Skip to content

Commit 86ebe33

Browse files
committed
[DeviceSanitizer] Handle mem buffer is created with flag COPY_HOST_POINTER
1 parent 167ddf9 commit 86ebe33

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

source/loader/layers/sanitizer/ur_sanddi.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,19 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate(
411411

412412
std::shared_ptr<MemBuffer> pMemBuffer =
413413
std::make_shared<MemBuffer>(hContext, size, hostPtrOrNull);
414+
415+
if (Host && (flags & UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) {
416+
std::shared_ptr<ContextInfo> CtxInfo =
417+
context.interceptor->getContextInfo(hContext);
418+
for (const auto &hDevice : CtxInfo->DeviceList) {
419+
ManagedQueue InternalQueue(hContext, hDevice);
420+
char *Handle;
421+
UR_CALL(pMemBuffer->getHandle(hDevice, Handle));
422+
UR_CALL(context.urDdiTable.Enqueue.pfnUSMMemcpy(
423+
InternalQueue, true, Handle, Host, size, 0, nullptr, nullptr));
424+
}
425+
}
426+
414427
ur_result_t result = context.interceptor->insertMemBuffer(pMemBuffer);
415428
*phBuffer = ur_cast<ur_mem_handle_t>(pMemBuffer.get());
416429

0 commit comments

Comments
 (0)