Skip to content

Commit 483a632

Browse files
Changed to uint8_t and improved fix as suggested
1 parent b8e15e2 commit 483a632

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

source/adapters/opencl/usm.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMFill(
276276
cl_ext::MemBlockingFreeName, &USMFree));
277277

278278
cl_int ClErr = CL_SUCCESS;
279-
auto HostBuffer = static_cast<unsigned char *>(
280-
HostMemAlloc(CLContext, nullptr, size, 0, &ClErr));
279+
auto HostBuffer =
280+
static_cast<uint8_t *>(HostMemAlloc(CLContext, nullptr, size, 0, &ClErr));
281281
CL_RETURN_ON_FAILURE(ClErr);
282282

283-
auto NumChunks = size / patternSize;
284-
for (size_t i = 0; i < NumChunks; i++) {
285-
auto Dest = HostBuffer + i * patternSize;
286-
memcpy(Dest, pPattern, patternSize);
283+
auto *End = HostBuffer + size;
284+
for (auto *Iter = HostBuffer; Iter < End; Iter += patternSize) {
285+
std::memcpy(Iter, pPattern, patternSize);
287286
}
288287

289288
cl_event CopyEvent = nullptr;

0 commit comments

Comments
 (0)