Skip to content

[SYCL] Emit a warning message for legacy env vars #2506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions sycl/source/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,19 @@ template <> class SYCLConfig<SYCL_DEVICE_FILTER> {
static device_filter_list DFL{ValStr};
FilterList = &DFL;
}

// TODO: remove the following code when we remove the support for legacy
// env vars.
// Emit the deprecation warning message if SYCL_BE or SYCL_DEVICE_TYPE is
// set.
if (SYCLConfig<SYCL_BE>::get() || getenv("SYCL_DEVICE_TYPE")) {
std::cerr << "\nWARNING: The legacy environment variables SYCL_BE and "
"SYCL_DEVICE_TYPE are deprecated. Please use "
"SYCL_DEVICE_FILTER instead. For details, please refer to "
"https://github.com/intel/llvm/blob/sycl/sycl/doc/"
"EnvironmentVariables.md\n\n";
}

// As mentioned above, configuration parameters are processed only once.
// If multiple threads are checking this env var at the same time,
// they will end up setting the configration to the same value.
Expand Down
12 changes: 10 additions & 2 deletions sycl/source/detail/filter_selector_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,19 @@ int filter_selector_impl::operator()(const device &Dev) const {
} else {
BE = sycl::detail::getSyclObjImpl(Dev)->getPlugin().getBackend();
}
BackendOK = (BE == Filter.Backend);
// Backend is okay if the filter BE is set 'all'.
if (Filter.Backend == backend::all)
BackendOK = true;
else
BackendOK = (BE == Filter.Backend);
}
if (Filter.HasDeviceType) {
info::device_type DT = Dev.get_info<info::device::device_type>();
DeviceTypeOK = (DT == Filter.DeviceType);
// DeviceType is okay if the filter is set 'all'.
if (Filter.DeviceType == info::device_type::all)
DeviceTypeOK = true;
else
DeviceTypeOK = (DT == Filter.DeviceType);
}
if (Filter.HasDeviceNum) {
// Only check device number if we're good on the previous matches
Expand Down
6 changes: 6 additions & 0 deletions sycl/source/device_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ int default_selector::operator()(const device &dev) const {
if (dev.is_host())
Score += 100;

// Since we deprecate SYCL_BE and SYCL_DEVICE_TYPE,
// we should not disallow accelerator to be chosen.
// But this device type gets the lowest heuristic point.
if (dev.is_accelerator())
Score += 75;

return Score;
}

Expand Down