[UR][L0] Migrate discrete buffer through host when P2P is not accessible#22010
Open
ldorau wants to merge 1 commit into
Open
Conversation
When a buffer on a discrete GPU needs to be accessed from a different device and P2P access is not enabled, migrate the data through a temporary host buffer instead of returning UR_RESULT_ERROR_UNSUPPORTED_FEATURE. Before migrating, wait for pending operations (from the wait list) to complete, ensuring that prior kernel writes to the buffer are visible. Fixes: intel#22007 Fixes: intel#22008 Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Contributor
Author
|
Please review @intel/unified-runtime-reviewers-level-zero |
mateuszpn
reviewed
May 14, 2026
| // Migrate buffer through the host: copy from the current device to a | ||
| // temporary host buffer, then from host to the target device. | ||
| auto bufferSize = getSize(); | ||
| std::vector<char> hostBuf(bufferSize); |
Contributor
There was a problem hiding this comment.
nit: maybe it is worth to consider USM allocation in place of heap, like in line 100
pbalcer
reviewed
May 14, 2026
Comment on lines
+369
to
+372
| for (uint32_t i = 0; i < waitListView.num; i++) { | ||
| ZE2UR_CALL_THROWS(zeEventHostSynchronize, | ||
| (waitListView.handles[i], UINT64_MAX)); | ||
| } |
Contributor
There was a problem hiding this comment.
I don't think this will work. The operation also needs to be ordered with regards to the command list itself, so something like this will be better:
if (numWaitEvents > 0) {
ZE2UR_CALL(zeCommandListAppendWaitOnEvents,
(zeCommandList.get(), numWaitEvents, pWaitEvents));
}
ZE2UR_CALL(zeCommandListHostSynchronize, (zeCommandList.get(), UINT64_MAX));
| auto bufferSize = getSize(); | ||
| std::vector<char> hostBuf(bufferSize); | ||
|
|
||
| UR_CALL_THROWS(synchronousZeCopy(hContext, activeAllocationDevice, |
Contributor
There was a problem hiding this comment.
I don't like the fact that this is synchronous. Can you explore what it would take to make it async? I think we'd need to keep the allocation somewhere.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a buffer on a discrete GPU needs to be accessed from a different
device and P2P access is not enabled, migrate the data through a
temporary host buffer instead of returning UR_RESULT_ERROR_UNSUPPORTED_FEATURE.
Before migrating, wait for pending operations (from the wait list) to
complete, ensuring that prior kernel writes to the buffer are visible.
Fixes: #22007
Fixes: #22008