[UR][L0V2] implement host-mediated buffer migration fallback#22152
[UR][L0V2] implement host-mediated buffer migration fallback#22152kweronsx wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Replaces the UR_RESULT_ERROR_UNSUPPORTED_FEATURE failure in ur_discrete_buffer_handle_t::getDevicePtr (Level Zero v2 adapter) with a host-mediated migration fallback when peer-to-peer access between the active allocation device and the requested device is unavailable. The fallback allocates a temporary USM host buffer, copies device→host from the active allocation, then host→device into the target allocation via migrateBufferTo, and updates activeAllocationDevice.
Changes:
- Removes the unconditional throw on the non-P2P path and downgrades the log to DEBUG with a migration message.
- Adds a temporary USM host allocation (RAII-guarded via
usm_unique_ptr_t) and performs source-device→host→target-device copies usingsynchronousZeCopyandmigrateBufferTo. - Sets
activeAllocationDeviceto the target device and returns the offset pointer into the new active allocation.
116faca to
75ea41d
Compare
|
@kweronsx Rebase on the current sycl branch so that CI builds could start. |
6fbeb9d to
1abfeb7
Compare
1abfeb7 to
461bfb3
Compare
|
@intel/unified-runtime-reviewers @intel/unified-runtime-reviewers-level-zero please review. Thank you |
| ze_bool_t isImmediate = false; | ||
| ZE2UR_CALL_THROWS(zeCommandListIsImmediate, (cmdList, &isImmediate)); | ||
|
|
||
| if (isImmediate) { |
There was a problem hiding this comment.
There was a problem hiding this comment.
When can cmdlist be null? I don't think the current implementation will work for non-immediate cmdlists. The staging buffer copy needs to be order with the already appended cmdlist operations, not just events. Also, if the events themselves are from non-immediate queue, this may hang, because the non-immediate cmdlist (i.e., a batch) may not have been ran yet.
This either needs to be done fully asynchronously (which would be my preference), or the non-immediate path needs to make sure the batch/cmdlist, and related associated events, are complete prior to executing this synchronous copy.
There was a problem hiding this comment.
I see that cmdList is explicitly passed as nullptr only here. Command list manager always passes its own internal command list to getDevicePtr, which can be of regular type.
To make it fully asynchronous we would have to:
- create host staging buffer and keep its lifetime until the copy is finished (or the ur_discrete_buffer_handle_t lifetime)
- append wait on waitlist events
- append copy srcPtr -> hostPtr
- append copy hostPtr -> dstPtr
- no synchronization - the events are ordered
and the!cmdListpath stays as is, is that correct?
1b09598 to
36cff3a
Compare
| ze_bool_t isImmediate = false; | ||
| ZE2UR_CALL_THROWS(zeCommandListIsImmediate, (cmdList, &isImmediate)); | ||
|
|
||
| if (isImmediate) { |
There was a problem hiding this comment.
When can cmdlist be null? I don't think the current implementation will work for non-immediate cmdlists. The staging buffer copy needs to be order with the already appended cmdlist operations, not just events. Also, if the events themselves are from non-immediate queue, this may hang, because the non-immediate cmdlist (i.e., a batch) may not have been ran yet.
This either needs to be done fully asynchronously (which would be my preference), or the non-immediate path needs to make sure the batch/cmdlist, and related associated events, are complete prior to executing this synchronous copy.
e8b8b9a to
167d748
Compare
When two devices lack P2P access, getDevicePtr() unconditionally threw UR_RESULT_ERROR_UNSUPPORTED_FEATURE instead of migrating the buffer through a temporary host allocation. Implement the fallback: copy active device -> host -> target device Resumes work on intel#22010
When two devices lack P2P access, getDevicePtr() was unconditionally throwing UR_RESULT_ERROR_UNSUPPORTED_FEATURE instead of migrating the buffer through a temporary host allocation. Implement the fallback: copy active-device -> host -> target device.