@@ -47,26 +47,37 @@ namespace {
4747// This is an experimental option to test performance of device to device copy
4848// operations on copy engines (versus compute engine)
4949static const bool UseCopyEngineForD2DCopy = [] {
50- const char *CopyEngineForD2DCopy =
50+ const char *UrRet = std::getenv (" UR_L0_USE_COPY_ENGINE_FOR_D2D_COPY" );
51+ const char *PiRet =
5152 std::getenv (" SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_D2D_COPY" );
53+ const char *CopyEngineForD2DCopy = UrRet ? UrRet : (PiRet ? PiRet : nullptr );
54+
5255 return (CopyEngineForD2DCopy && (std::stoi (CopyEngineForD2DCopy) != 0 ));
5356}();
5457
5558// This is an experimental option that allows the use of copy engine, if
5659// available in the device, in Level Zero plugin for copy operations submitted
5760// to an in-order queue. The default is 1.
5861static const bool UseCopyEngineForInOrderQueue = [] {
59- const char *CopyEngineForInOrderQueue =
62+ const char *UrRet = std::getenv (" UR_L0_USE_COPY_ENGINE_FOR_IN_ORDER_QUEUE" );
63+ const char *PiRet =
6064 std::getenv (" SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_IN_ORDER_QUEUE" );
65+ const char *CopyEngineForInOrderQueue =
66+ UrRet ? UrRet : (PiRet ? PiRet : nullptr );
67+
6168 return (!CopyEngineForInOrderQueue ||
6269 (std::stoi (CopyEngineForInOrderQueue) != 0 ));
6370}();
6471
6572// This is an experimental option that allows the use of multiple command lists
6673// when submitting barriers. The default is 0.
6774static const bool UseMultipleCmdlistBarriers = [] {
68- const char *UseMultipleCmdlistBarriersFlag =
75+ const char *UrRet = std::getenv (" UR_L0_USE_MULTIPLE_COMMANDLIST_BARRIERS" );
76+ const char *PiRet =
6977 std::getenv (" SYCL_PI_LEVEL_ZERO_USE_MULTIPLE_COMMANDLIST_BARRIERS" );
78+ const char *UseMultipleCmdlistBarriersFlag =
79+ UrRet ? UrRet : (PiRet ? PiRet : nullptr );
80+
7081 if (!UseMultipleCmdlistBarriersFlag)
7182 return true ;
7283 return std::stoi (UseMultipleCmdlistBarriersFlag) > 0 ;
@@ -75,8 +86,11 @@ static const bool UseMultipleCmdlistBarriers = [] {
7586// This is an experimental option that allows to disable caching of events in
7687// the context.
7788static const bool DisableEventsCaching = [] {
89+ const char *UrRet = std::getenv (" UR_L0_DISABLE_EVENTS_CACHING" );
90+ const char *PiRet = std::getenv (" SYCL_PI_LEVEL_ZERO_DISABLE_EVENTS_CACHING" );
7891 const char *DisableEventsCachingFlag =
79- std::getenv (" SYCL_PI_LEVEL_ZERO_DISABLE_EVENTS_CACHING" );
92+ UrRet ? UrRet : (PiRet ? PiRet : nullptr );
93+
8094 if (!DisableEventsCachingFlag)
8195 return false ;
8296 return std::stoi (DisableEventsCachingFlag) != 0 ;
@@ -85,8 +99,11 @@ static const bool DisableEventsCaching = [] {
8599// This is an experimental option that allows reset and reuse of uncompleted
86100// events in the in-order queue with discard_events property.
87101static const bool ReuseDiscardedEvents = [] {
102+ const char *UrRet = std::getenv (" UR_L0_REUSE_DISCARDED_EVENTS" );
103+ const char *PiRet = std::getenv (" SYCL_PI_LEVEL_ZERO_REUSE_DISCARDED_EVENTS" );
88104 const char *ReuseDiscardedEventsFlag =
89- std::getenv (" SYCL_PI_LEVEL_ZERO_REUSE_DISCARDED_EVENTS" );
105+ UrRet ? UrRet : (PiRet ? PiRet : nullptr );
106+
90107 if (!ReuseDiscardedEventsFlag)
91108 return true ;
92109 return std::stoi (ReuseDiscardedEventsFlag) > 0 ;
@@ -95,8 +112,11 @@ static const bool ReuseDiscardedEvents = [] {
95112// Due to a bug with 2D memory copy to and from non-USM pointers, this option is
96113// disabled by default.
97114static const bool UseMemcpy2DOperations = [] {
115+ const char *UrRet = std::getenv (" UR_L0_USE_NATIVE_USM_MEMCPY2D" );
116+ const char *PiRet = std::getenv (" SYCL_PI_LEVEL_ZERO_USE_NATIVE_USM_MEMCPY2D" );
98117 const char *UseMemcpy2DOperationsFlag =
99- std::getenv (" SYCL_PI_LEVEL_ZERO_USE_NATIVE_USM_MEMCPY2D" );
118+ UrRet ? UrRet : (PiRet ? PiRet : nullptr );
119+
100120 if (!UseMemcpy2DOperationsFlag)
101121 return false ;
102122 return std::stoi (UseMemcpy2DOperationsFlag) > 0 ;
@@ -130,16 +150,21 @@ static inline pi_result mapError(ze_result_t Result) {
130150// paths be less likely affected.
131151//
132152static bool doEagerInit = [] {
133- const char *EagerInit = std::getenv (" SYCL_EAGER_INIT" );
153+ const char *UrRet = std::getenv (" UR_L0_EAGER_INIT" );
154+ const char *PiRet = std::getenv (" SYCL_EAGER_INIT" );
155+ const char *EagerInit = UrRet ? UrRet : (PiRet ? PiRet : nullptr );
134156 return EagerInit ? std::atoi (EagerInit) != 0 : false ;
135157}();
136158
137159// Maximum number of events that can be present in an event ZePool is captured
138160// here. Setting it to 256 gave best possible performance for several
139161// benchmarks.
140162static const pi_uint32 MaxNumEventsPerPool = [] {
141- const auto MaxNumEventsPerPoolEnv =
142- std::getenv (" ZE_MAX_NUMBER_OF_EVENTS_PER_EVENT_POOL" );
163+ const char *UrRet = std::getenv (" UR_L0_MAX_NUMBER_OF_EVENTS_PER_EVENT_POOL" );
164+ const char *PiRet = std::getenv (" ZE_MAX_NUMBER_OF_EVENTS_PER_EVENT_POOL" );
165+ const char *MaxNumEventsPerPoolEnv =
166+ UrRet ? UrRet : (PiRet ? PiRet : nullptr );
167+
143168 pi_uint32 Result =
144169 MaxNumEventsPerPoolEnv ? std::atoi (MaxNumEventsPerPoolEnv) : 256 ;
145170 if (Result <= 0 )
@@ -177,16 +202,18 @@ template <> ze_result_t zeHostSynchronize(ze_command_queue_handle_t Handle) {
177202
178203} // anonymous namespace
179204
180- // SYCL_PI_LEVEL_ZERO_USE_COMPUTE_ENGINE can be set to an integer (>=0) in
205+ // UR_L0_LEVEL_ZERO_USE_COMPUTE_ENGINE can be set to an integer (>=0) in
181206// which case all compute commands will be submitted to the command-queue
182207// with the given index in the compute command group. If it is instead set
183208// to negative then all available compute engines may be used.
184209//
185210// The default value is "0".
186211//
187212static const std::pair<int , int > getRangeOfAllowedComputeEngines () {
188- static const char *EnvVar =
189- std::getenv (" SYCL_PI_LEVEL_ZERO_USE_COMPUTE_ENGINE" );
213+ const char *UrRet = std::getenv (" UR_L0_USE_COMPUTE_ENGINE" );
214+ const char *PiRet = std::getenv (" SYCL_PI_LEVEL_ZERO_USE_COMPUTE_ENGINE" );
215+ const char *EnvVar = UrRet ? UrRet : (PiRet ? PiRet : nullptr );
216+
190217 // If the environment variable is not set only use "0" CCS for now.
191218 // TODO: allow all CCSs when HW support is complete.
192219 if (!EnvVar)
@@ -466,8 +493,13 @@ pi_result _pi_queue::addEventToQueueCache(pi_event Event) {
466493// If number of events in the immediate command list exceeds this threshold then
467494// cleanup process for those events is executed.
468495static const size_t ImmCmdListsEventCleanupThreshold = [] {
469- const char *ImmCmdListsEventCleanupThresholdStr = std::getenv (
496+ const char *UrRet =
497+ std::getenv (" UR_L0_IMMEDIATE_COMMANDLISTS_EVENT_CLEANUP_THRESHOLD" );
498+ const char *PiRet = std::getenv (
470499 " SYCL_PI_LEVEL_ZERO_IMMEDIATE_COMMANDLISTS_EVENT_CLEANUP_THRESHOLD" );
500+ const char *ImmCmdListsEventCleanupThresholdStr =
501+ UrRet ? UrRet : (PiRet ? PiRet : nullptr );
502+
471503 static constexpr int Default = 1000 ;
472504 if (!ImmCmdListsEventCleanupThresholdStr)
473505 return Default;
@@ -484,8 +516,12 @@ static const size_t ImmCmdListsEventCleanupThreshold = [] {
484516// Get value of the threshold for number of active command lists allowed before
485517// we start heuristically cleaning them up.
486518static const size_t CmdListsCleanupThreshold = [] {
487- const char *CmdListsCleanupThresholdStr =
519+ const char *UrRet = std::getenv (" UR_L0_COMMANDLISTS_CLEANUP_THRESHOLD" );
520+ const char *PiRet =
488521 std::getenv (" SYCL_PI_LEVEL_ZERO_COMMANDLISTS_CLEANUP_THRESHOLD" );
522+ const char *CmdListsCleanupThresholdStr =
523+ UrRet ? UrRet : (PiRet ? PiRet : nullptr );
524+
489525 static constexpr int Default = 20 ;
490526 if (!CmdListsCleanupThresholdStr)
491527 return Default;
@@ -826,9 +862,17 @@ static const zeCommandListBatchConfig ZeCommandListBatchConfig(bool IsCopy) {
826862 zeCommandListBatchConfig Config{}; // default initialize
827863
828864 // Default value of 0. This specifies to use dynamic batch size adjustment.
829- const auto BatchSizeStr =
830- (IsCopy) ? std::getenv (" SYCL_PI_LEVEL_ZERO_COPY_BATCH_SIZE" )
831- : std::getenv (" SYCL_PI_LEVEL_ZERO_BATCH_SIZE" );
865+ const char *UrRet = nullptr ;
866+ const char *PiRet = nullptr ;
867+ if (IsCopy) {
868+ UrRet = std::getenv (" UR_L0_COPY_BATCH_SIZE" );
869+ PiRet = std::getenv (" SYCL_PI_LEVEL_ZERO_COPY_BATCH_SIZE" );
870+ } else {
871+ UrRet = std::getenv (" UR_L0_BATCH_SIZE" );
872+ PiRet = std::getenv (" SYCL_PI_LEVEL_ZERO_BATCH_SIZE" );
873+ }
874+ const char *BatchSizeStr = UrRet ? UrRet : (PiRet ? PiRet : nullptr );
875+
832876 if (BatchSizeStr) {
833877 pi_int32 BatchSizeStrVal = std::atoi (BatchSizeStr);
834878 // Level Zero may only support a limted number of commands per command
@@ -861,10 +905,9 @@ static const zeCommandListBatchConfig ZeCommandListBatchConfig(bool IsCopy) {
861905 Val = std::stoi (BatchConfig.substr (Pos));
862906 } catch (...) {
863907 if (IsCopy)
864- urPrint (
865- " SYCL_PI_LEVEL_ZERO_COPY_BATCH_SIZE: failed to parse value\n " );
908+ urPrint (" UR_L0_COPY_BATCH_SIZE: failed to parse value\n " );
866909 else
867- urPrint (" SYCL_PI_LEVEL_ZERO_BATCH_SIZE : failed to parse value\n " );
910+ urPrint (" UR_L0_BATCH_SIZE : failed to parse value\n " );
868911 break ;
869912 }
870913 switch (Ord) {
@@ -887,21 +930,20 @@ static const zeCommandListBatchConfig ZeCommandListBatchConfig(bool IsCopy) {
887930 die (" Unexpected batch config" );
888931 }
889932 if (IsCopy)
890- urPrint (" SYCL_PI_LEVEL_ZERO_COPY_BATCH_SIZE : dynamic batch param "
933+ urPrint (" UR_L0_COPY_BATCH_SIZE : dynamic batch param "
891934 " #%d: %d\n " ,
892935 (int )Ord, (int )Val);
893936 else
894- urPrint (
895- " SYCL_PI_LEVEL_ZERO_BATCH_SIZE: dynamic batch param #%d: %d\n " ,
896- (int )Ord, (int )Val);
937+ urPrint (" UR_L0_BATCH_SIZE: dynamic batch param #%d: %d\n " , (int )Ord,
938+ (int )Val);
897939 };
898940
899941 } else {
900942 // Negative batch sizes are silently ignored.
901943 if (IsCopy)
902- urPrint (" SYCL_PI_LEVEL_ZERO_COPY_BATCH_SIZE : ignored negative value\n " );
944+ urPrint (" UR_L0_COPY_BATCH_SIZE : ignored negative value\n " );
903945 else
904- urPrint (" SYCL_PI_LEVEL_ZERO_BATCH_SIZE : ignored negative value\n " );
946+ urPrint (" UR_L0_BATCH_SIZE : ignored negative value\n " );
905947 }
906948 }
907949 return Config;
@@ -922,7 +964,10 @@ static const zeCommandListBatchConfig ZeCommandListBatchCopyConfig = [] {
922964// Temporarily check whether immediate command list env var has been set. This
923965// affects default behavior of make_queue API.
924966static const bool ImmediateCommandlistEnvVarIsSet = [] {
925- return std::getenv (" SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS" );
967+ const char *UrRet = std::getenv (" UR_L0_USE_IMMEDIATE_COMMANDLISTS" );
968+ const char *PiRet =
969+ std::getenv (" SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS" );
970+ return (UrRet ? std::stoi (UrRet) : (PiRet ? std::stoi (PiRet) : 0 ));
926971}();
927972
928973_pi_queue::_pi_queue (std::vector<ze_command_queue_handle_t > &ComputeQueues,
@@ -1893,9 +1938,9 @@ pi_result _pi_queue::executeOpenCommandList(bool IsCopy) {
18931938}
18941939
18951940static const bool FilterEventWaitList = [] {
1896- const char *Ret = std::getenv (" SYCL_PI_LEVEL_ZERO_FILTER_EVENT_WAIT_LIST " );
1897- const bool RetVal = Ret ? std::stoi (Ret) : 0 ;
1898- return RetVal ;
1941+ const char *UrRet = std::getenv (" UR_L0_FILTER_EVENT_WAIT_LIST " );
1942+ const char *PiRet = std::getenv ( " SYCL_PI_LEVEL_ZERO_FILTER_EVENT_WAIT_LIST " ) ;
1943+ return (UrRet ? std::stoi (UrRet) : (PiRet ? std::stoi (PiRet) : 0 )) ;
18991944}();
19001945
19011946pi_result _pi_ze_event_list_t::createAndRetainPiZeEventList (
@@ -2398,7 +2443,7 @@ pi_result piContextGetInfo(pi_context Context, pi_context_info ParamName,
23982443 return ReturnValue (pi_uint32{Context->RefCount .load ()});
23992444 case PI_EXT_ONEAPI_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT:
24002445 // 2D USM memcpy is supported unless disabled through
2401- // SYCL_PI_LEVEL_ZERO_USE_NATIVE_USM_MEMCPY2D .
2446+ // UR_L0_LEVEL_ZERO_USE_NATIVE_USM_MEMCPY2D .
24022447 return ReturnValue (pi_bool{UseMemcpy2DOperations});
24032448 case PI_EXT_ONEAPI_CONTEXT_INFO_USM_FILL2D_SUPPORT:
24042449 case PI_EXT_ONEAPI_CONTEXT_INFO_USM_MEMSET2D_SUPPORT:
@@ -2901,8 +2946,12 @@ pi_result piQueueFinish(pi_queue Queue) {
29012946 // TODO: this currently exhibits some issues in the driver, so
29022947 // we control this with an env var. Remove this control when
29032948 // we settle one way or the other.
2904- static bool HoldLock =
2905- std::getenv (" SYCL_PI_LEVEL_ZERO_QUEUE_FINISH_HOLD_LOCK" ) != nullptr ;
2949+ const char *UrRet = std::getenv (" UR_L0_QUEUE_FINISH_HOLD_LOCK" );
2950+ const char *PiRet =
2951+ std::getenv (" SYCL_PI_LEVEL_ZERO_QUEUE_FINISH_HOLD_LOCK" );
2952+ const bool HoldLock =
2953+ UrRet ? std::stoi (UrRet) : (PiRet ? std::stoi (PiRet) : 0 );
2954+
29062955 if (!HoldLock) {
29072956 Lock.unlock ();
29082957 }
@@ -5793,7 +5842,7 @@ pi_result piEnqueueEventsWaitWithBarrier(pi_queue Queue,
57935842 // If we have a list of events to make the barrier from, then we can create a
57945843 // barrier on these and use the resulting event as our future barrier.
57955844 // We use the same approach if
5796- // SYCL_PI_LEVEL_ZERO_USE_MULTIPLE_COMMANDLIST_BARRIERS is not set to a
5845+ // UR_L0_USE_MULTIPLE_COMMANDLIST_BARRIERS is not set to a
57975846 // positive value.
57985847 // We use the same approach if we have in-order queue because every command
57995848 // depends on previous one, so we don't need to insert barrier to multiple
@@ -6346,8 +6395,10 @@ pi_result piEnqueueMemBufferCopyRect(
63466395// Default to using compute engine for fill operation, but allow to
63476396// override this with an environment variable.
63486397static bool PreferCopyEngine = [] {
6349- const char *Env = std::getenv (" SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_FILL" );
6350- return Env ? std::stoi (Env) != 0 : false ;
6398+ const char *UrRet = std::getenv (" UR_L0_USE_COPY_ENGINE_FOR_FILL" );
6399+ const char *PiRet =
6400+ std::getenv (" SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE_FOR_FILL" );
6401+ return (UrRet ? std::stoi (UrRet) : (PiRet ? std::stoi (PiRet) : 0 ));
63516402}();
63526403
63536404// PI interfaces must have queue's and buffer's mutexes locked on entry.
@@ -7188,7 +7239,10 @@ enum class USMAllocationForceResidencyType {
71887239
71897240// Returns the desired USM residency setting
71907241static USMAllocationForceResidencyType USMAllocationForceResidency = [] {
7191- const auto Str = std::getenv (" SYCL_PI_LEVEL_ZERO_USM_RESIDENT" );
7242+ const char *UrRet = std::getenv (" UR_L0_USM_RESIDENT" );
7243+ const char *PiRet = std::getenv (" SYCL_PI_LEVEL_ZERO_USM_RESIDENT" );
7244+ const char *Str = UrRet ? UrRet : (PiRet ? PiRet : nullptr );
7245+
71927246 if (!Str)
71937247 return USMAllocationForceResidencyType::P2PDevices;
71947248 switch (std::atoi (Str)) {
@@ -8599,8 +8653,12 @@ pi_result _pi_buffer::getZeHandle(char *&ZeHandle, access_mode_t AccessMode,
85998653 // cross-tile traffic.
86008654 //
86018655 static const bool SingleRootDeviceBufferMigration = [] {
8602- const char *EnvStr =
8656+ const char *UrRet =
8657+ std::getenv (" UR_L0_SINGLE_ROOT_DEVICE_BUFFER_MIGRATION" );
8658+ const char *PiRet =
86038659 std::getenv (" SYCL_PI_LEVEL_ZERO_SINGLE_ROOT_DEVICE_BUFFER_MIGRATION" );
8660+ const char *EnvStr = UrRet ? UrRet : (PiRet ? PiRet : nullptr );
8661+
86048662 if (EnvStr)
86058663 return (std::stoi (EnvStr) != 0 );
86068664 // The default is to migrate normally, which may not always be the
0 commit comments