Skip to content

Commit 6242160

Browse files
authored
[SYCL] Emit a warning message for legacy env vars (#2506)
We are deprecating legacy env vars SYCL_BE and SYCL_DEVICE_TYPE. This PR is intended to inform users about this change during the grace period. Signed-off-by: Byoungro So <[email protected]>
1 parent a476a49 commit 6242160

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

sycl/source/detail/config.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,19 @@ template <> class SYCLConfig<SYCL_DEVICE_FILTER> {
184184
static device_filter_list DFL{ValStr};
185185
FilterList = &DFL;
186186
}
187+
188+
// TODO: remove the following code when we remove the support for legacy
189+
// env vars.
190+
// Emit the deprecation warning message if SYCL_BE or SYCL_DEVICE_TYPE is
191+
// set.
192+
if (SYCLConfig<SYCL_BE>::get() || getenv("SYCL_DEVICE_TYPE")) {
193+
std::cerr << "\nWARNING: The legacy environment variables SYCL_BE and "
194+
"SYCL_DEVICE_TYPE are deprecated. Please use "
195+
"SYCL_DEVICE_FILTER instead. For details, please refer to "
196+
"https://github.com/intel/llvm/blob/sycl/sycl/doc/"
197+
"EnvironmentVariables.md\n\n";
198+
}
199+
187200
// As mentioned above, configuration parameters are processed only once.
188201
// If multiple threads are checking this env var at the same time,
189202
// they will end up setting the configration to the same value.

sycl/source/detail/filter_selector_impl.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,19 @@ int filter_selector_impl::operator()(const device &Dev) const {
131131
} else {
132132
BE = sycl::detail::getSyclObjImpl(Dev)->getPlugin().getBackend();
133133
}
134-
BackendOK = (BE == Filter.Backend);
134+
// Backend is okay if the filter BE is set 'all'.
135+
if (Filter.Backend == backend::all)
136+
BackendOK = true;
137+
else
138+
BackendOK = (BE == Filter.Backend);
135139
}
136140
if (Filter.HasDeviceType) {
137141
info::device_type DT = Dev.get_info<info::device::device_type>();
138-
DeviceTypeOK = (DT == Filter.DeviceType);
142+
// DeviceType is okay if the filter is set 'all'.
143+
if (Filter.DeviceType == info::device_type::all)
144+
DeviceTypeOK = true;
145+
else
146+
DeviceTypeOK = (DT == Filter.DeviceType);
139147
}
140148
if (Filter.HasDeviceNum) {
141149
// Only check device number if we're good on the previous matches

sycl/source/device_selector.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ int default_selector::operator()(const device &dev) const {
154154
if (dev.is_host())
155155
Score += 100;
156156

157+
// Since we deprecate SYCL_BE and SYCL_DEVICE_TYPE,
158+
// we should not disallow accelerator to be chosen.
159+
// But this device type gets the lowest heuristic point.
160+
if (dev.is_accelerator())
161+
Score += 75;
162+
157163
return Score;
158164
}
159165

0 commit comments

Comments
 (0)