|
1 | 1 | //===--------- queue_immediate_in_order.cpp - Level Zero Adapter ---------===// |
2 | 2 | // |
3 | | -// Copyright (C) 2024 Intel Corporation |
| 3 | +// Copyright (C) 2025 Intel Corporation |
4 | 4 | // |
5 | 5 | // Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM |
6 | 6 | // Exceptions. See LICENSE.TXT |
|
14 | 14 |
|
15 | 15 | namespace v2 { |
16 | 16 |
|
17 | | -// Helper function to intialize std::array of command list manager. |
18 | | -// This is needed because command list manager does not have a default |
19 | | -// constructor. |
20 | | -template <size_t... Is> |
21 | | -std::array<ur_command_list_manager, sizeof...(Is)> createCommandListManagers( |
22 | | - ur_context_handle_t hContext, ur_device_handle_t hDevice, uint32_t ordinal, |
23 | | - ze_command_queue_priority_t priority, std::index_sequence<Is...>) { |
24 | | - return { |
25 | | - ((void)Is, ur_command_list_manager( |
26 | | - hContext, hDevice, |
27 | | - hContext->getCommandListCache().getImmediateCommandList( |
28 | | - hDevice->ZeDevice, |
29 | | - {true, ordinal, true /* always enable copy offload */}, |
30 | | - ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, priority)))...}; |
31 | | -} |
32 | | - |
33 | 17 | template <size_t N> |
34 | | -std::array<ur_command_list_manager, N> |
35 | | -createCommandListManagers(ur_context_handle_t hContext, |
36 | | - ur_device_handle_t hDevice, uint32_t ordinal, |
37 | | - ze_command_queue_priority_t priority) { |
38 | | - return createCommandListManagers(hContext, hDevice, ordinal, priority, |
39 | | - std::make_index_sequence<N>{}); |
| 18 | +std::array<ur_command_list_manager, N> createCommandListManagers( |
| 19 | + ur_context_handle_t hContext, ur_device_handle_t hDevice, uint32_t ordinal, |
| 20 | + ze_command_queue_priority_t priority, std::optional<int32_t> index) { |
| 21 | + return createArrayOf<ur_command_list_manager, numCommandLists>([&](size_t) { |
| 22 | + return ur_command_list_manager( |
| 23 | + hContext, hDevice, |
| 24 | + hContext->getCommandListCache().getImmediateCommandList( |
| 25 | + hDevice->ZeDevice, |
| 26 | + {true, ordinal, true /* always enable copy offload */}, |
| 27 | + ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS, priority, index)); |
| 28 | + }); |
40 | 29 | } |
41 | 30 |
|
42 | 31 | ur_queue_immediate_out_of_order_t::ur_queue_immediate_out_of_order_t( |
43 | 32 | ur_context_handle_t hContext, ur_device_handle_t hDevice, uint32_t ordinal, |
44 | | - ze_command_queue_priority_t priority, event_flags_t eventFlags, |
45 | | - ur_queue_flags_t flags) |
| 33 | + ze_command_queue_priority_t priority, std::optional<int32_t> index, |
| 34 | + event_flags_t eventFlags, ur_queue_flags_t flags) |
46 | 35 | : hContext(hContext), hDevice(hDevice), |
47 | 36 | eventPool(hContext->getEventPoolCache(PoolCacheType::Immediate) |
48 | 37 | .borrow(hDevice->Id.value(), eventFlags)), |
49 | 38 | commandListManagers(createCommandListManagers<numCommandLists>( |
50 | | - hContext, hDevice, ordinal, priority)), |
| 39 | + hContext, hDevice, ordinal, priority, index)), |
51 | 40 | flags(flags) { |
52 | 41 | for (size_t i = 0; i < numCommandLists; i++) { |
53 | 42 | barrierEvents[i] = eventPool->allocate(); |
@@ -153,11 +142,11 @@ ur_result_t ur_queue_immediate_out_of_order_t::enqueueEventsWaitWithBarrier( |
153 | 142 | ur_event_handle_t *phEvent) { |
154 | 143 | TRACK_SCOPE_LATENCY( |
155 | 144 | "ur_queue_immediate_out_of_order_t::enqueueEventsWaitWithBarrier"); |
156 | | - // For in-order queue we don't need a real L0 barrier, just wait for |
157 | | - // requested events in potentially different queues and add a "barrier" |
158 | | - // event signal because it is already guaranteed that previous commands |
159 | | - // in this queue are completed when the signal is started. However, we do |
160 | | - // need to use barrier if profiling is enabled: see |
| 145 | + // Since we use L0 in-order command lists, we don't need a real L0 barrier, |
| 146 | + // just wait for requested events in potentially different queues and add a |
| 147 | + // "barrier" event signal because it is already guaranteed that previous |
| 148 | + // commands in this queue are completed when the signal is started. However, |
| 149 | + // we do need to use barrier if profiling is enabled: see |
161 | 150 | // zeCommandListAppendWaitOnEvents |
162 | 151 | bool needsRealBarrier = (flags & UR_QUEUE_FLAG_PROFILING_ENABLE) != 0; |
163 | 152 | auto appendEventsWaitFn = |
|
0 commit comments