Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion unified-runtime/scripts/templates/queue_api.hpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ from templates import helper as th
#pragma once

#include <ur_api.h>
#include "queue_extensions.hpp"

struct ur_queue_t_ {
struct ur_queue_t_ : ur_queue_extensions {
virtual ~ur_queue_t_();

%for obj in th.get_queue_related_functions(specs, n, tags):
Expand Down
2 changes: 2 additions & 0 deletions unified-runtime/source/adapters/level_zero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ if(UR_BUILD_ADAPTER_L0_V2)
${CMAKE_CURRENT_SOURCE_DIR}/v2/memory.hpp
${CMAKE_CURRENT_SOURCE_DIR}/v2/lockable.hpp
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_api.hpp
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_batched.hpp
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_in_order.hpp
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_out_of_order.hpp
${CMAKE_CURRENT_SOURCE_DIR}/v2/usm.hpp
Expand All @@ -187,6 +188,7 @@ if(UR_BUILD_ADAPTER_L0_V2)
${CMAKE_CURRENT_SOURCE_DIR}/v2/kernel.cpp
${CMAKE_CURRENT_SOURCE_DIR}/v2/memory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_api.cpp
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_batched.cpp
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_create.cpp
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_in_order.cpp
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_out_of_order.cpp
Expand Down
85 changes: 62 additions & 23 deletions unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "../command_buffer_command.hpp"
#include "../helpers/kernel_helpers.hpp"
#include "../ur_interface_loader.hpp"
#include "command_list_manager.hpp"
#include "logger/ur_logger.hpp"
#include "queue_handle.hpp"

Expand Down Expand Up @@ -323,9 +324,12 @@ ur_result_t urCommandBufferAppendKernelLaunchExp(
auto eventsWaitList = commandBuffer->getWaitListFromSyncPoints(
syncPointWaitList, numSyncPointsInWaitList);

wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendKernelLaunch(
hKernel, workDim, pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize, 0,
nullptr, numSyncPointsInWaitList, eventsWaitList,
nullptr, waitListView,
commandBuffer->createEventIfRequested(retSyncPoint)));

return UR_RESULT_SUCCESS;
Expand All @@ -348,8 +352,11 @@ ur_result_t urCommandBufferAppendUSMMemcpyExp(
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
pSyncPointWaitList, numSyncPointsInWaitList);

wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendUSMMemcpy(
false, pDst, pSrc, size, numSyncPointsInWaitList, eventsWaitList,
false, pDst, pSrc, size, waitListView,
hCommandBuffer->createEventIfRequested(pSyncPoint)));

return UR_RESULT_SUCCESS;
Expand All @@ -375,9 +382,12 @@ ur_result_t urCommandBufferAppendMemBufferCopyExp(
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
pSyncPointWaitList, numSyncPointsInWaitList);

wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendMemBufferCopy(
hSrcMem, hDstMem, srcOffset, dstOffset, size, numSyncPointsInWaitList,
eventsWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
hSrcMem, hDstMem, srcOffset, dstOffset, size, waitListView,
hCommandBuffer->createEventIfRequested(pSyncPoint)));

return UR_RESULT_SUCCESS;
} catch (...) {
Expand All @@ -402,9 +412,12 @@ ur_result_t urCommandBufferAppendMemBufferWriteExp(
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
pSyncPointWaitList, numSyncPointsInWaitList);

wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendMemBufferWrite(
hBuffer, false, offset, size, pSrc, numSyncPointsInWaitList,
eventsWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
hBuffer, false, offset, size, pSrc, waitListView,
hCommandBuffer->createEventIfRequested(pSyncPoint)));

return UR_RESULT_SUCCESS;
} catch (...) {
Expand All @@ -427,9 +440,12 @@ ur_result_t urCommandBufferAppendMemBufferReadExp(
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
pSyncPointWaitList, numSyncPointsInWaitList);

wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendMemBufferRead(
hBuffer, false, offset, size, pDst, numSyncPointsInWaitList,
eventsWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
hBuffer, false, offset, size, pDst, waitListView,
hCommandBuffer->createEventIfRequested(pSyncPoint)));

return UR_RESULT_SUCCESS;
} catch (...) {
Expand All @@ -456,10 +472,13 @@ ur_result_t urCommandBufferAppendMemBufferCopyRectExp(
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
pSyncPointWaitList, numSyncPointsInWaitList);

wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendMemBufferCopyRect(
hSrcMem, hDstMem, srcOrigin, dstOrigin, region, srcRowPitch,
srcSlicePitch, dstRowPitch, dstSlicePitch, numSyncPointsInWaitList,
eventsWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
srcSlicePitch, dstRowPitch, dstSlicePitch, waitListView,
hCommandBuffer->createEventIfRequested(pSyncPoint)));

