diff --git a/source/adapters/level_zero/memory.cpp b/source/adapters/level_zero/memory.cpp index fe2f833a28..dde4d1d239 100644 --- a/source/adapters/level_zero/memory.cpp +++ b/source/adapters/level_zero/memory.cpp @@ -236,7 +236,7 @@ static ur_result_t enqueueMemFillHelper(ur_command_t CommandType, // PatternSize must be a power of two for zeCommandListAppendMemoryFill. // When it's not, the fill is emulated with zeCommandListAppendMemoryCopy. - if (PatternSize && !(PatternSize & (PatternSize - 1))) { + if (isPowerOf2(PatternSize)) { ZE2UR_CALL(zeCommandListAppendMemoryFill, (ZeCommandList, Ptr, Pattern, PatternSize, Size, ZeEvent, WaitList.Length, WaitList.ZeEventList)); diff --git a/source/adapters/opencl/usm.cpp b/source/adapters/opencl/usm.cpp index 0d64f23d13..3f4382fc0d 100644 --- a/source/adapters/opencl/usm.cpp +++ b/source/adapters/opencl/usm.cpp @@ -8,6 +8,8 @@ // //===----------------------------------------------------------------------===// +#include + #include "common.hpp" inline cl_mem_alloc_flags_intel @@ -239,7 +241,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMFill( return mapCLErrorToUR(CLErr); } - if (patternSize <= 128) { + if (patternSize <= 128 && isPowerOf2(patternSize)) { clEnqueueMemFillINTEL_fn EnqueueMemFill = nullptr; UR_RETURN_ON_FAILURE( cl_ext::getExtFuncFromContext(