@@ -74,7 +74,12 @@ ur_queue_batched_t::ur_queue_batched_t(
7474
7575ur_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 (), ®ularList);
119+ enqueueCurrentBatchUnlocked (batchLocked->immediateList .getZeCommandList (),
120+ ®ularList);
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 (), ®ularCmdlist);
194+ queueFinishBatchAndPoolsUnlocked (
195+ lockedBatches->immediateList .getZeCommandList (), ®ularCmdlist);
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));
0 commit comments