Skip to content

Commit 44d7926

Browse files
authored
[SYCL] Fix ESIMD_EMULATOR being picked as default device (#6870)
This commit attempts to fix the problem that occurs when the default device selector picks the ESIMD_EMULATOR when other devices are available.
1 parent 429c09e commit 44d7926

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

sycl/source/detail/filter_selector_impl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ filter create_filter(const std::string &Input) {
7676
Result.Backend = backend::ext_oneapi_cuda;
7777
} else if (Token == "hip" && !Result.Backend) {
7878
Result.Backend = backend::ext_oneapi_hip;
79+
} else if (Token == "esimd_emulator" && !Result.Backend) {
80+
Result.Backend = backend::ext_intel_esimd_emulator;
7981
} else if (std::regex_match(Token, IntegerExpr) && !Result.DeviceNum) {
8082
try {
8183
Result.DeviceNum = std::stoi(Token);

sycl/source/detail/pi.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,6 @@ std::vector<std::pair<std::string, backend>> findPlugins() {
283283
backend::ext_oneapi_level_zero);
284284
PluginNames.emplace_back(__SYCL_CUDA_PLUGIN_NAME, backend::ext_oneapi_cuda);
285285
PluginNames.emplace_back(__SYCL_HIP_PLUGIN_NAME, backend::ext_oneapi_hip);
286-
PluginNames.emplace_back(__SYCL_ESIMD_EMULATOR_PLUGIN_NAME,
287-
backend::ext_intel_esimd_emulator);
288286
} else {
289287
std::vector<device_filter> Filters = FilterList->get();
290288
bool OpenCLFound = false;
@@ -311,8 +309,7 @@ std::vector<std::pair<std::string, backend>> findPlugins() {
311309
backend::ext_oneapi_cuda);
312310
CudaFound = true;
313311
}
314-
if (!EsimdCpuFound && (Backend == backend::ext_intel_esimd_emulator ||
315-
Backend == backend::all)) {
312+
if (!EsimdCpuFound && Backend == backend::ext_intel_esimd_emulator) {
316313
PluginNames.emplace_back(__SYCL_ESIMD_EMULATOR_PLUGIN_NAME,
317314
backend::ext_intel_esimd_emulator);
318315
EsimdCpuFound = true;

sycl/source/device_selector.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,22 @@ static void traceDeviceSelector(const std::string &DeviceType) {
164164
bool ShouldTrace = false;
165165
ShouldTrace = detail::pi::trace(detail::pi::TraceLevel::PI_TRACE_BASIC);
166166
if (ShouldTrace) {
167-
std::cout << "SYCL_PI_TRACE[all]: Requested device_type: " << DeviceType << std::endl;
167+
std::cout << "SYCL_PI_TRACE[all]: Requested device_type: " << DeviceType
168+
<< std::endl;
168169
}
169170
}
170171

171172
__SYCL_EXPORT int default_selector_v(const device &dev) {
172173
// The default selector doesn't reject any devices.
173174
int Score = 0;
174175

176+
// we give the esimd_emulator device a score of zero to prevent it from being
177+
// chosen among other devices. The same thing is done for gpu_selector_v
178+
// below.
179+
if (dev.get_backend() == backend::ext_intel_esimd_emulator) {
180+
return 0;
181+
}
182+
175183
traceDeviceSelector("info::device_type::automatic");
176184
if (dev.get_info<info::device::device_type>() == detail::get_forced_type())
177185
Score += 2000;
@@ -197,6 +205,10 @@ __SYCL_EXPORT int default_selector_v(const device &dev) {
197205
__SYCL_EXPORT int gpu_selector_v(const device &dev) {
198206
int Score = detail::REJECT_DEVICE_SCORE;
199207

208+
if (dev.get_backend() == backend::ext_intel_esimd_emulator) {
209+
return 0;
210+
}
211+
200212
traceDeviceSelector("info::device_type::gpu");
201213
if (dev.is_gpu()) {
202214
Score = 1000;

0 commit comments

Comments
 (0)