Skip to content

Commit 052bb52

Browse files
authored
Merge pull request #2221 from oneapi-src/revert-2063-refactor_l0_default_init
Revert "[L0] Refactor to remove default constructor inits"
2 parents 65054b9 + fae0c9c commit 052bb52

File tree

10 files changed

+79
-124
lines changed

10 files changed

+79
-124
lines changed

source/adapters/level_zero/command_buffer.cpp

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,8 @@ ur_result_t createSyncPointAndGetZeEvents(
147147
UR_CALL(getEventsFromSyncPoints(CommandBuffer, NumSyncPointsInWaitList,
148148
SyncPointWaitList, ZeEventList));
149149
ur_event_handle_t LaunchEvent;
150-
UR_CALL(EventCreate(CommandBuffer->Context, nullptr /*Queue*/,
151-
false /*IsMultiDevice*/, HostVisible, &LaunchEvent,
152-
false /*CounterBasedEventEnabled*/,
153-
!CommandBuffer->IsProfilingEnabled));
150+
UR_CALL(EventCreate(CommandBuffer->Context, nullptr, false, HostVisible,
151+
&LaunchEvent, false, !CommandBuffer->IsProfilingEnabled));
154152
LaunchEvent->CommandType = CommandType;
155153
ZeLaunchEvent = LaunchEvent->ZeEvent;
156154

@@ -328,26 +326,22 @@ void ur_exp_command_buffer_handle_t_::cleanupCommandBufferResources() {
328326

329327
// Release additional signal and wait events used by command_buffer
330328
if (SignalEvent) {
331-
CleanupCompletedEvent(SignalEvent, false /*QueueLocked*/,
332-
false /*SetEventCompleted*/);
329+
CleanupCompletedEvent(SignalEvent, false);
333330
urEventReleaseInternal(SignalEvent);
334331
}
335332
if (WaitEvent) {
336-
CleanupCompletedEvent(WaitEvent, false /*QueueLocked*/,
337-
false /*SetEventCompleted*/);
333+
CleanupCompletedEvent(WaitEvent, false);
338334
urEventReleaseInternal(WaitEvent);
339335
}
340336
if (AllResetEvent) {
341-
CleanupCompletedEvent(AllResetEvent, false /*QueueLocked*/,
342-
false /*SetEventCompleted*/);
337+
CleanupCompletedEvent(AllResetEvent, false);
343338
urEventReleaseInternal(AllResetEvent);
344339
}
345340

346341
// Release events added to the command_buffer
347342
for (auto &Sync : SyncPoints) {
348343
auto &Event = Sync.second;
349-
CleanupCompletedEvent(Event, false /*QueueLocked*/,
350-
false /*SetEventCompleted*/);
344+
CleanupCompletedEvent(Event, false);
351345
urEventReleaseInternal(Event);
352346
}
353347

@@ -520,15 +514,12 @@ urCommandBufferCreateExp(ur_context_handle_t Context, ur_device_handle_t Device,
520514
ur_event_handle_t WaitEvent;
521515
ur_event_handle_t AllResetEvent;
522516

523-
UR_CALL(EventCreate(Context, nullptr /*Queue*/, false /*IsMultiDevice*/,
524-
false /*HostVisible*/, &SignalEvent,
525-
false /*CounterBasedEventEnabled*/, !EnableProfiling));
526-
UR_CALL(EventCreate(Context, nullptr /*Queue*/, false /*IsMultiDevice*/,
527-
false /*HostVisible*/, &WaitEvent,
528-
false /*CounterBasedEventEnabled*/, !EnableProfiling));
529-
UR_CALL(EventCreate(Context, nullptr /*Queue*/, false /*IsMultiDevice*/,
530-
false /*HostVisible*/, &AllResetEvent,
531-
false /*CounterBasedEventEnabled*/, !EnableProfiling));
517+
UR_CALL(EventCreate(Context, nullptr, false, false, &SignalEvent, false,
518+
!EnableProfiling));
519+
UR_CALL(EventCreate(Context, nullptr, false, false, &WaitEvent, false,
520+
!EnableProfiling));
521+
UR_CALL(EventCreate(Context, nullptr, false, false, &AllResetEvent, false,
522+
!EnableProfiling));
532523
std::vector<ze_event_handle_t> PrecondEvents = {WaitEvent->ZeEvent,
533524
AllResetEvent->ZeEvent};
534525

@@ -1228,15 +1219,14 @@ ur_result_t waitForDependencies(ur_exp_command_buffer_handle_t CommandBuffer,
12281219
// when `EventWaitList` dependencies are complete.
12291220
ur_command_list_ptr_t WaitCommandList{};
12301221
UR_CALL(Queue->Context->getAvailableCommandList(
1231-
Queue, WaitCommandList, false /*UseCopyEngine*/, NumEventsInWaitList,
1232-
EventWaitList, false /*AllowBatching*/, nullptr /*ForcedCmdQueue*/));
1222+
Queue, WaitCommandList, false, NumEventsInWaitList, EventWaitList,
1223+
false));
12331224

12341225
ZE2UR_CALL(zeCommandListAppendBarrier,
12351226
(WaitCommandList->first, CommandBuffer->WaitEvent->ZeEvent,
12361227
CommandBuffer->WaitEvent->WaitList.Length,
12371228
CommandBuffer->WaitEvent->WaitList.ZeEventList));
1238-
Queue->executeCommandList(WaitCommandList, false /*IsBlocking*/,
1239-
false /*OKToBatchCommand*/);
1229+
Queue->executeCommandList(WaitCommandList, false, false);
12401230
MustSignalWaitEvent = false;
12411231
}
12421232
}
@@ -1348,9 +1338,9 @@ urCommandBufferEnqueueExp(ur_exp_command_buffer_handle_t CommandBuffer,
13481338

13491339
// Create a command-list to signal the Event on completion
13501340
ur_command_list_ptr_t SignalCommandList{};
1351-
UR_CALL(Queue->Context->getAvailableCommandList(
1352-
Queue, SignalCommandList, false /*UseCopyEngine*/, NumEventsInWaitList,
1353-
EventWaitList, false /*AllowBatching*/, nullptr /*ForcedCmdQueue*/));
1341+
UR_CALL(Queue->Context->getAvailableCommandList(Queue, SignalCommandList,
1342+
false, NumEventsInWaitList,
1343+
EventWaitList, false));
13541344

13551345
// Reset the wait-event for the UR command-buffer that is signaled when its
13561346
// submission dependencies have been satisfied.
@@ -1365,8 +1355,7 @@ urCommandBufferEnqueueExp(ur_exp_command_buffer_handle_t CommandBuffer,
13651355
// parameter with signal command-list completing.
13661356
UR_CALL(createUserEvent(CommandBuffer, Queue, SignalCommandList, Event));
13671357

1368-
UR_CALL(Queue->executeCommandList(SignalCommandList, false /*IsBlocking*/,
1369-
false /*OKToBatchCommand*/));
1358+
UR_CALL(Queue->executeCommandList(SignalCommandList, false, false));
13701359

13711360
return UR_RESULT_SUCCESS;
13721361
}

source/adapters/level_zero/context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList(
774774
.emplace(ZeCommandList,
775775
ur_command_list_info_t(
776776
ZeFence, true, false, ZeCommandQueue, ZeQueueDesc,
777-
Queue->useCompletionBatching(), true /*CanReuse */,
777+
Queue->useCompletionBatching(), true,
778778
ZeCommandListIt->second.InOrderList,
779779
ZeCommandListIt->second.IsImmediate))
780780
.first;

source/adapters/level_zero/context.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ struct ur_context_handle_t_ : _ur_object {
302302
ur_result_t getAvailableCommandList(
303303
ur_queue_handle_t Queue, ur_command_list_ptr_t &CommandList,
304304
bool UseCopyEngine, uint32_t NumEventsInWaitList,
305-
const ur_event_handle_t *EventWaitList, bool AllowBatching,
306-
ze_command_queue_handle_t *ForcedCmdQueue);
305+
const ur_event_handle_t *EventWaitList, bool AllowBatching = false,
306+
ze_command_queue_handle_t *ForcedCmdQueue = nullptr);
307307

308308
// Checks if Device is covered by this context.
309309
// For that the Device or its root devices need to be in the context.

source/adapters/level_zero/event.cpp

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ ur_result_t urEnqueueEventsWait(
8888
// Get a new command list to be used on this call
8989
ur_command_list_ptr_t CommandList{};
9090
UR_CALL(Queue->Context->getAvailableCommandList(
91-
Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList,
92-
false /*AllowBatching*/, nullptr /*ForceCmdQueue*/));
91+
Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList));
9392

9493
ze_event_handle_t ZeEvent = nullptr;
9594
ur_event_handle_t InternalEvent;
@@ -110,8 +109,7 @@ ur_result_t urEnqueueEventsWait(
110109

111110
// Execute command list asynchronously as the event will be used
112111
// to track down its completion.
113-
return Queue->executeCommandList(CommandList, false /*IsBlocking*/,
114-
false /*OKToBatchCommand*/);
112+
return Queue->executeCommandList(CommandList);
115113
}
116114

117115
{
@@ -281,14 +279,13 @@ ur_result_t urEnqueueEventsWaitWithBarrier(
281279
ur_command_list_ptr_t CmdList;
282280
UR_CALL(Queue->Context->getAvailableCommandList(
283281
Queue, CmdList, false /*UseCopyEngine=*/, NumEventsInWaitList,
284-
EventWaitList, OkToBatch, nullptr /*ForcedCmdQueue*/));
282+
EventWaitList, OkToBatch));
285283

286284
// Insert the barrier into the command-list and execute.
287285
UR_CALL(insertBarrierIntoCmdList(CmdList, TmpWaitList, ResultEvent,
288286
IsInternal));
289287

290-
UR_CALL(
291-
Queue->executeCommandList(CmdList, false /*IsBlocking*/, OkToBatch));
288+
UR_CALL(Queue->executeCommandList(CmdList, false, OkToBatch));
292289

293290
// Because of the dependency between commands in the in-order queue we don't
294291
// need to keep track of any active barriers if we have in-order queue.
@@ -357,7 +354,7 @@ ur_result_t urEnqueueEventsWaitWithBarrier(
357354
ur_command_list_ptr_t CmdList;
358355
UR_CALL(Queue->Context->getAvailableCommandList(
359356
Queue, CmdList, false /*UseCopyEngine=*/, NumEventsInWaitList,
360-
EventWaitList, OkToBatch, nullptr /*ForcedCmdQueue*/));
357+
EventWaitList, OkToBatch));
361358
CmdLists.push_back(CmdList);
362359
}
363360

@@ -407,8 +404,7 @@ ur_result_t urEnqueueEventsWaitWithBarrier(
407404
// Only batch if the matching CmdList is already open.
408405
OkToBatch = CommandBatch.OpenCommandList == CmdList;
409406

410-
UR_CALL(
411-
Queue->executeCommandList(CmdList, false /*IsBlocking*/, OkToBatch));
407+
UR_CALL(Queue->executeCommandList(CmdList, false, OkToBatch));
412408
}
413409

414410
UR_CALL(Queue->ActiveBarriers.clear());
@@ -720,7 +716,7 @@ ur_result_t urEnqueueTimestampRecordingExp(
720716
ur_command_list_ptr_t CommandList{};
721717
UR_CALL(Queue->Context->getAvailableCommandList(
722718
Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList,
723-
/* AllowBatching */ false, nullptr /*ForcedCmdQueue*/));
719+
/* AllowBatching */ false));
724720

725721
UR_CALL(createEventAndAssociateQueue(
726722
Queue, OutEvent, UR_COMMAND_TIMESTAMP_RECORDING_EXP, CommandList,
@@ -744,7 +740,7 @@ ur_result_t urEnqueueTimestampRecordingExp(
744740
(*OutEvent)->WaitList.ZeEventList));
745741

746742
UR_CALL(
747-
Queue->executeCommandList(CommandList, Blocking, false /* OkToBatch */));
743+
Queue->executeCommandList(CommandList, Blocking, /* OkToBatch */ false));
748744

749745
return UR_RESULT_SUCCESS;
750746
}
@@ -820,9 +816,7 @@ urEventWait(uint32_t NumEvents, ///< [in] number of events in the event list
820816
else {
821817
// NOTE: we are cleaning up after the event here to free resources
822818
// sooner in case run-time is not calling urEventRelease soon enough.
823-
CleanupCompletedEvent(reinterpret_cast<ur_event_handle_t>(Event),
824-
false /*QueueLocked*/,
825-
false /*SetEventCompleted*/);
819+
CleanupCompletedEvent(reinterpret_cast<ur_event_handle_t>(Event));
826820
// For the case when we have out-of-order queue or regular command
827821
// lists its more efficient to check fences so put the queue in the
828822
// set to cleanup later.
@@ -890,10 +884,7 @@ ur_result_t urExtEventCreate(
890884
ur_event_handle_t
891885
*Event ///< [out] pointer to the handle of the event object created.
892886
) {
893-
UR_CALL(EventCreate(Context, nullptr /*Queue*/, false /*IsMultiDevice*/,
894-
true /*HostVisible*/, Event,
895-
false /*CounterBasedEventEnabled*/,
896-
false /*ForceDisableProfiling*/));
887+
UR_CALL(EventCreate(Context, nullptr, false, true, Event));
897888

898889
(*Event)->RefCountExternal++;
899890
if (!(*Event)->CounterBasedEventsEnabled)
@@ -912,10 +903,7 @@ ur_result_t urEventCreateWithNativeHandle(
912903
// we dont have urEventCreate, so use this check for now to know that
913904
// the call comes from urEventCreate()
914905
if (reinterpret_cast<ze_event_handle_t>(NativeEvent) == nullptr) {
915-
UR_CALL(EventCreate(Context, nullptr /*Queue*/, false /*IsMultiDevice*/,
916-
true /*HostVisible*/, Event,
917-
false /*CounterBasedEventEnabled*/,
918-
false /*ForceDisableProfiling*/));
906+
UR_CALL(EventCreate(Context, nullptr, false, true, Event));
919907

920908
(*Event)->RefCountExternal++;
921909
if (!(*Event)->CounterBasedEventsEnabled)
@@ -995,8 +983,7 @@ ur_result_t ur_event_handle_t_::getOrCreateHostVisibleEvent(
995983

996984
ur_command_list_ptr_t CommandList{};
997985
UR_CALL(UrQueue->Context->getAvailableCommandList(
998-
UrQueue, CommandList, false /* UseCopyEngine */, 0, nullptr, OkToBatch,
999-
nullptr /*ForcedCmdQueue*/))
986+
UrQueue, CommandList, false /* UseCopyEngine */, 0, nullptr, OkToBatch))
1000987

1001988
// Create a "proxy" host-visible event.
1002989
UR_CALL(createEventAndAssociateQueue(
@@ -1542,8 +1529,7 @@ ur_result_t _ur_ze_event_list_t::createAndRetainUrZeEventList(
15421529
// This prevents a potential deadlock with recursive
15431530
// event locks.
15441531
UR_CALL(Queue->Context->getAvailableCommandList(
1545-
Queue, CommandList, false /*UseCopyEngine*/, 0, nullptr,
1546-
true /*AllowBatching*/, nullptr /*ForcedCmdQueue*/));
1532+
Queue, CommandList, false, 0, nullptr, true));
15471533
}
15481534

15491535
std::shared_lock<ur_shared_mutex> Lock(EventList[I]->Mutex);

source/adapters/level_zero/event.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ ur_result_t urEventReleaseInternal(ur_event_handle_t Event);
3232
ur_result_t EventCreate(ur_context_handle_t Context, ur_queue_handle_t Queue,
3333
bool IsMultiDevice, bool HostVisible,
3434
ur_event_handle_t *RetEvent,
35-
bool CounterBasedEventEnabled,
36-
bool ForceDisableProfiling);
35+
bool CounterBasedEventEnabled = false,
36+
bool ForceDisableProfiling = false);
3737
} // extern "C"
3838

3939
// This is an experimental option that allows to disable caching of events in
@@ -273,8 +273,9 @@ template <> ze_result_t zeHostSynchronize(ze_command_queue_handle_t Handle);
273273
// the event, updates the last command event in the queue and cleans up all dep
274274
// events of the event.
275275
// If the caller locks queue mutex then it must pass 'true' to QueueLocked.
276-
ur_result_t CleanupCompletedEvent(ur_event_handle_t Event, bool QueueLocked,
277-
bool SetEventCompleted);
276+
ur_result_t CleanupCompletedEvent(ur_event_handle_t Event,
277+
bool QueueLocked = false,
278+
bool SetEventCompleted = false);
278279

279280
// Get value of device scope events env var setting or default setting
280281
static const EventsScope DeviceEventsSetting = [] {

source/adapters/level_zero/image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ ur_result_t urBindlessImagesImageCopyExp(
856856
ur_command_list_ptr_t CommandList{};
857857
UR_CALL(hQueue->Context->getAvailableCommandList(
858858
hQueue, CommandList, UseCopyEngine, numEventsInWaitList, phEventWaitList,
859-
OkToBatch, nullptr /*ForcedCmdQueue*/));
859+
OkToBatch));
860860

861861
ze_event_handle_t ZeEvent = nullptr;
862862
ur_event_handle_t InternalEvent;

source/adapters/level_zero/kernel.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ ur_result_t urEnqueueKernelLaunch(
139139
ur_command_list_ptr_t CommandList{};
140140
UR_CALL(Queue->Context->getAvailableCommandList(
141141
Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList,
142-
true /* AllowBatching */, nullptr /*ForcedCmdQueue*/));
142+
true /* AllowBatching */));
143143

144144
ze_event_handle_t ZeEvent = nullptr;
145145
ur_event_handle_t InternalEvent{};
@@ -202,8 +202,7 @@ ur_result_t urEnqueueKernelLaunch(
202202

203203
// Execute command list asynchronously, as the event will be used
204204
// to track down its completion.
205-
UR_CALL(Queue->executeCommandList(CommandList, false /*IsBlocking*/,
206-
true /*OKToBatchCommand*/));
205+
UR_CALL(Queue->executeCommandList(CommandList, false, true));
207206

208207
return UR_RESULT_SUCCESS;
209208
}
@@ -405,7 +404,7 @@ ur_result_t urEnqueueCooperativeKernelLaunchExp(
405404
ur_command_list_ptr_t CommandList{};
406405
UR_CALL(Queue->Context->getAvailableCommandList(
407406
Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList,
408-
true /* AllowBatching */, nullptr /*ForcedCmdQueue*/));
407+
true /* AllowBatching */));
409408

410409
ze_event_handle_t ZeEvent = nullptr;
411410
ur_event_handle_t InternalEvent{};
@@ -468,8 +467,7 @@ ur_result_t urEnqueueCooperativeKernelLaunchExp(
468467

469468
// Execute command list asynchronously, as the event will be used
470469
// to track down its completion.
471-
UR_CALL(Queue->executeCommandList(CommandList, false /*IsBlocking*/,
472-
true /*OKToBatchCommand*/));
470+
UR_CALL(Queue->executeCommandList(CommandList, false, true));
473471

474472
return UR_RESULT_SUCCESS;
475473
}

0 commit comments

Comments
 (0)