Skip to content

Commit 413ee06

Browse files
let's pretend it all has been done in one commit
TODO cleanup in out_of_order and in_order_queues - remove comments
1 parent e890640 commit 413ee06

21 files changed

+2164
-462
lines changed

unified-runtime/source/adapters/level_zero/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ if(UR_BUILD_ADAPTER_L0_V2)
171171
${CMAKE_CURRENT_SOURCE_DIR}/v2/memory.hpp
172172
${CMAKE_CURRENT_SOURCE_DIR}/v2/lockable.hpp
173173
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_api.hpp
174+
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_batched.hpp
174175
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_in_order.hpp
175176
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_out_of_order.hpp
176177
${CMAKE_CURRENT_SOURCE_DIR}/v2/usm.hpp
@@ -187,6 +188,7 @@ if(UR_BUILD_ADAPTER_L0_V2)
187188
${CMAKE_CURRENT_SOURCE_DIR}/v2/kernel.cpp
188189
${CMAKE_CURRENT_SOURCE_DIR}/v2/memory.cpp
189190
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_api.cpp
191+
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_batched.cpp
190192
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_create.cpp
191193
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_in_order.cpp
192194
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_out_of_order.cpp

unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp

Lines changed: 62 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "../command_buffer_command.hpp"
1313
#include "../helpers/kernel_helpers.hpp"
1414
#include "../ur_interface_loader.hpp"
15+
#include "command_list_manager.hpp"
1516
#include "logger/ur_logger.hpp"
1617
#include "queue_handle.hpp"
1718