return UR_RESULT_SUCCESS;
} catch (...) {
Expand All @@ -486,10 +505,12 @@ ur_result_t urCommandBufferAppendMemBufferWriteRectExp(
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
pSyncPointWaitList, numSyncPointsInWaitList);

wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendMemBufferWriteRect(
hBuffer, false, bufferOffset, hostOffset, region, bufferRowPitch,
bufferSlicePitch, hostRowPitch, hostSlicePitch, pSrc,
numSyncPointsInWaitList, eventsWaitList,
bufferSlicePitch, hostRowPitch, hostSlicePitch, pSrc, waitListView,
hCommandBuffer->createEventIfRequested(pSyncPoint)));

return UR_RESULT_SUCCESS;
Expand Down Expand Up @@ -517,10 +538,12 @@ ur_result_t urCommandBufferAppendMemBufferReadRectExp(
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
pSyncPointWaitList, numSyncPointsInWaitList);

wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendMemBufferReadRect(
hBuffer, false, bufferOffset, hostOffset, region, bufferRowPitch,
bufferSlicePitch, hostRowPitch, hostSlicePitch, pDst,
numSyncPointsInWaitList, eventsWaitList,
bufferSlicePitch, hostRowPitch, hostSlicePitch, pDst, waitListView,
hCommandBuffer->createEventIfRequested(pSyncPoint)));

return UR_RESULT_SUCCESS;
Expand All @@ -543,9 +566,12 @@ ur_result_t urCommandBufferAppendUSMFillExp(
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
pSyncPointWaitList, numSyncPointsInWaitList);

wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendUSMFill(
pMemory, patternSize, pPattern, size, numSyncPointsInWaitList,
eventsWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
pMemory, patternSize, pPattern, size, waitListView,
hCommandBuffer->createEventIfRequested(pSyncPoint)));
return UR_RESULT_SUCCESS;
} catch (...) {
return exceptionToResult(std::current_exception());
Expand All @@ -567,9 +593,12 @@ ur_result_t urCommandBufferAppendMemBufferFillExp(
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
pSyncPointWaitList, numSyncPointsInWaitList);

wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendMemBufferFill(
hBuffer, pPattern, patternSize, offset, size, numSyncPointsInWaitList,
eventsWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));
hBuffer, pPattern, patternSize, offset, size, waitListView,
hCommandBuffer->createEventIfRequested(pSyncPoint)));

return UR_RESULT_SUCCESS;
} catch (...) {
Expand All @@ -593,8 +622,11 @@ ur_result_t urCommandBufferAppendUSMPrefetchExp(
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
pSyncPointWaitList, numSyncPointsInWaitList);

wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendUSMPrefetch(
pMemory, size, flags, numSyncPointsInWaitList, eventsWaitList,
pMemory, size, flags, waitListView,
hCommandBuffer->createEventIfRequested(pSyncPoint)));

return UR_RESULT_SUCCESS;
Expand All @@ -617,8 +649,11 @@ ur_result_t urCommandBufferAppendUSMAdviseExp(
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
pSyncPointWaitList, numSyncPointsInWaitList);

wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendUSMAdvise(
pMemory, size, advice, numSyncPointsInWaitList, eventsWaitList,
pMemory, size, advice, waitListView,
hCommandBuffer->createEventIfRequested(pSyncPoint)));

return UR_RESULT_SUCCESS;
Expand Down Expand Up @@ -667,15 +702,19 @@ ur_result_t urCommandBufferAppendNativeCommandExp(
auto eventsWaitList = hCommandBuffer->getWaitListFromSyncPoints(
pSyncPointWaitList, numSyncPointsInWaitList);

UR_CALL(commandListLocked->appendEventsWaitWithBarrier(
numSyncPointsInWaitList, eventsWaitList, nullptr));
wait_list_view waitListView =
wait_list_view(eventsWaitList, numSyncPointsInWaitList);

UR_CALL(
commandListLocked->appendEventsWaitWithBarrier(waitListView, nullptr));

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

wait_list_view emptyWaitList = wait_list_view(nullptr, 0);
// Barrier on all commands after user defined commands.
UR_CALL(commandListLocked->appendEventsWaitWithBarrier(
0, nullptr, hCommandBuffer->createEventIfRequested(pSyncPoint)));
emptyWaitList, hCommandBuffer->createEventIfRequested(pSyncPoint)));

return UR_RESULT_SUCCESS;
}
Expand Down
Loading
Loading