Skip to content

[UR][L0 v2][draft] Port USM alloc to adapter v2 #18179

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

Draft
wants to merge 1 commit into
base: sycl
Choose a base branch
from

Conversation

staniewzki
Copy link
Contributor

@staniewzki staniewzki commented Apr 24, 2025

This PR ports USM alloc enqueue API introduced to L0 adapter in #17112 to L0 adapter v2.

@@ -348,19 +348,21 @@ ur_result_t urEnqueueUSMDeviceAllocExp(
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is auto-generated. If you want to modify it you need to change scripts/templates/queue_api.cpp.mako (same is true for the corresponding .hpp file)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I don't think you need to actually modify it. As far as I understand you wanted to add ur_queue_handle_t param so that you can pass it to EnqueuedPool functions (like getBestFit, etc.). However, if I'm not mistaken, the queue is only used as an identifier by the EnqueuedPool implementation. This means that you can just do something like this in queue_immediate_in_order.cpp:

...
getBestFit(size, alignment, reinterpret_cast<ur_queue_handle_t>(this));

If the EnqueuedPool actually needs to have valid queue handle, then I think it would be better to rewrite EnqueuedPool (which you might need to do anyway, as it has some logic for handling events that is legacy-specific).


auto device = (type == UR_USM_TYPE_HOST) ? nullptr : hDevice;

std::vector<ur_event_handle_t> extendedWaitList;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don;t need to create a temporary vector here. commandListManger has getWaitListView function that you should use here (it also accepts an optional extra wait event). You just call: getWaitListView(commandListLocked, phEventWaitList, numEventsInWaitList, originAllocEvent);

return Ret;
}
} else {
*ppMem = std::get<0>(*asyncAlloc);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: std::tie(*ppMem, originAllocEvent) = *asyncAlloc;

const ur_exp_async_usm_alloc_properties_t *pProperties,
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
void **ppMem, ur_event_handle_t *phEvent) {
return enqueueUSMAllocHelper(hQueue, pPool, size, pProperties,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add TRACK_SCOPE_LATENCY("ur_queue_immediate_in_order_t::enqueueUSMHostAllocExp"); at the beginning of this function (and other function you implement in this patch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants