Skip to content

Commit c55074e

Browse files
fix event creation on request
1 parent c694b3a commit c55074e

File tree

4 files changed

+48
-29
lines changed

4 files changed

+48
-29
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ ur_result_t ur_command_list_manager::appendGenericFillUnlocked(
6363
return UR_RESULT_SUCCESS;
6464
}
6565

66-
v2::raii::command_list_unique_handle&& ur_command_list_manager::releaseCommandList() {
66+
v2::raii::command_list_unique_handle &&
67+
ur_command_list_manager::releaseCommandList() {
6768
return std::move(zeCommandList);
6869
}
6970

70-
void ur_command_list_manager::replaceCommandList(v2::raii::command_list_unique_handle &&cmdlist) {
71+
void ur_command_list_manager::replaceCommandList(
72+
v2::raii::command_list_unique_handle &&cmdlist) {
7173
zeCommandList = std::move(cmdlist);
7274
}
7375

74-
75-
7676
ur_result_t ur_command_list_manager::appendGenericCopyUnlocked(
7777
ur_mem_buffer_t *src, ur_mem_buffer_t *dst, bool blocking, size_t srcOffset,
7878
size_t dstOffset, size_t size, uint32_t numEventsInWaitList,

unified-runtime/source/adapters/level_zero/v2/command_list_manager.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ struct ur_command_list_manager {
233233

234234
ur_result_t appendRegular(ze_command_list_handle_t *phCommandLists);
235235

236-
v2::raii::command_list_unique_handle&& releaseCommandList();
236+
v2::raii::command_list_unique_handle &&releaseCommandList();
237237

238-
void replaceCommandList(v2::raii::command_list_unique_handle&& cmdlist);
238+
void replaceCommandList(v2::raii::command_list_unique_handle &&cmdlist);
239239

240240
private:
241241
ur_result_t appendGenericCommandListsExp(

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

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ ur_queue_batched_t::ur_queue_batched_t(
7474

7575
ur_event_handle_t ur_queue_batched_t::createEventIfRequestedRegular(
7676
ur_event_handle_t *phEvent, ur_event_generation_t batch_generation) {
77-
(*phEvent) = createEventIfRequested(eventPoolRegular.get(), phEvent, this);
77+
if (phEvent == nullptr) {
78+
return nullptr;
79+
}
80+
81+
(*phEvent) = eventPoolRegular->allocate();
82+
(*phEvent)->setQueue(this);
7883
(*phEvent)->setBatch(batch_generation);
7984

8085
return (*phEvent);
@@ -86,13 +91,16 @@ locked<Batch> ur_queue_batched_t::renewRegular(locked<Batch> batchLocked) {
8691
// TODO replace with unlocked functions
8792
// save regular for execution
8893
// renew regular
89-
runBatches.push_back( batchLocked->regularBatch.releaseCommandList()); //std::move(batchLocked->regularBatch));
90-
batchLocked->regularBatch.replaceCommandList(getNewRegularCmdList());
94+
runBatches.push_back(
95+
batchLocked->regularBatch
96+
.releaseCommandList()); // std::move(batchLocked->regularBatch));
97+
batchLocked->regularBatch.replaceCommandList(getNewRegularCmdList());
9198

9299
return batchLocked;
93100
}
94101

95-
ur_result_t enqueueCurrentBatchUnlocked(ze_command_list_handle_t immediateList, ze_command_list_handle_t* regularList) {
102+
ur_result_t enqueueCurrentBatchUnlocked(ze_command_list_handle_t immediateList,
103+
ze_command_list_handle_t *regularList) {
96104
// finalize
97105
ZE2UR_CALL(zeCommandListClose, (*regularList));
98106
// run batch
@@ -108,7 +116,8 @@ ur_result_t ur_queue_batched_t::runBatchIfCurrentBatch(
108116

109117
if (batch_generation == batchLocked->generation) {
110118
auto regularList = batchLocked->regularBatch.getZeCommandList();
111-
enqueueCurrentBatchUnlocked(batchLocked->immediateList.getZeCommandList(), &regularList);
119+
enqueueCurrentBatchUnlocked(batchLocked->immediateList.getZeCommandList(),
120+
&regularList);
112121
// auto cmdlist = batchLocked->regularBatch.getZeCommandList();
113122

114123
// // no syncpoints to synchronize
@@ -125,11 +134,13 @@ ur_result_t ur_queue_batched_t::runBatchIfCurrentBatch(
125134
// TODO std::optional
126135
// save regular for execution
127136
// renew regular
128-
runBatches.push_back( batchLocked->regularBatch.releaseCommandList()); //std::move(batchLocked->regularBatch));
129-
batchLocked->regularBatch.replaceCommandList(getNewRegularCmdList());
130-
137+
runBatches.push_back(
138+
batchLocked->regularBatch
139+
.releaseCommandList()); // std::move(batchLocked->regularBatch));
140+
batchLocked->regularBatch.replaceCommandList(getNewRegularCmdList());
141+
131142
// =
132-
// ur_command_list_manager(hContext, hDevice, getNewRegularCmdList());
143+
// ur_command_list_manager(hContext, hDevice, getNewRegularCmdList());
133144

134145
return UR_RESULT_SUCCESS;
135146
}
@@ -154,18 +165,19 @@ ur_result_t ur_queue_batched_t::enqueueKernelLaunch(
154165
return UR_RESULT_SUCCESS;
155166
}
156167

157-
ur_result_t ur_queue_batched_t::queueFinishBatchAndPoolsUnlocked(ze_command_list_handle_t immediateList, ze_command_list_handle_t* regularList) {
168+
ur_result_t ur_queue_batched_t::queueFinishBatchAndPoolsUnlocked(
169+
ze_command_list_handle_t immediateList,
170+
ze_command_list_handle_t *regularList) {
158171
enqueueCurrentBatchUnlocked(immediateList, regularList);
159172

160173
// finish queue
161-
ZE2UR_CALL(zeCommandListHostSynchronize,
162-
(immediateList, UINT64_MAX));
174+
ZE2UR_CALL(zeCommandListHostSynchronize, (immediateList, UINT64_MAX));
163175

164-
hContext->getAsyncPool()->cleanupPoolsForQueue(this);
165-
hContext->forEachUsmPool([this](ur_usm_pool_handle_t hPool) {
166-
hPool->cleanupPoolsForQueue(this);
167-
return true;
168-
});
176+
hContext->getAsyncPool()->cleanupPoolsForQueue(this);
177+
hContext->forEachUsmPool([this](ur_usm_pool_handle_t hPool) {
178+
hPool->cleanupPoolsForQueue(this);
179+
return true;
180+
});
169181

170182
return UR_RESULT_SUCCESS;
171183
}
@@ -179,7 +191,8 @@ ur_result_t ur_queue_batched_t::queueFinish() {
179191
ze_command_list_handle_t regularCmdlist =
180192
lockedBatches->regularBatch.getZeCommandList();
181193

182-
queueFinishBatchAndPoolsUnlocked(lockedBatches->immediateList.getZeCommandList(), &regularCmdlist);
194+
queueFinishBatchAndPoolsUnlocked(
195+
lockedBatches->immediateList.getZeCommandList(), &regularCmdlist);
183196
// finalize
184197
// ZE2UR_CALL(zeCommandListClose, (cmdlist));
185198

@@ -188,7 +201,8 @@ ur_result_t ur_queue_batched_t::queueFinish() {
188201

189202
// // finish queue
190203
// ZE2UR_CALL(zeCommandListHostSynchronize,
191-
// (lockedBatches->immediateList.getZeCommandList(), UINT64_MAX));
204+
// (lockedBatches->immediateList.getZeCommandList(),
205+
// UINT64_MAX));
192206

193207
// hContext->getAsyncPool()->cleanupPoolsForQueue(this);
194208
// hContext->forEachUsmPool([this](ur_usm_pool_handle_t hPool) {
@@ -199,8 +213,10 @@ ur_result_t ur_queue_batched_t::queueFinish() {
199213
UR_CALL(lockedBatches->immediateList.releaseSubmittedKernels());
200214

201215
// renew regular
202-
runBatches.push_back( lockedBatches->regularBatch.releaseCommandList()); //std::move(batchLocked->regularBatch));
203-
lockedBatches->regularBatch.replaceCommandList(getNewRegularCmdList());
216+
runBatches.push_back(
217+
lockedBatches->regularBatch
218+
.releaseCommandList()); // std::move(batchLocked->regularBatch));
219+
lockedBatches->regularBatch.replaceCommandList(getNewRegularCmdList());
204220

205221
// // TODO removingf double lock but looks like trash - change to unlocked
206222
// lockedBatches = renewRegular(std::move(lockedBatches));

unified-runtime/source/adapters/level_zero/v2/queue_batched.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ struct ur_queue_batched_t : ur_object, ur_queue_t_ {
7878
createEventIfRequestedRegular(ur_event_handle_t *phEvent,
7979
ur_event_generation_t generation_number);
8080

81-
// ur_result_t enqueueCurrentBatch(ze_command_list_handle_t immediateList, ze_command_list_handle_t regularList);
82-
ur_result_t queueFinishBatchAndPoolsUnlocked(ze_command_list_handle_t immediateList, ze_command_list_handle_t* regularList);
81+
// ur_result_t enqueueCurrentBatch(ze_command_list_handle_t immediateList,
82+
// ze_command_list_handle_t regularList);
83+
ur_result_t
84+
queueFinishBatchAndPoolsUnlocked(ze_command_list_handle_t immediateList,
85+
ze_command_list_handle_t *regularList);
8386

8487
public:
8588
ur_queue_batched_t(ur_context_handle_t, ur_device_handle_t, uint32_t ordinal,

0 commit comments

Comments
 (0)