@@ -323,9 +324,12 @@ ur_result_t urCommandBufferAppendKernelLaunchExp(
323324
auto eventsWaitList = commandBuffer->getWaitListFromSyncPoints(
324325
syncPointWaitList, numSyncPointsInWaitList);
325326

327+
wait_list_view waitListView =
328+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
329+
326330
UR_CALL(commandListLocked->appendKernelLaunch(
327331
hKernel, workDim, pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize, 0,
328-
nullptr, numSyncPointsInWaitList, eventsWaitList,
332+
nullptr, waitListView,
329333
commandBuffer->createEventIfRequested(retSyncPoint)));
330334

331335
return UR_RESULT_SUCCESS;
@@ -348,8 +352,11 @@ ur_result_t urCommandBufferAppendUSMMemcpyExp(
348352
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
349353
pSyncPointWaitList, numSyncPointsInWaitList);
350354

355+
wait_list_view waitListView =
356+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
357+
351358
UR_CALL(commandListLocked->appendUSMMemcpy(
352-
false, pDst, pSrc, size, numSyncPointsInWaitList, eventsWaitList,
359+
false, pDst, pSrc, size, waitListView,
353360
hCommandBuffer->createEventIfRequested(pSyncPoint)));
354361

355362
return UR_RESULT_SUCCESS;
@@ -375,9 +382,12 @@ ur_result_t urCommandBufferAppendMemBufferCopyExp(
375382
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
376383
pSyncPointWaitList, numSyncPointsInWaitList);
377384

385+
wait_list_view waitListView =
386+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
387+
378388
UR_CALL(commandListLocked->appendMemBufferCopy(
379-
hSrcMem, hDstMem, srcOffset, dstOffset, size, numSyncPointsInWaitList,
380-
eventsWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
389+
hSrcMem, hDstMem, srcOffset, dstOffset, size, waitListView,
390+
hCommandBuffer->createEventIfRequested(pSyncPoint)));
381391

382392
return UR_RESULT_SUCCESS;
383393
} catch (...) {
@@ -402,9 +412,12 @@ ur_result_t urCommandBufferAppendMemBufferWriteExp(
402412
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
403413
pSyncPointWaitList, numSyncPointsInWaitList);
404414

415+
wait_list_view waitListView =
416+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
417+
405418
UR_CALL(commandListLocked->appendMemBufferWrite(
406-
hBuffer, false, offset, size, pSrc, numSyncPointsInWaitList,
407-
eventsWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
419+
hBuffer, false, offset, size, pSrc, waitListView,
420+
hCommandBuffer->createEventIfRequested(pSyncPoint)));
408421

409422
return UR_RESULT_SUCCESS;
410423
} catch (...) {
@@ -427,9 +440,12 @@ ur_result_t urCommandBufferAppendMemBufferReadExp(
427440
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
428441
pSyncPointWaitList, numSyncPointsInWaitList);
429442

443+
wait_list_view waitListView =
444+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
445+
430446
UR_CALL(commandListLocked->appendMemBufferRead(
431-
hBuffer, false, offset, size, pDst, numSyncPointsInWaitList,
432-
eventsWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
447+
hBuffer, false, offset, size, pDst, waitListView,
448+
hCommandBuffer->createEventIfRequested(pSyncPoint)));
433449

434450
return UR_RESULT_SUCCESS;
435451
} catch (...) {
@@ -456,10 +472,13 @@ ur_result_t urCommandBufferAppendMemBufferCopyRectExp(
456472
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
457473
pSyncPointWaitList, numSyncPointsInWaitList);
458474

475+
wait_list_view waitListView =
476+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
477+
459478
UR_CALL(commandListLocked->appendMemBufferCopyRect(
460479
hSrcMem, hDstMem, srcOrigin, dstOrigin, region, srcRowPitch,
461-
srcSlicePitch, dstRowPitch, dstSlicePitch, numSyncPointsInWaitList,
462-
eventsWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
480+
srcSlicePitch, dstRowPitch, dstSlicePitch, waitListView,
481+
hCommandBuffer->createEventIfRequested(pSyncPoint)));
463482

464483
return UR_RESULT_SUCCESS;
465484
} catch (...) {
@@ -486,10 +505,12 @@ ur_result_t urCommandBufferAppendMemBufferWriteRectExp(
486505
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
487506
pSyncPointWaitList, numSyncPointsInWaitList);
488507

508+
wait_list_view waitListView =
509+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
510+
489511
UR_CALL(commandListLocked->appendMemBufferWriteRect(
490512
hBuffer, false, bufferOffset, hostOffset, region, bufferRowPitch,
491-
bufferSlicePitch, hostRowPitch, hostSlicePitch, pSrc,
492-
numSyncPointsInWaitList, eventsWaitList,
513+
bufferSlicePitch, hostRowPitch, hostSlicePitch, pSrc, waitListView,
493514
hCommandBuffer->createEventIfRequested(pSyncPoint)));
494515

495516
return UR_RESULT_SUCCESS;
@@ -517,10 +538,12 @@ ur_result_t urCommandBufferAppendMemBufferReadRectExp(
517538
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
518539
pSyncPointWaitList, numSyncPointsInWaitList);
519540

541+
wait_list_view waitListView =
542+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
543+
520544
UR_CALL(commandListLocked->appendMemBufferReadRect(
521545
hBuffer, false, bufferOffset, hostOffset, region, bufferRowPitch,
522-
bufferSlicePitch, hostRowPitch, hostSlicePitch, pDst,
523-
numSyncPointsInWaitList, eventsWaitList,
546+
bufferSlicePitch, hostRowPitch, hostSlicePitch, pDst, waitListView,
524547
hCommandBuffer->createEventIfRequested(pSyncPoint)));
525548

526549
return UR_RESULT_SUCCESS;
@@ -543,9 +566,12 @@ ur_result_t urCommandBufferAppendUSMFillExp(
543566
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
544567
pSyncPointWaitList, numSyncPointsInWaitList);
545568

569+
wait_list_view waitListView =
570+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
571+
546572
UR_CALL(commandListLocked->appendUSMFill(
547-
pMemory, patternSize, pPattern, size, numSyncPointsInWaitList,
548-
eventsWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
573+
pMemory, patternSize, pPattern, size, waitListView,
574+
hCommandBuffer->createEventIfRequested(pSyncPoint)));
549575
return UR_RESULT_SUCCESS;
550576
} catch (...) {
551577
return exceptionToResult(std::current_exception());
@@ -567,9 +593,12 @@ ur_result_t urCommandBufferAppendMemBufferFillExp(
567593
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
568594
pSyncPointWaitList, numSyncPointsInWaitList);
569595

596+
wait_list_view waitListView =
597+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
598+
570599
UR_CALL(commandListLocked->appendMemBufferFill(
571-
hBuffer, pPattern, patternSize, offset, size, numSyncPointsInWaitList,
572-
eventsWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
600+
hBuffer, pPattern, patternSize, offset, size, waitListView,
601+
hCommandBuffer->createEventIfRequested(pSyncPoint)));
573602

574603
return UR_RESULT_SUCCESS;
575604
} catch (...) {
@@ -593,8 +622,11 @@ ur_result_t urCommandBufferAppendUSMPrefetchExp(
593622
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
594623
pSyncPointWaitList, numSyncPointsInWaitList);
595624

625+
wait_list_view waitListView =
626+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
627+
596628
UR_CALL(commandListLocked->appendUSMPrefetch(
597-
pMemory, size, flags, numSyncPointsInWaitList, eventsWaitList,
629+
pMemory, size, flags, waitListView,
598630
hCommandBuffer->createEventIfRequested(pSyncPoint)));
599631

600632
return UR_RESULT_SUCCESS;
@@ -617,8 +649,11 @@ ur_result_t urCommandBufferAppendUSMAdviseExp(
617649
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
618650
pSyncPointWaitList, numSyncPointsInWaitList);
619651

652+
wait_list_view waitListView =
653+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
654+
620655
UR_CALL(commandListLocked->appendUSMAdvise(
621-
pMemory, size, advice, numSyncPointsInWaitList, eventsWaitList,
656+
pMemory, size, advice, waitListView,
622657
hCommandBuffer->createEventIfRequested(pSyncPoint)));
623658

624659
return UR_RESULT_SUCCESS;
@@ -667,15 +702,19 @@ ur_result_t urCommandBufferAppendNativeCommandExp(
667702
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
668703
pSyncPointWaitList, numSyncPointsInWaitList);
669704

670-
UR_CALL(commandListLocked->appendEventsWaitWithBarrier(
671-
numSyncPointsInWaitList, eventsWaitList, nullptr));
705+
wait_list_view waitListView =
706+
wait_list_view(eventsWaitList, numSyncPointsInWaitList);
707+
708+
UR_CALL(
709+
commandListLocked->appendEventsWaitWithBarrier(waitListView, nullptr));
672710

673711
// Call user-defined function immediately
674712
pfnNativeCommand(pData);
675713

714+
wait_list_view emptyWaitList = wait_list_view(nullptr, 0);
676715
// Barrier on all commands after user defined commands.
677716
UR_CALL(commandListLocked->appendEventsWaitWithBarrier(
678-
0, nullptr, hCommandBuffer->createEventIfRequested(pSyncPoint)));
717+
emptyWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
679718

680719
return UR_RESULT_SUCCESS;
681720
}

0 commit comments

Comments
 (0)