-
Notifications
You must be signed in to change notification settings - Fork 795
[UR][Offload] Various small fixes for offload adapter #19832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,16 +93,19 @@ ur_result_t doWait(ur_queue_handle_t hQueue, uint32_t numEventsInWaitList, | |
| OL_RETURN_ON_ERR(makeEvent(TYPE, TargetQueue, hQueue, phEvent)); | ||
|
|
||
| if constexpr (Barrier) { | ||
| ol_event_handle_t BarrierEvent; | ||
| ur_event_handle_t BarrierEvent; | ||
| if (phEvent) { | ||
| BarrierEvent = (*phEvent)->OffloadEvent; | ||
| BarrierEvent = *phEvent; | ||
| urEventRetain(BarrierEvent); | ||
| } else { | ||
| OL_RETURN_ON_ERR(olCreateEvent(TargetQueue, &BarrierEvent)); | ||
| OL_RETURN_ON_ERR(makeEvent(TYPE, TargetQueue, hQueue, &BarrierEvent)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: I know it's not added in this PR but the all caps name
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a template parameter, so in my head it inherits the naming scheme of enum variants which are all caps. Although I can't exactly say why I think it should work that way. |
||
| } | ||
|
|
||
| // Ensure any newly created work waits on this barrier | ||
| if (hQueue->Barrier) { | ||
| OL_RETURN_ON_ERR(olDestroyEvent(hQueue->Barrier)); | ||
| if (auto Err = urEventRelease(hQueue->Barrier)) { | ||
| return Err; | ||
| } | ||
| } | ||
| hQueue->Barrier = BarrierEvent; | ||
|
|
||
|
|
@@ -114,7 +117,7 @@ ur_result_t doWait(ur_queue_handle_t hQueue, uint32_t numEventsInWaitList, | |
| if (Q == TargetQueue) { | ||
| continue; | ||
| } | ||
| OL_RETURN_ON_ERR(olWaitEvents(Q, &BarrierEvent, 1)); | ||
| OL_RETURN_ON_ERR(olWaitEvents(Q, &BarrierEvent->OffloadEvent, 1)); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -260,6 +263,22 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferWrite( | |
| blockingWrite, numEventsInWaitList, phEventWaitList, phEvent); | ||
| } | ||
|
|
||
| UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferCopy( | ||
| ur_queue_handle_t hQueue, ur_mem_handle_t hBufferSrc, | ||
| ur_mem_handle_t hBufferDst, size_t srcOffset, size_t dstOffset, size_t size, | ||
| uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList, | ||
| ur_event_handle_t *phEvent) { | ||
| char *DevPtrSrc = | ||
| reinterpret_cast<char *>(std::get<BufferMem>(hBufferSrc->Mem).Ptr); | ||
| char *DevPtrDst = | ||
| reinterpret_cast<char *>(std::get<BufferMem>(hBufferDst->Mem).Ptr); | ||
|
|
||
| return doMemcpy(UR_COMMAND_MEM_BUFFER_COPY, hQueue, DevPtrDst + dstOffset, | ||
| hQueue->OffloadDevice, DevPtrSrc + srcOffset, | ||
| hQueue->OffloadDevice, size, false, numEventsInWaitList, | ||
| phEventWaitList, phEvent); | ||
| } | ||
|
|
||
| UR_APIEXPORT ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead( | ||
| ur_queue_handle_t hQueue, ur_program_handle_t hProgram, const char *name, | ||
| bool blockingRead, size_t count, size_t offset, void *pDst, | ||
|
|
@@ -366,3 +385,22 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemUnmap( | |
|
|
||
| return Result; | ||
| } | ||
|
|
||
| UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMMemcpy( | ||
| ur_queue_handle_t hQueue, bool blocking, void *pDst, const void *pSrc, | ||
| size_t size, uint32_t numEventsInWaitList, | ||
| const ur_event_handle_t *phEventWaitList, ur_event_handle_t *phEvent) { | ||
| auto GetDevice = [&](const void *Ptr) { | ||
| auto Res = hQueue->UrContext->getAllocType(Ptr); | ||
| if (!Res) | ||
| return Adapter->HostDevice; | ||
| return Res->Type == OL_ALLOC_TYPE_HOST ? Adapter->HostDevice | ||
| : hQueue->OffloadDevice; | ||
| }; | ||
|
|
||
| return doMemcpy(UR_COMMAND_USM_MEMCPY, hQueue, pDst, GetDevice(pDst), pSrc, | ||
| GetDevice(pSrc), size, blocking, numEventsInWaitList, | ||
| phEventWaitList, phEvent); | ||
|
|
||
| return UR_RESULT_SUCCESS; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.