@@ -263,19 +263,34 @@ std::string memFlagsToString(pi_mem_flags Flags) {
263
263
std::shared_ptr<plugin> GlobalPlugin;
264
264
265
265
// Find the plugin at the appropriate location and return the location.
266
- bool findPlugins (std::vector<std::pair<std::string, backend>> &PluginNames) {
266
+ std::vector<std::pair<std::string, backend>> findPlugins () {
267
+ std::vector<std::pair<std::string, backend>> PluginNames;
268
+
267
269
// TODO: Based on final design discussions, change the location where the
268
270
// plugin must be searched; how to identify the plugins etc. Currently the
269
271
// search is done for libpi_opencl.so/pi_opencl.dll file in LD_LIBRARY_PATH
270
272
// env only.
271
273
//
274
+ const char *OpenCLPluginName =
275
+ SYCLConfig<SYCL_OVERRIDE_PI_OPENCL>::get ()
276
+ ? SYCLConfig<SYCL_OVERRIDE_PI_OPENCL>::get ()
277
+ : __SYCL_OPENCL_PLUGIN_NAME;
278
+ const char *L0PluginName =
279
+ SYCLConfig<SYCL_OVERRIDE_PI_LEVEL_ZERO>::get ()
280
+ ? SYCLConfig<SYCL_OVERRIDE_PI_LEVEL_ZERO>::get ()
281
+ : __SYCL_LEVEL_ZERO_PLUGIN_NAME;
282
+ const char *CUDAPluginName = SYCLConfig<SYCL_OVERRIDE_PI_CUDA>::get ()
283
+ ? SYCLConfig<SYCL_OVERRIDE_PI_CUDA>::get ()
284
+ : __SYCL_CUDA_PLUGIN_NAME;
285
+ const char *ROCMPluginName = SYCLConfig<SYCL_OVERRIDE_PI_ROCM>::get ()
286
+ ? SYCLConfig<SYCL_OVERRIDE_PI_ROCM>::get ()
287
+ : __SYCL_ROCM_PLUGIN_NAME;
272
288
device_filter_list *FilterList = SYCLConfig<SYCL_DEVICE_FILTER>::get ();
273
289
if (!FilterList) {
274
- PluginNames.emplace_back (__SYCL_OPENCL_PLUGIN_NAME, backend::opencl);
275
- PluginNames.emplace_back (__SYCL_LEVEL_ZERO_PLUGIN_NAME,
276
- backend::level_zero);
277
- PluginNames.emplace_back (__SYCL_CUDA_PLUGIN_NAME, backend::cuda);
278
- PluginNames.emplace_back (__SYCL_ROCM_PLUGIN_NAME, backend::rocm);
290
+ PluginNames.emplace_back (OpenCLPluginName, backend::opencl);
291
+ PluginNames.emplace_back (L0PluginName, backend::level_zero);
292
+ PluginNames.emplace_back (CUDAPluginName, backend::cuda);
293
+ PluginNames.emplace_back (ROCMPluginName, backend::rocm);
279
294
} else {
280
295
std::vector<device_filter> Filters = FilterList->get ();
281
296
bool OpenCLFound = false ;
@@ -286,26 +301,25 @@ bool findPlugins(std::vector<std::pair<std::string, backend>> &PluginNames) {
286
301
backend Backend = Filter.Backend ;
287
302
if (!OpenCLFound &&
288
303
(Backend == backend::opencl || Backend == backend::all)) {
289
- PluginNames.emplace_back (__SYCL_OPENCL_PLUGIN_NAME , backend::opencl);
304
+ PluginNames.emplace_back (OpenCLPluginName , backend::opencl);
290
305
OpenCLFound = true ;
291
306
}
292
307
if (!LevelZeroFound &&
293
308
(Backend == backend::level_zero || Backend == backend::all)) {
294
- PluginNames.emplace_back (__SYCL_LEVEL_ZERO_PLUGIN_NAME,
295
- backend::level_zero);
309
+ PluginNames.emplace_back (L0PluginName, backend::level_zero);
296
310
LevelZeroFound = true ;
297
311
}
298
312
if (!CudaFound && (Backend == backend::cuda || Backend == backend::all)) {
299
- PluginNames.emplace_back (__SYCL_CUDA_PLUGIN_NAME , backend::cuda);
313
+ PluginNames.emplace_back (CUDAPluginName , backend::cuda);
300
314
CudaFound = true ;
301
315
}
302
316
if (!RocmFound && (Backend == backend::rocm || Backend == backend::all)) {
303
- PluginNames.emplace_back (__SYCL_ROCM_PLUGIN_NAME , backend::rocm);
317
+ PluginNames.emplace_back (ROCMPluginName , backend::rocm);
304
318
RocmFound = true ;
305
319
}
306
320
}
307
321
}
308
- return true ;
322
+ return PluginNames ;
309
323
}
310
324
311
325
// Load the Plugin by calling the OS dependent library loading call.
@@ -359,8 +373,7 @@ const std::vector<plugin> &initialize() {
359
373
}
360
374
361
375
static void initializePlugins (std::vector<plugin> *Plugins) {
362
- std::vector<std::pair<std::string, backend>> PluginNames;
363
- findPlugins (PluginNames);
376
+ std::vector<std::pair<std::string, backend>> PluginNames = findPlugins ();
364
377
365
378
if (PluginNames.empty () && trace (PI_TRACE_ALL))
366
379
std::cerr << " SYCL_PI_TRACE[all]: "
0 commit comments