Skip to content
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

[UR] Add support for bidirectional USM prefetching #2312

Open
wants to merge 43 commits into
base: main
Choose a base branch
from

Conversation

ianayl
Copy link

@ianayl ianayl commented Nov 11, 2024

This PR implements the previously unimplemented ur_usm_migration_flags_t enum, and adds the logic for prefetching for from the device to host for each implemented adapter.

Note that level zero currently does not support this behavior: it remains unimplemented for now until level zero implements a way to prefetch from device to host.

Corresponding intel/llvm PR for testing: intel/llvm#16047

@ianayl ianayl requested review from a team as code owners December 20, 2024 22:00
@ianayl ianayl requested review from reble and jchlanda December 20, 2024 22:00
Comment on lines 1304 to 1308
if (Flags == UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST) {
logger::warning("USM migration from device to host is not currently "
"supported by level zero.");
return UR_RESULT_SUCCESS;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This early return is a problem for out-of-order command-lists in that it doesn't respect the command dependencies or signal dependent commands when finished.

In the else branch below think we just want to opt-out of the actual zeCommandListAppendMemoryPrefetch but keep the zeCommandListAppendWaitOnEvents and zeCommandListAppendSignalEvent commnads.

Copy link
Author

Choose a reason for hiding this comment

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

Hey thanks for reviewing! Admittedly I'm not the most familiar with how things work in L0; would I also need to do this for source/adapters/level_zero/memory.cpp:1243?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I think that the same issue with an early return, the OutEvent output parameter won't be set and it's not respecting EventWaitList dependencies

Copy link
Contributor

@jchlanda jchlanda left a comment

Choose a reason for hiding this comment

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

CUDA/HIP 👍

Copy link
Contributor

@kbenzie kbenzie left a comment

Choose a reason for hiding this comment

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

Looks like there's conflicts in generated files, please pull in the latest changes from the main branch and during conflit resolution run the generate target to resolve those conflicts.

Comment on lines 1 to 13
{{NONDETERMINISTIC}}
urEnqueueKernelLaunchTest.InvalidKernelArgs/*
urEnqueueKernelLaunchKernelWgSizeTest.NonMatchingLocalSize/*
urEnqueueKernelLaunchKernelSubGroupTest.Success/*
urEnqueueMemBufferMapTestWithWriteFlagParam.SuccessWrite/*__UR_MAP_FLAG_WRITE_INVALIDATE_REGION
urEnqueueUSMAdviseWithParamTest.Success/*__UR_USM_ADVICE_FLAG_DEFAULT
urEnqueueUSMAdviseTest.MultipleParamsSuccess/*
urEnqueueUSMPrefetchWithParamTest.Success/*__UR_USM_MIGRATION_FLAG_DEFAULT
urEnqueueUSMPrefetchWithParamTest.CheckWaitEvent/*__UR_USM_MIGRATION_FLAG_DEFAULT
urEnqueueUSMPrefetchWithParamTest.Success/*__UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE
urEnqueueUSMPrefetchWithParamTest.Success/*__UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST
urEnqueueUSMPrefetchWithParamTest.CheckWaitEvent/*__UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE
urEnqueueUSMPrefetchWithParamTest.CheckWaitEvent/*__UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST
urEnqueueTimestampRecordingExpTest.Success/*
urEnqueueTimestampRecordingExpTest.SuccessBlocking/*
urEnqueueTimestampRecordingExpTest.SuccessBlocking/*
Copy link
Contributor

Choose a reason for hiding this comment

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

We've recently merged #2479 which removes uses of match files from the CTS, the new mechanism for tracking know failures is described here.

@github-actions github-actions bot added conformance Conformance test suite issues. specification Changes or additions to the specification experimental Experimental feature additions/changes/specification level-zero L0 adapter specific issues cuda CUDA adapter specific issues hip HIP adapter specific issues opencl OpenCL adapter specific issues command-buffer Command Buffer feature addition/changes/specification labels Feb 6, 2025
cmd_buf_handle, device_ptrs[0], allocation_size,
UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE, 0, nullptr, 0, nullptr, nullptr,
nullptr, nullptr));
ASSERT_SUCCESS(urCommandBufferAppendUSMPrefetchExp(
Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding is that changes include calling prefetch here twice for host and device in both directions. Is that consistent across all tests?

Copy link
Author

Choose a reason for hiding this comment

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

As far as I'm aware I'm checking both directions for only tests checking functionality; e.g. I am not checking both directions if the test is checking how the function handles invalid input. Let me know if you'd like the tests changed to always use both directions regardless.

@github-actions github-actions bot added the loader Loader related feature/bug label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command-buffer Command Buffer feature addition/changes/specification conformance Conformance test suite issues. cuda CUDA adapter specific issues experimental Experimental feature additions/changes/specification hip HIP adapter specific issues level-zero L0 adapter specific issues loader Loader related feature/bug opencl OpenCL adapter specific issues specification Changes or additions to the specification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants