diff --git a/source/adapters/level_zero/command_buffer.cpp b/source/adapters/level_zero/command_buffer.cpp index 43e13c3419..d12f2db777 100644 --- a/source/adapters/level_zero/command_buffer.cpp +++ b/source/adapters/level_zero/command_buffer.cpp @@ -147,10 +147,8 @@ ur_result_t createSyncPointAndGetZeEvents( UR_CALL(getEventsFromSyncPoints(CommandBuffer, NumSyncPointsInWaitList, SyncPointWaitList, ZeEventList)); ur_event_handle_t LaunchEvent; - UR_CALL(EventCreate(CommandBuffer->Context, nullptr /*Queue*/, - false /*IsMultiDevice*/, HostVisible, &LaunchEvent, - false /*CounterBasedEventEnabled*/, - !CommandBuffer->IsProfilingEnabled)); + UR_CALL(EventCreate(CommandBuffer->Context, nullptr, false, HostVisible, + &LaunchEvent, false, !CommandBuffer->IsProfilingEnabled)); LaunchEvent->CommandType = CommandType; ZeLaunchEvent = LaunchEvent->ZeEvent; @@ -328,26 +326,22 @@ void ur_exp_command_buffer_handle_t_::cleanupCommandBufferResources() { // Release additional signal and wait events used by command_buffer if (SignalEvent) { - CleanupCompletedEvent(SignalEvent, false /*QueueLocked*/, - false /*SetEventCompleted*/); + CleanupCompletedEvent(SignalEvent, false); urEventReleaseInternal(SignalEvent); } if (WaitEvent) { - CleanupCompletedEvent(WaitEvent, false /*QueueLocked*/, - false /*SetEventCompleted*/); + CleanupCompletedEvent(WaitEvent, false); urEventReleaseInternal(WaitEvent); } if (AllResetEvent) { - CleanupCompletedEvent(AllResetEvent, false /*QueueLocked*/, - false /*SetEventCompleted*/); + CleanupCompletedEvent(AllResetEvent, false); urEventReleaseInternal(AllResetEvent); } // Release events added to the command_buffer for (auto &Sync : SyncPoints) { auto &Event = Sync.second; - CleanupCompletedEvent(Event, false /*QueueLocked*/, - false /*SetEventCompleted*/); + CleanupCompletedEvent(Event, false); urEventReleaseInternal(Event); } @@ -520,15 +514,12 @@ urCommandBufferCreateExp(ur_context_handle_t Context, ur_device_handle_t Device, ur_event_handle_t WaitEvent; ur_event_handle_t AllResetEvent; - UR_CALL(EventCreate(Context, nullptr /*Queue*/, false /*IsMultiDevice*/, - false /*HostVisible*/, &SignalEvent, - false /*CounterBasedEventEnabled*/, !EnableProfiling)); - UR_CALL(EventCreate(Context, nullptr /*Queue*/, false /*IsMultiDevice*/, - false /*HostVisible*/, &WaitEvent, - false /*CounterBasedEventEnabled*/, !EnableProfiling)); - UR_CALL(EventCreate(Context, nullptr /*Queue*/, false /*IsMultiDevice*/, - false /*HostVisible*/, &AllResetEvent, - false /*CounterBasedEventEnabled*/, !EnableProfiling)); + UR_CALL(EventCreate(Context, nullptr, false, false, &SignalEvent, false, + !EnableProfiling)); + UR_CALL(EventCreate(Context, nullptr, false, false, &WaitEvent, false, + !EnableProfiling)); + UR_CALL(EventCreate(Context, nullptr, false, false, &AllResetEvent, false, + !EnableProfiling)); std::vector PrecondEvents = {WaitEvent->ZeEvent, AllResetEvent->ZeEvent}; @@ -1228,15 +1219,14 @@ ur_result_t waitForDependencies(ur_exp_command_buffer_handle_t CommandBuffer, // when `EventWaitList` dependencies are complete. ur_command_list_ptr_t WaitCommandList{}; UR_CALL(Queue->Context->getAvailableCommandList( - Queue, WaitCommandList, false /*UseCopyEngine*/, NumEventsInWaitList, - EventWaitList, false /*AllowBatching*/, nullptr /*ForcedCmdQueue*/)); + Queue, WaitCommandList, false, NumEventsInWaitList, EventWaitList, + false)); ZE2UR_CALL(zeCommandListAppendBarrier, (WaitCommandList->first, CommandBuffer->WaitEvent->ZeEvent, CommandBuffer->WaitEvent->WaitList.Length, CommandBuffer->WaitEvent->WaitList.ZeEventList)); - Queue->executeCommandList(WaitCommandList, false /*IsBlocking*/, - false /*OKToBatchCommand*/); + Queue->executeCommandList(WaitCommandList, false, false); MustSignalWaitEvent = false; } } @@ -1348,9 +1338,9 @@ urCommandBufferEnqueueExp(ur_exp_command_buffer_handle_t CommandBuffer, // Create a command-list to signal the Event on completion ur_command_list_ptr_t SignalCommandList{}; - UR_CALL(Queue->Context->getAvailableCommandList( - Queue, SignalCommandList, false /*UseCopyEngine*/, NumEventsInWaitList, - EventWaitList, false /*AllowBatching*/, nullptr /*ForcedCmdQueue*/)); + UR_CALL(Queue->Context->getAvailableCommandList(Queue, SignalCommandList, + false, NumEventsInWaitList, + EventWaitList, false)); // Reset the wait-event for the UR command-buffer that is signaled when its // submission dependencies have been satisfied. @@ -1365,8 +1355,7 @@ urCommandBufferEnqueueExp(ur_exp_command_buffer_handle_t CommandBuffer, // parameter with signal command-list completing. UR_CALL(createUserEvent(CommandBuffer, Queue, SignalCommandList, Event)); - UR_CALL(Queue->executeCommandList(SignalCommandList, false /*IsBlocking*/, - false /*OKToBatchCommand*/)); + UR_CALL(Queue->executeCommandList(SignalCommandList, false, false)); return UR_RESULT_SUCCESS; } diff --git a/source/adapters/level_zero/context.cpp b/source/adapters/level_zero/context.cpp index 41c7593237..296e3e98d5 100644 --- a/source/adapters/level_zero/context.cpp +++ b/source/adapters/level_zero/context.cpp @@ -774,7 +774,7 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList( .emplace(ZeCommandList, ur_command_list_info_t( ZeFence, true, false, ZeCommandQueue, ZeQueueDesc, - Queue->useCompletionBatching(), true /*CanReuse */, + Queue->useCompletionBatching(), true, ZeCommandListIt->second.InOrderList, ZeCommandListIt->second.IsImmediate)) .first; diff --git a/source/adapters/level_zero/context.hpp b/source/adapters/level_zero/context.hpp index 0d3b2846e2..e7c0d784a0 100644 --- a/source/adapters/level_zero/context.hpp +++ b/source/adapters/level_zero/context.hpp @@ -302,8 +302,8 @@ struct ur_context_handle_t_ : _ur_object { ur_result_t getAvailableCommandList( ur_queue_handle_t Queue, ur_command_list_ptr_t &CommandList, bool UseCopyEngine, uint32_t NumEventsInWaitList, - const ur_event_handle_t *EventWaitList, bool AllowBatching, - ze_command_queue_handle_t *ForcedCmdQueue); + const ur_event_handle_t *EventWaitList, bool AllowBatching = false, + ze_command_queue_handle_t *ForcedCmdQueue = nullptr); // Checks if Device is covered by this context. // For that the Device or its root devices need to be in the context. diff --git a/source/adapters/level_zero/event.cpp b/source/adapters/level_zero/event.cpp index 408580dd80..2bd3011b4b 100644 --- a/source/adapters/level_zero/event.cpp +++ b/source/adapters/level_zero/event.cpp @@ -88,8 +88,7 @@ ur_result_t urEnqueueEventsWait( // Get a new command list to be used on this call ur_command_list_ptr_t CommandList{}; UR_CALL(Queue->Context->getAvailableCommandList( - Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList, - false /*AllowBatching*/, nullptr /*ForceCmdQueue*/)); + Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList)); ze_event_handle_t ZeEvent = nullptr; ur_event_handle_t InternalEvent; @@ -110,8 +109,7 @@ ur_result_t urEnqueueEventsWait( // Execute command list asynchronously as the event will be used // to track down its completion. - return Queue->executeCommandList(CommandList, false /*IsBlocking*/, - false /*OKToBatchCommand*/); + return Queue->executeCommandList(CommandList); } { @@ -281,14 +279,13 @@ ur_result_t urEnqueueEventsWaitWithBarrier( ur_command_list_ptr_t CmdList; UR_CALL(Queue->Context->getAvailableCommandList( Queue, CmdList, false /*UseCopyEngine=*/, NumEventsInWaitList, - EventWaitList, OkToBatch, nullptr /*ForcedCmdQueue*/)); + EventWaitList, OkToBatch)); // Insert the barrier into the command-list and execute. UR_CALL(insertBarrierIntoCmdList(CmdList, TmpWaitList, ResultEvent, IsInternal)); - UR_CALL( - Queue->executeCommandList(CmdList, false /*IsBlocking*/, OkToBatch)); + UR_CALL(Queue->executeCommandList(CmdList, false, OkToBatch)); // Because of the dependency between commands in the in-order queue we don't // need to keep track of any active barriers if we have in-order queue. @@ -357,7 +354,7 @@ ur_result_t urEnqueueEventsWaitWithBarrier( ur_command_list_ptr_t CmdList; UR_CALL(Queue->Context->getAvailableCommandList( Queue, CmdList, false /*UseCopyEngine=*/, NumEventsInWaitList, - EventWaitList, OkToBatch, nullptr /*ForcedCmdQueue*/)); + EventWaitList, OkToBatch)); CmdLists.push_back(CmdList); } @@ -407,8 +404,7 @@ ur_result_t urEnqueueEventsWaitWithBarrier( // Only batch if the matching CmdList is already open. OkToBatch = CommandBatch.OpenCommandList == CmdList; - UR_CALL( - Queue->executeCommandList(CmdList, false /*IsBlocking*/, OkToBatch)); + UR_CALL(Queue->executeCommandList(CmdList, false, OkToBatch)); } UR_CALL(Queue->ActiveBarriers.clear()); @@ -720,7 +716,7 @@ ur_result_t urEnqueueTimestampRecordingExp( ur_command_list_ptr_t CommandList{}; UR_CALL(Queue->Context->getAvailableCommandList( Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList, - /* AllowBatching */ false, nullptr /*ForcedCmdQueue*/)); + /* AllowBatching */ false)); UR_CALL(createEventAndAssociateQueue( Queue, OutEvent, UR_COMMAND_TIMESTAMP_RECORDING_EXP, CommandList, @@ -744,7 +740,7 @@ ur_result_t urEnqueueTimestampRecordingExp( (*OutEvent)->WaitList.ZeEventList)); UR_CALL( - Queue->executeCommandList(CommandList, Blocking, false /* OkToBatch */)); + Queue->executeCommandList(CommandList, Blocking, /* OkToBatch */ false)); return UR_RESULT_SUCCESS; } @@ -820,9 +816,7 @@ urEventWait(uint32_t NumEvents, ///< [in] number of events in the event list else { // NOTE: we are cleaning up after the event here to free resources // sooner in case run-time is not calling urEventRelease soon enough. - CleanupCompletedEvent(reinterpret_cast(Event), - false /*QueueLocked*/, - false /*SetEventCompleted*/); + CleanupCompletedEvent(reinterpret_cast(Event)); // For the case when we have out-of-order queue or regular command // lists its more efficient to check fences so put the queue in the // set to cleanup later. @@ -890,10 +884,7 @@ ur_result_t urExtEventCreate( ur_event_handle_t *Event ///< [out] pointer to the handle of the event object created. ) { - UR_CALL(EventCreate(Context, nullptr /*Queue*/, false /*IsMultiDevice*/, - true /*HostVisible*/, Event, - false /*CounterBasedEventEnabled*/, - false /*ForceDisableProfiling*/)); + UR_CALL(EventCreate(Context, nullptr, false, true, Event)); (*Event)->RefCountExternal++; if (!(*Event)->CounterBasedEventsEnabled) @@ -912,10 +903,7 @@ ur_result_t urEventCreateWithNativeHandle( // we dont have urEventCreate, so use this check for now to know that // the call comes from urEventCreate() if (reinterpret_cast(NativeEvent) == nullptr) { - UR_CALL(EventCreate(Context, nullptr /*Queue*/, false /*IsMultiDevice*/, - true /*HostVisible*/, Event, - false /*CounterBasedEventEnabled*/, - false /*ForceDisableProfiling*/)); + UR_CALL(EventCreate(Context, nullptr, false, true, Event)); (*Event)->RefCountExternal++; if (!(*Event)->CounterBasedEventsEnabled) @@ -995,8 +983,7 @@ ur_result_t ur_event_handle_t_::getOrCreateHostVisibleEvent( ur_command_list_ptr_t CommandList{}; UR_CALL(UrQueue->Context->getAvailableCommandList( - UrQueue, CommandList, false /* UseCopyEngine */, 0, nullptr, OkToBatch, - nullptr /*ForcedCmdQueue*/)) + UrQueue, CommandList, false /* UseCopyEngine */, 0, nullptr, OkToBatch)) // Create a "proxy" host-visible event. UR_CALL(createEventAndAssociateQueue( @@ -1542,8 +1529,7 @@ ur_result_t _ur_ze_event_list_t::createAndRetainUrZeEventList( // This prevents a potential deadlock with recursive // event locks. UR_CALL(Queue->Context->getAvailableCommandList( - Queue, CommandList, false /*UseCopyEngine*/, 0, nullptr, - true /*AllowBatching*/, nullptr /*ForcedCmdQueue*/)); + Queue, CommandList, false, 0, nullptr, true)); } std::shared_lock Lock(EventList[I]->Mutex); diff --git a/source/adapters/level_zero/event.hpp b/source/adapters/level_zero/event.hpp index 2c9e698e3c..7dd64acdaa 100644 --- a/source/adapters/level_zero/event.hpp +++ b/source/adapters/level_zero/event.hpp @@ -32,8 +32,8 @@ ur_result_t urEventReleaseInternal(ur_event_handle_t Event); ur_result_t EventCreate(ur_context_handle_t Context, ur_queue_handle_t Queue, bool IsMultiDevice, bool HostVisible, ur_event_handle_t *RetEvent, - bool CounterBasedEventEnabled, - bool ForceDisableProfiling); + bool CounterBasedEventEnabled = false, + bool ForceDisableProfiling = false); } // extern "C" // 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); // the event, updates the last command event in the queue and cleans up all dep // events of the event. // If the caller locks queue mutex then it must pass 'true' to QueueLocked. -ur_result_t CleanupCompletedEvent(ur_event_handle_t Event, bool QueueLocked, - bool SetEventCompleted); +ur_result_t CleanupCompletedEvent(ur_event_handle_t Event, + bool QueueLocked = false, + bool SetEventCompleted = false); // Get value of device scope events env var setting or default setting static const EventsScope DeviceEventsSetting = [] { diff --git a/source/adapters/level_zero/image.cpp b/source/adapters/level_zero/image.cpp index 6433b1f325..4810b3d88e 100644 --- a/source/adapters/level_zero/image.cpp +++ b/source/adapters/level_zero/image.cpp @@ -856,7 +856,7 @@ ur_result_t urBindlessImagesImageCopyExp( ur_command_list_ptr_t CommandList{}; UR_CALL(hQueue->Context->getAvailableCommandList( hQueue, CommandList, UseCopyEngine, numEventsInWaitList, phEventWaitList, - OkToBatch, nullptr /*ForcedCmdQueue*/)); + OkToBatch)); ze_event_handle_t ZeEvent = nullptr; ur_event_handle_t InternalEvent; diff --git a/source/adapters/level_zero/kernel.cpp b/source/adapters/level_zero/kernel.cpp index a34782cbae..c77bb22b8c 100644 --- a/source/adapters/level_zero/kernel.cpp +++ b/source/adapters/level_zero/kernel.cpp @@ -139,7 +139,7 @@ ur_result_t urEnqueueKernelLaunch( ur_command_list_ptr_t CommandList{}; UR_CALL(Queue->Context->getAvailableCommandList( Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList, - true /* AllowBatching */, nullptr /*ForcedCmdQueue*/)); + true /* AllowBatching */)); ze_event_handle_t ZeEvent = nullptr; ur_event_handle_t InternalEvent{}; @@ -202,8 +202,7 @@ ur_result_t urEnqueueKernelLaunch( // Execute command list asynchronously, as the event will be used // to track down its completion. - UR_CALL(Queue->executeCommandList(CommandList, false /*IsBlocking*/, - true /*OKToBatchCommand*/)); + UR_CALL(Queue->executeCommandList(CommandList, false, true)); return UR_RESULT_SUCCESS; } @@ -405,7 +404,7 @@ ur_result_t urEnqueueCooperativeKernelLaunchExp( ur_command_list_ptr_t CommandList{}; UR_CALL(Queue->Context->getAvailableCommandList( Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList, - true /* AllowBatching */, nullptr /*ForcedCmdQueue*/)); + true /* AllowBatching */)); ze_event_handle_t ZeEvent = nullptr; ur_event_handle_t InternalEvent{}; @@ -468,8 +467,7 @@ ur_result_t urEnqueueCooperativeKernelLaunchExp( // Execute command list asynchronously, as the event will be used // to track down its completion. - UR_CALL(Queue->executeCommandList(CommandList, false /*IsBlocking*/, - true /*OKToBatchCommand*/)); + UR_CALL(Queue->executeCommandList(CommandList, false, true)); return UR_RESULT_SUCCESS; } diff --git a/source/adapters/level_zero/memory.cpp b/source/adapters/level_zero/memory.cpp index 62b1de8591..e7ff6dfea1 100644 --- a/source/adapters/level_zero/memory.cpp +++ b/source/adapters/level_zero/memory.cpp @@ -80,7 +80,7 @@ ur_result_t enqueueMemCopyHelper(ur_command_t CommandType, ur_command_list_ptr_t CommandList{}; UR_CALL(Queue->Context->getAvailableCommandList( Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList, - OkToBatch, nullptr /*ForcedCmdQueue*/)); + OkToBatch)); ze_event_handle_t ZeEvent = nullptr; ur_event_handle_t InternalEvent; @@ -133,7 +133,7 @@ ur_result_t enqueueMemCopyRectHelper( ur_command_list_ptr_t CommandList{}; UR_CALL(Queue->Context->getAvailableCommandList( Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList, - OkToBatch, nullptr /*ForcedCmdQueue*/)); + OkToBatch)); ze_event_handle_t ZeEvent = nullptr; ur_event_handle_t InternalEvent; @@ -215,7 +215,7 @@ static ur_result_t enqueueMemFillHelper(ur_command_t CommandType, bool OkToBatch = true; UR_CALL(Queue->Context->getAvailableCommandList( Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList, - OkToBatch, nullptr /*ForcedCmdQueue*/)); + OkToBatch)); ze_event_handle_t ZeEvent = nullptr; ur_event_handle_t InternalEvent; @@ -245,8 +245,7 @@ static ur_result_t enqueueMemFillHelper(ur_command_t CommandType, // Execute command list asynchronously, as the event will be used // to track down its completion. - UR_CALL(Queue->executeCommandList(CommandList, false /*IsBlocking*/, - OkToBatch)); + UR_CALL(Queue->executeCommandList(CommandList, false, OkToBatch)); } else { // Copy pattern into every entry in memory array pointed by Ptr. uint32_t NumOfCopySteps = Size / PatternSize; @@ -266,8 +265,7 @@ static ur_result_t enqueueMemFillHelper(ur_command_t CommandType, printZeEventList(WaitList); // Execute command list synchronously. - UR_CALL( - Queue->executeCommandList(CommandList, true /*IsBlocking*/, OkToBatch)); + UR_CALL(Queue->executeCommandList(CommandList, true, OkToBatch)); } return UR_RESULT_SUCCESS; @@ -334,7 +332,7 @@ static ur_result_t enqueueMemImageCommandHelper( ur_command_list_ptr_t CommandList{}; UR_CALL(Queue->Context->getAvailableCommandList( Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList, - OkToBatch, nullptr /*ForcedCmdQueue*/)); + OkToBatch)); ze_event_handle_t ZeEvent = nullptr; ur_event_handle_t InternalEvent; @@ -1008,8 +1006,7 @@ ur_result_t urEnqueueMemBufferMap( // For discrete devices we need a command list ur_command_list_ptr_t CommandList{}; UR_CALL(Queue->Context->getAvailableCommandList( - Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList, - false /*AllowBatching*/, nullptr /*ForcedCmdQueue*/)); + Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList)); // Add the event to the command list. CommandList->second.append(reinterpret_cast(*Event)); @@ -1030,8 +1027,7 @@ ur_result_t urEnqueueMemBufferMap( (ZeCommandList, *RetMap, ZeHandleSrc + Offset, Size, ZeEvent, WaitList.Length, WaitList.ZeEventList)); - UR_CALL(Queue->executeCommandList(CommandList, BlockingMap, - false /*OKToBatchCommand*/)); + UR_CALL(Queue->executeCommandList(CommandList, BlockingMap)); } auto Res = Buffer->Mappings.insert({*RetMap, {Offset, Size}}); @@ -1139,8 +1135,7 @@ ur_result_t urEnqueueMemUnmap( ur_command_list_ptr_t CommandList{}; UR_CALL(Queue->Context->getAvailableCommandList( reinterpret_cast(Queue), CommandList, UseCopyEngine, - NumEventsInWaitList, EventWaitList, false /*AllowBatching*/, - nullptr /*ForcedCmdQueue*/)); + NumEventsInWaitList, EventWaitList)); CommandList->second.append(reinterpret_cast(*Event)); (*Event)->RefCount.increment(); @@ -1169,8 +1164,7 @@ ur_result_t urEnqueueMemUnmap( // Execute command list asynchronously, as the event will be used // to track down its completion. - UR_CALL(Queue->executeCommandList(CommandList, false /*IsBlocking*/, - false /*OKToBatchCommand*/)); + UR_CALL(Queue->executeCommandList(CommandList)); return UR_RESULT_SUCCESS; } @@ -1252,8 +1246,7 @@ ur_result_t urEnqueueUSMPrefetch( // TODO: Change UseCopyEngine argument to 'true' once L0 backend // support is added UR_CALL(Queue->Context->getAvailableCommandList( - Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList, - false /*AllowBatching*/, nullptr /*ForcedCmdQueue*/)); + Queue, CommandList, UseCopyEngine, NumEventsInWaitList, EventWaitList)); // TODO: do we need to create a unique command type for this? ze_event_handle_t ZeEvent = nullptr; @@ -1278,8 +1271,7 @@ ur_result_t urEnqueueUSMPrefetch( // so manually add command to signal our event. ZE2UR_CALL(zeCommandListAppendSignalEvent, (ZeCommandList, ZeEvent)); - UR_CALL(Queue->executeCommandList(CommandList, false /*IsBlocking*/, - false /*OKToBatchCommand*/)); + UR_CALL(Queue->executeCommandList(CommandList, false)); return UR_RESULT_SUCCESS; } @@ -1309,9 +1301,8 @@ ur_result_t urEnqueueUSMAdvise( // UseCopyEngine is set to 'false' here. // TODO: Additional analysis is required to check if this operation will // run faster on copy engines. - UR_CALL(Queue->Context->getAvailableCommandList( - Queue, CommandList, UseCopyEngine, 0, nullptr, false /*AllowBatching*/, - nullptr /*ForcedCmdQueue*/)); + UR_CALL(Queue->Context->getAvailableCommandList(Queue, CommandList, + UseCopyEngine, 0, nullptr)); // TODO: do we need to create a unique command type for this? ze_event_handle_t ZeEvent = nullptr; @@ -1338,8 +1329,7 @@ ur_result_t urEnqueueUSMAdvise( // so manually add command to signal our event. ZE2UR_CALL(zeCommandListAppendSignalEvent, (ZeCommandList, ZeEvent)); - Queue->executeCommandList(CommandList, false /*IsBlocking*/, - false /*OKToBatchCommand*/); + Queue->executeCommandList(CommandList, false); return UR_RESULT_SUCCESS; } diff --git a/source/adapters/level_zero/queue.cpp b/source/adapters/level_zero/queue.cpp index c4598f3472..978547df10 100644 --- a/source/adapters/level_zero/queue.cpp +++ b/source/adapters/level_zero/queue.cpp @@ -104,10 +104,7 @@ ur_result_t ur_completion_batch::seal(ur_queue_handle_t queue, assert(st == ACCUMULATING); if (!barrierEvent) { - UR_CALL(EventCreate(queue->Context, queue, false /*IsMultiDevice*/, - true /*HostVisible*/, &barrierEvent, - false /*CounterBasedEventEnabled*/, - false /*ForceDisableProfiling*/)); + UR_CALL(EventCreate(queue->Context, queue, false, true, &barrierEvent)); } // Instead of collecting all the batched events, we simply issue a global @@ -310,9 +307,7 @@ ur_result_t resetCommandLists(ur_queue_handle_t Queue) { // Handle immediate command lists here, they don't need to be reset and we // only need to cleanup events. if (Queue->UsingImmCmdLists) { - UR_CALL(CleanupEventsInImmCmdLists(Queue, true /*QueueLocked*/, - false /*QueueSynced*/, - nullptr /*CompletedEvent*/)); + UR_CALL(CleanupEventsInImmCmdLists(Queue, true /*locked*/)); return UR_RESULT_SUCCESS; } @@ -687,8 +682,7 @@ ur_result_t urQueueRelease( std::scoped_lock EventLock(Event->Mutex); Event->Completed = true; } - UR_CALL(CleanupCompletedEvent(Event, false /*QueueLocked*/, - false /*SetEventCompleted*/)); + UR_CALL(CleanupCompletedEvent(Event)); // This event was removed from the command list, so decrement ref count // (it was incremented when they were added to the command list). UR_CALL(urEventReleaseInternal(reinterpret_cast(Event))); @@ -1661,8 +1655,7 @@ ur_result_t CleanupEventListFromResetCmdList( for (auto &Event : EventListToCleanup) { // We don't need to synchronize the events since the fence associated with // the command list was synchronized. - UR_CALL( - CleanupCompletedEvent(Event, QueueLocked, true /*SetEventCompleted*/)); + UR_CALL(CleanupCompletedEvent(Event, QueueLocked, true)); // This event was removed from the command list, so decrement ref count // (it was incremented when they were added to the command list). UR_CALL(urEventReleaseInternal(Event)); @@ -1886,9 +1879,9 @@ ur_result_t createEventAndAssociateQueue(ur_queue_handle_t Queue, : nullptr; if (*Event == nullptr) - UR_CALL(EventCreate( - Queue->Context, Queue, IsMultiDevice, HostVisible.value(), Event, - Queue->CounterBasedEventsEnabled, false /*ForceDisableProfiling*/)); + UR_CALL(EventCreate(Queue->Context, Queue, IsMultiDevice, + HostVisible.value(), Event, + Queue->CounterBasedEventsEnabled)); (*Event)->UrQueue = Queue; (*Event)->CommandType = CommandType; @@ -1985,9 +1978,7 @@ ur_result_t ur_queue_handle_t_::executeOpenCommandList(bool IsCopy) { // queue, then close and execute that command list now. if (hasOpenCommandList(IsCopy)) { adjustBatchSizeForPartialBatch(IsCopy); - auto Res = - executeCommandList(CommandBatch.OpenCommandList, false /*IsBlocking*/, - false /*OKToBatchCommand*/); + auto Res = executeCommandList(CommandBatch.OpenCommandList, false, false); CommandBatch.OpenCommandList = CommandListMap.end(); return Res; } @@ -2297,11 +2288,9 @@ ur_result_t ur_queue_handle_t_::createCommandList( std::tie(CommandList, std::ignore) = CommandListMap.insert( std::pair( - ZeCommandList, - ur_command_list_info_t( - ZeFence, false /*ZeFenceInUse*/, false /*IsClosed*/, - ZeCommandQueue, ZeQueueDesc, useCompletionBatching(), - true /*CanReuse*/, IsInOrderList, false /*IsImmediate*/))); + ZeCommandList, ur_command_list_info_t( + ZeFence, false, false, ZeCommandQueue, ZeQueueDesc, + useCompletionBatching(), true, IsInOrderList))); UR_CALL(insertStartBarrierIfDiscardEventsMode(CommandList)); UR_CALL(insertActiveBarriers(CommandList, UseCopyEngine)); diff --git a/source/adapters/level_zero/queue.hpp b/source/adapters/level_zero/queue.hpp index 1108e4c268..699d7ec960 100644 --- a/source/adapters/level_zero/queue.hpp +++ b/source/adapters/level_zero/queue.hpp @@ -150,9 +150,10 @@ struct ur_completion_batches { }; ur_result_t resetCommandLists(ur_queue_handle_t Queue); -ur_result_t CleanupEventsInImmCmdLists(ur_queue_handle_t UrQueue, - bool QueueLocked, bool QueueSynced, - ur_event_handle_t CompletedEvent); +ur_result_t +CleanupEventsInImmCmdLists(ur_queue_handle_t UrQueue, bool QueueLocked = false, + bool QueueSynced = false, + ur_event_handle_t CompletedEvent = nullptr); // Structure describing the specific use of a command-list in a queue. // This is because command-lists are re-used across multiple queues @@ -161,8 +162,8 @@ struct ur_command_list_info_t { ur_command_list_info_t(ze_fence_handle_t ZeFence, bool ZeFenceInUse, bool IsClosed, ze_command_queue_handle_t ZeQueue, ZeStruct ZeQueueDesc, - bool UseCompletionBatching, bool CanReuse, - bool IsInOrderList, bool IsImmediate) + bool UseCompletionBatching, bool CanReuse = true, + bool IsInOrderList = false, bool IsImmediate = false) : ZeFence(ZeFence), ZeFenceInUse(ZeFenceInUse), IsClosed(IsClosed), ZeQueue(ZeQueue), ZeQueueDesc(ZeQueueDesc), IsInOrderList(IsInOrderList), CanReuse(CanReuse), @@ -527,7 +528,8 @@ struct ur_queue_handle_t_ : _ur_object { // // For immediate commandlists, no close and execute is necessary. ur_result_t executeCommandList(ur_command_list_ptr_t CommandList, - bool IsBlocking, bool OKToBatchCommand); + bool IsBlocking = false, + bool OKToBatchCommand = false); // Helper method telling whether we need to reuse discarded event in this // queue.