Skip to content

Commit

Permalink
Added condition with isPowerOf2 to opencl Fill
Browse files Browse the repository at this point in the history
  • Loading branch information
konradkusiak97 committed Mar 8, 2024
1 parent 293b670 commit 3887dfd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion source/adapters/level_zero/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 3 additions & 1 deletion source/adapters/opencl/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//
//===----------------------------------------------------------------------===//

#include <ur/ur.hpp>

#include "common.hpp"

inline cl_mem_alloc_flags_intel
Expand Down Expand Up @@ -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<clEnqueueMemFillINTEL_fn>(
Expand Down

0 comments on commit 3887dfd

Please sign in to comment.