@@ -60,43 +60,6 @@ static const bool UseCopyEngineForD2DCopy = [] {
60
60
return (CopyEngineForD2DCopy && (std::stoi (CopyEngineForD2DCopy) != 0 ));
61
61
}();
62
62
63
- // SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE can be set to an integer value, or
64
- // a pair of integer values of the form "lower_index:upper_index".
65
- // Here, the indices point to copy engines in a list of all available copy
66
- // engines.
67
- // This functions returns this pair of indices.
68
- // If the user specifies only a single integer, a value of 0 indicates that
69
- // the copy engines will not be used at all. A value of 1 indicates that all
70
- // available copy engines can be used.
71
- static const std::pair<int , int > getRangeOfAllowedCopyEngines = [] {
72
- const char *EnvVar = std::getenv (" SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE" );
73
- // If the environment variable is not set, all available copy engines can be
74
- // used.
75
- if (!EnvVar) {
76
- return std::pair<int , int >(0 , INT_MAX);
77
- }
78
- std::string CopyEngineRange = EnvVar;
79
- // Environment variable can be a single integer or a pair of integers
80
- // separated by ":"
81
- auto pos = CopyEngineRange.find (" :" );
82
- if (pos == std::string::npos) {
83
- bool UseCopyEngine = (std::stoi (CopyEngineRange) != 0 );
84
- if (UseCopyEngine)
85
- return std::pair<int , int >(0 , INT_MAX); // All copy engines can be used.
86
- else
87
- return std::pair<int , int >(-1 , -1 ); // No copy engines will be used.
88
- }
89
- int LowerCopyEngineIndex = std::stoi (CopyEngineRange.substr (0 , pos));
90
- int UpperCopyEngineIndex = std::stoi (CopyEngineRange.substr (pos + 1 ));
91
- return std::pair<int , int >(LowerCopyEngineIndex, UpperCopyEngineIndex);
92
- }();
93
-
94
- static const bool CopyEngineRequested = [] {
95
- int LowerCopyQueueIndex = getRangeOfAllowedCopyEngines.first ;
96
- int UpperCopyQueueIndex = getRangeOfAllowedCopyEngines.second ;
97
- return ((LowerCopyQueueIndex != -1 ) || (UpperCopyQueueIndex != -1 ));
98
- }();
99
-
100
63
// This class encapsulates actions taken along with a call to Level Zero API.
101
64
class ZeCall {
102
65
private:
@@ -322,6 +285,48 @@ class ReturnHelper {
322
285
323
286
} // anonymous namespace
324
287
288
+ // SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE can be set to an integer value, or
289
+ // a pair of integer values of the form "lower_index:upper_index".
290
+ // Here, the indices point to copy engines in a list of all available copy
291
+ // engines.
292
+ // This functions returns this pair of indices.
293
+ // If the user specifies only a single integer, a value of 0 indicates that
294
+ // the copy engines will not be used at all. A value of 1 indicates that all
295
+ // available copy engines can be used.
296
+ static const std::pair<int , int > getRangeOfAllowedCopyEngines = [] {
297
+ const char *EnvVar = std::getenv (" SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE" );
298
+ // If the environment variable is not set, all available copy engines can be
299
+ // used.
300
+ if (!EnvVar)
301
+ return std::pair<int , int >(0 , INT_MAX);
302
+ std::string CopyEngineRange = EnvVar;
303
+ // Environment variable can be a single integer or a pair of integers
304
+ // separated by ":"
305
+ auto pos = CopyEngineRange.find (" :" );
306
+ if (pos == std::string::npos) {
307
+ bool UseCopyEngine = (std::stoi (CopyEngineRange) != 0 );
308
+ if (UseCopyEngine)
309
+ return std::pair<int , int >(0 , INT_MAX); // All copy engines can be used.
310
+ return std::pair<int , int >(-1 , -1 ); // No copy engines will be used.
311
+ }
312
+ int LowerCopyEngineIndex = std::stoi (CopyEngineRange.substr (0 , pos));
313
+ int UpperCopyEngineIndex = std::stoi (CopyEngineRange.substr (pos + 1 ));
314
+ if ((LowerCopyEngineIndex > UpperCopyEngineIndex) ||
315
+ (LowerCopyEngineIndex < -1 ) || (UpperCopyEngineIndex < -1 )) {
316
+ zePrint (" SYCL_PI_LEVEL_ZERO_USE_COPY_ENGINE: invalid value provided, "
317
+ " default set.\n " );
318
+ LowerCopyEngineIndex = 0 ;
319
+ UpperCopyEngineIndex = INT_MAX;
320
+ }
321
+ return std::pair<int , int >(LowerCopyEngineIndex, UpperCopyEngineIndex);
322
+ }();
323
+
324
+ static const bool CopyEngineRequested = [] {
325
+ int LowerCopyQueueIndex = getRangeOfAllowedCopyEngines.first ;
326
+ int UpperCopyQueueIndex = getRangeOfAllowedCopyEngines.second ;
327
+ return ((LowerCopyQueueIndex != -1 ) || (UpperCopyQueueIndex != -1 ));
328
+ }();
329
+
325
330
// Global variables used in PI_Level_Zero
326
331
// Note we only create a simple pointer variables such that C++ RT won't
327
332
// deallocate them automatically at the end of the main program.
@@ -1092,8 +1097,7 @@ _pi_queue::getZeCopyCommandQueue(int *CopyQueueIndex,
1092
1097
1093
1098
// Return nullptr when no copy command queues are allowed to be used or if
1094
1099
// no copy command queues are available.
1095
- if ((LowerCopyQueueIndex == -1 ) || (UpperCopyQueueIndex == -1 ) ||
1096
- (LowerCopyQueueIndex > UpperCopyQueueIndex) || (n == 0 )) {
1100
+ if ((LowerCopyQueueIndex == -1 ) || (UpperCopyQueueIndex == -1 ) || (n == 0 )) {
1097
1101
if (CopyQueueGroupIndex)
1098
1102
*CopyQueueGroupIndex = -1 ;
1099
1103
*CopyQueueIndex = -1 ;
0 commit comments