diff --git a/source/adapters/hip/enqueue.cpp b/source/adapters/hip/enqueue.cpp index a1b78bf936..72c596e825 100644 --- a/source/adapters/hip/enqueue.cpp +++ b/source/adapters/hip/enqueue.cpp @@ -807,7 +807,10 @@ ur_result_t commonMemSetLargePattern(hipStream_t Stream, uint32_t PatternSize, hipPointerAttribute_t ptrAttribs{}; UR_CHECK_ERROR(hipPointerGetAttributes(&ptrAttribs, (const void *)Ptr)); - if (ptrAttribs.hostPointer) { + // The hostPointer attribute is non-null also for shared memory allocations. + // To make sure that this workaround only executes for host pinned memory, we + // need to check that isManaged attribute is false. + if (ptrAttribs.hostPointer && !ptrAttribs.isManaged) { const auto NumOfCopySteps = Size / PatternSize; const auto Offset = sizeof(uint32_t); const auto LeftPatternSize = PatternSize - Offset;