Skip to content

Commit

Permalink
[SYCL][Graph] Handle PI flags for mem-advise op (intel#12431)
Browse files Browse the repository at this point in the history
Translates PI to UR and passes them the backends.
  • Loading branch information
mfrancepillois authored Jan 23, 2024
1 parent e6d6a47 commit 2603314
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions sycl/plugins/unified_runtime/pi2ur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4652,13 +4652,39 @@ inline pi_result piextCommandBufferAdviseUSM(
pi_ext_command_buffer CommandBuffer, const void *Ptr, size_t Length,
pi_mem_advice Advice, pi_uint32 NumSyncPointsInWaitList,
const pi_ext_sync_point *SyncPointWaitList, pi_ext_sync_point *SyncPoint) {
// TODO: Handle advice correctly
(void)Advice;

ur_exp_command_buffer_handle_t UrCommandBuffer =
reinterpret_cast<ur_exp_command_buffer_handle_t>(CommandBuffer);

ur_usm_advice_flags_t UrAdvice{};
if (Advice & PI_MEM_ADVICE_CUDA_SET_READ_MOSTLY) {
UrAdvice |= UR_USM_ADVICE_FLAG_SET_READ_MOSTLY;
}
if (Advice & PI_MEM_ADVICE_CUDA_UNSET_READ_MOSTLY) {
UrAdvice |= UR_USM_ADVICE_FLAG_CLEAR_READ_MOSTLY;
}
if (Advice & PI_MEM_ADVICE_CUDA_SET_PREFERRED_LOCATION) {
UrAdvice |= UR_USM_ADVICE_FLAG_SET_PREFERRED_LOCATION;
}
if (Advice & PI_MEM_ADVICE_CUDA_UNSET_PREFERRED_LOCATION) {
UrAdvice |= UR_USM_ADVICE_FLAG_CLEAR_PREFERRED_LOCATION;
}
if (Advice & PI_MEM_ADVICE_CUDA_SET_ACCESSED_BY) {
UrAdvice |= UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_DEVICE;
}
if (Advice & PI_MEM_ADVICE_CUDA_UNSET_ACCESSED_BY) {
UrAdvice |= UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_DEVICE;
}
if (Advice & PI_MEM_ADVICE_CUDA_SET_ACCESSED_BY_HOST) {
UrAdvice |= UR_USM_ADVICE_FLAG_SET_ACCESSED_BY_HOST;
}
if (Advice & PI_MEM_ADVICE_CUDA_UNSET_ACCESSED_BY_HOST) {
UrAdvice |= UR_USM_ADVICE_FLAG_CLEAR_ACCESSED_BY_HOST;
}
if (Advice & PI_MEM_ADVICE_RESET) {
UrAdvice |= UR_USM_ADVICE_FLAG_DEFAULT;
}

HANDLE_ERRORS(urCommandBufferAppendUSMAdviseExp(
UrCommandBuffer, Ptr, Length, UrAdvice, NumSyncPointsInWaitList,
SyncPointWaitList, SyncPoint));
Expand Down

0 comments on commit 2603314

Please sign in to comment.