Skip to content

Commit

Permalink
Merge pull request #1858 from zhaomaosu/buffer-copy-host-ptr
Browse files Browse the repository at this point in the history
[DeviceSanitizer] Handle mem buffer is created with flag COPY_HOST_POINTER
  • Loading branch information
omarahmed1111 authored Aug 20, 2024
2 parents 3296886 + 9ee4588 commit 0702e7b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions source/loader/layers/sanitizer/ur_sanddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,19 @@ __urdlllocal ur_result_t UR_APICALL urMemBufferCreate(

std::shared_ptr<MemBuffer> pMemBuffer =
std::make_shared<MemBuffer>(hContext, size, hostPtrOrNull);

if (Host && (flags & UR_MEM_FLAG_ALLOC_COPY_HOST_POINTER)) {
std::shared_ptr<ContextInfo> CtxInfo =
getContext()->interceptor->getContextInfo(hContext);
for (const auto &hDevice : CtxInfo->DeviceList) {
ManagedQueue InternalQueue(hContext, hDevice);
char *Handle = nullptr;
UR_CALL(pMemBuffer->getHandle(hDevice, Handle));
UR_CALL(getContext()->urDdiTable.Enqueue.pfnUSMMemcpy(
InternalQueue, true, Handle, Host, size, 0, nullptr, nullptr));
}
}

ur_result_t result = getContext()->interceptor->insertMemBuffer(pMemBuffer);
*phBuffer = ur_cast<ur_mem_handle_t>(pMemBuffer.get());

Expand Down

0 comments on commit 0702e7b

Please sign in to comment.