Skip to content

Commit 582c88e

Browse files
committed
[L0 v2] implement enqueueUSMPrefetch and Advise
1 parent 1441037 commit 582c88e

File tree

2 files changed

+48
-16
lines changed

2 files changed

+48
-16
lines changed

source/adapters/level_zero/v2/queue_immediate_in_order.cpp

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -545,24 +545,61 @@ ur_result_t ur_queue_immediate_in_order_t::enqueueUSMPrefetch(
545545
const void *pMem, size_t size, ur_usm_migration_flags_t flags,
546546
uint32_t numEventsInWaitList, const ur_event_handle_t *phEventWaitList,
547547
ur_event_handle_t *phEvent) {
548-
std::ignore = pMem;
549-
std::ignore = size;
550548
std::ignore = flags;
551-
std::ignore = numEventsInWaitList;
552-
std::ignore = phEventWaitList;
553-
std::ignore = phEvent;
554-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
549+
550+
std::scoped_lock<ur_shared_mutex> Lock(this->Mutex);
551+
552+
auto handler = getCommandListHandlerForCompute();
553+
auto signalEvent = getSignalEvent(handler, phEvent);
554+
555+
auto [pWaitEvents, numWaitEvents] =
556+
getWaitListView(phEventWaitList, numEventsInWaitList, handler);
557+
558+
if (pWaitEvents) {
559+
ZE2UR_CALL(zeCommandListAppendBarrier, (handler->commandList.get(), nullptr,
560+
numWaitEvents, pWaitEvents));
561+
}
562+
// TODO: figure out how to translate "flags"
563+
ZE2UR_CALL(zeCommandListAppendMemoryPrefetch,
564+
(handler->commandList.get(), pMem, size));
565+
ZE2UR_CALL(zeCommandListAppendSignalEvent,
566+
(handler->commandList.get(), signalEvent));
567+
568+
lastHandler = handler;
569+
570+
return UR_RESULT_SUCCESS;
555571
}
556572

557573
ur_result_t
558574
ur_queue_immediate_in_order_t::enqueueUSMAdvise(const void *pMem, size_t size,
559575
ur_usm_advice_flags_t advice,
560576
ur_event_handle_t *phEvent) {
561-
std::ignore = pMem;
562-
std::ignore = size;
563-
std::ignore = advice;
564-
std::ignore = phEvent;
565-
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
577+
std::ignore = flags;
578+
579+
auto zeAdvice = ur_cast<ze_memory_advice_t>(advice);
580+
581+
std::scoped_lock<ur_shared_mutex> Lock(this->Mutex);
582+
583+
auto handler = getCommandListHandlerForCompute();
584+
auto signalEvent = getSignalEvent(handler, phEvent);
585+
586+
auto [pWaitEvents, numWaitEvents] = getWaitListView(nullptr, 0, handler);
587+
588+
if (pWaitEvents) {
589+
ZE2UR_CALL(zeCommandListAppendBarrier, (handler->commandList.get(), nullptr,
590+
numWaitEvents, pWaitEvents));
591+
}
592+
593+
// TODO: figure out how to translate "flags"
594+
ZE2UR_CALL(zeCommandListAppendMemAdvise,
595+
(handler->commandList.get(), this->hDevice->ZeDevice, pMem, size,
596+
zeAdvice));
597+
ZE2UR_CALL(zeCommandListAppendSignalEvent,
598+
(handler->commandList.get(), signalEvent));
599+
600+
lastHandler = handler;
601+
602+
return UR_RESULT_SUCCESS;
566603
}
567604

568605
ur_result_t ur_queue_immediate_in_order_t::enqueueUSMFill2D(

test/conformance/enqueue/enqueue_adapter_level_zero_v2.match

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,7 @@ urEnqueueMemUnmapTestWithParam.InvalidNullPtrEventWaitList/Intel_R__oneAPI_Unifi
287287
urEnqueueMemUnmapTestWithParam.InvalidNullPtrEventWaitList/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___4096_UR_MEM_FLAG_ALLOC_HOST_POINTER
288288
urEnqueueMemUnmapTestWithParam.InvalidNullPtrEventWaitList/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___6000_UR_MEM_FLAG_ALLOC_HOST_POINTER
289289
urEnqueueUSMFill2DNegativeTest.OutOfBounds/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
290-
urEnqueueUSMAdviseWithParamTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_USM_ADVICE_FLAG_DEFAULT
291-
urEnqueueUSMAdviseTest.MultipleParamsSuccess/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
292290
urEnqueueUSMAdviseTest.InvalidSizeTooLarge/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
293-
urEnqueueUSMAdviseTest.NonCoherentDeviceMemorySuccessOrWarning/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
294-
urEnqueueUSMPrefetchWithParamTest.Success/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_USM_MIGRATION_FLAG_DEFAULT
295-
urEnqueueUSMPrefetchWithParamTest.CheckWaitEvent/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}___UR_USM_MIGRATION_FLAG_DEFAULT
296291
urEnqueueUSMPrefetchTest.InvalidSizeTooLarge/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
297292
urEnqueueReadHostPipeTest.InvalidNullHandleQueue/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_
298293
urEnqueueReadHostPipeTest.InvalidNullHandleProgram/Intel_R__oneAPI_Unified_Runtime_over_Level_Zero___{{.*}}_

0 commit comments

Comments
 (0)