|
13 | 13 | #include <mutex> |
14 | 14 | #include <string.h> |
15 | 15 |
|
| 16 | +#include "adapters/level_zero/queue.hpp" |
16 | 17 | #include "context.hpp" |
17 | 18 | #include "ur_level_zero.hpp" |
18 | 19 |
|
@@ -596,29 +597,6 @@ ur_context_handle_t_::decrementUnreleasedEventsInPool(ur_event_handle_t Event) { |
596 | 597 | return UR_RESULT_SUCCESS; |
597 | 598 | } |
598 | 599 |
|
599 | | -// Get value of the threshold for number of events in immediate command lists. |
600 | | -// If number of events in the immediate command list exceeds this threshold then |
601 | | -// cleanup process for those events is executed. |
602 | | -static const size_t ImmCmdListsEventCleanupThreshold = [] { |
603 | | - const char *UrRet = |
604 | | - std::getenv("UR_L0_IMMEDIATE_COMMANDLISTS_EVENT_CLEANUP_THRESHOLD"); |
605 | | - const char *PiRet = std::getenv( |
606 | | - "SYCL_PI_LEVEL_ZERO_IMMEDIATE_COMMANDLISTS_EVENT_CLEANUP_THRESHOLD"); |
607 | | - const char *ImmCmdListsEventCleanupThresholdStr = |
608 | | - UrRet ? UrRet : (PiRet ? PiRet : nullptr); |
609 | | - static constexpr int Default = 1000; |
610 | | - if (!ImmCmdListsEventCleanupThresholdStr) |
611 | | - return Default; |
612 | | - |
613 | | - int Threshold = std::atoi(ImmCmdListsEventCleanupThresholdStr); |
614 | | - |
615 | | - // Basically disable threshold if negative value is provided. |
616 | | - if (Threshold < 0) |
617 | | - return INT_MAX; |
618 | | - |
619 | | - return Threshold; |
620 | | -}(); |
621 | | - |
622 | 600 | // Get value of the threshold for number of active command lists allowed before |
623 | 601 | // we start heuristically cleaning them up. |
624 | 602 | static const size_t CmdListsCleanupThreshold = [] { |
@@ -648,8 +626,8 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList( |
648 | 626 | // Immediate commandlists have been pre-allocated and are always available. |
649 | 627 | if (Queue->UsingImmCmdLists) { |
650 | 628 | CommandList = Queue->getQueueGroup(UseCopyEngine).getImmCmdList(); |
651 | | - if (CommandList->second.EventList.size() > |
652 | | - ImmCmdListsEventCleanupThreshold) { |
| 629 | + if (CommandList->second.EventList.size() >= |
| 630 | + Queue->getImmdCmmdListsEventCleanupThreshold()) { |
653 | 631 | std::vector<ur_event_handle_t> EventListToCleanup; |
654 | 632 | Queue->resetCommandList(CommandList, false, EventListToCleanup); |
655 | 633 | CleanupEventListFromResetCmdList(EventListToCleanup, true); |
@@ -743,11 +721,13 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList( |
743 | 721 | ZE2UR_CALL(zeFenceCreate, (ZeCommandQueue, &ZeFenceDesc, &ZeFence)); |
744 | 722 | ZeStruct<ze_command_queue_desc_t> ZeQueueDesc; |
745 | 723 | ZeQueueDesc.ordinal = QueueGroupOrdinal; |
| 724 | + |
746 | 725 | CommandList = |
747 | 726 | Queue->CommandListMap |
748 | 727 | .emplace(ZeCommandList, |
749 | | - ur_command_list_info_t{ZeFence, true, false, |
750 | | - ZeCommandQueue, ZeQueueDesc}) |
| 728 | + ur_command_list_info_t(ZeFence, true, false, |
| 729 | + ZeCommandQueue, ZeQueueDesc, |
| 730 | + Queue->useCompletionBatching())) |
751 | 731 | .first; |
752 | 732 | } |
753 | 733 | ZeCommandListCache.erase(ZeCommandListIt); |
|
0 commit comments