Skip to content

Commit 243bf5d

Browse files
author
Alexander Johnston
committed
[SYCL] Select GlobalPlugin based on SYCL_BE
Rather than choose the last found plugin as GlobalPlugin, select it depending on the SYCL_BE env var. Signed-off-by: Alexander Johnston <[email protected]>
1 parent 235cfdd commit 243bf5d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

sycl/source/detail/pi.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ bool bindPlugin(void *Library, PiPlugin *PluginInformation) {
166166
}
167167

168168
// Load the plugin based on SYCL_BE.
169-
// TODO: Currently only accepting OpenCL and CUDA plugins. Edit it to identify and load
170-
// other kinds of plugins, do the required changes in the findPlugins,
171-
// loadPlugin and bindPlugin functions.
169+
// TODO: Currently only accepting OpenCL and CUDA plugins. Edit it to identify
170+
// and load other kinds of plugins, do the required changes in the
171+
// findPlugins, loadPlugin and bindPlugin functions.
172172
vector_class<plugin> initialize() {
173173
vector_class<plugin> Plugins;
174174

@@ -196,11 +196,18 @@ vector_class<plugin> initialize() {
196196
std::cerr << "Failed to bind PI APIs to the plugin: " << PluginNames[I]
197197
<< std::endl;
198198
}
199+
if (useBackend(SYCL_BE_PI_OPENCL) &&
200+
PluginNames[I].find("opencl") != std::string::npos) {
201+
// Use the OpenCL plugin as the GlobalPlugin
202+
GlobalPlugin = std::make_shared<plugin>(PluginInformation);
203+
}
204+
if (useBackend(SYCL_BE_PI_CUDA) &&
205+
PluginNames[I].find("cuda") != std::string::npos) {
206+
// Use the CUDA plugin as the GlobalPlugin
207+
GlobalPlugin = std::make_shared<plugin>(PluginInformation);
208+
}
199209
Plugins.push_back(plugin(PluginInformation));
200210
}
201-
// TODO: Correct the logic to store the appropriate plugin into GlobalPlugin
202-
// variable. Currently it saves the last plugin found.
203-
GlobalPlugin = std::make_shared<plugin>(PluginInformation);
204211
return Plugins;
205212
}
206213

0 commit comments

Comments
 (0)