Skip to content

Commit 1ee35aa

Browse files
authored
[SYCL] Remove SYCL_BE and SYCL_DEVICE_TYPE env vars from code (#7214)
This PR aims to remove the usage of the SYCL_BE and SYCL_DEVICE_TYPE environment variables( which can be found here : https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md ) from code and documentation since they have already been deprecated for some time and warning messages have been shown to discourage their use.
1 parent 9670beb commit 1ee35aa

File tree

14 files changed

+25
-208
lines changed

14 files changed

+25
-208
lines changed

sycl/doc/EnvironmentVariables.md

100755100644
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ compiler and runtime.
88
| Environment variable | Values | Description |
99
| -------------------- | ------ | ----------- |
1010
| `ONEAPI_DEVICE_SELECTOR` | [See below.](#oneapi_device_selector) | This device selection environment variable can be used to limit the choice of devices available when the SYCL-using application is run. Useful for limiting devices to a certain type (like GPUs or accelerators) or backends (like Level Zero or OpenCL). This device selection mechanism is replacing `SYCL_DEVICE_FILTER` . The `ONEAPI_DEVICE_SELECTOR` syntax is shared with OpenMP and also allows sub-devices to be chosen. [See below.](#oneapi_device_selector) for a full description. |
11-
| `SYCL_BE` (deprecated) | `PI_OPENCL`, `PI_LEVEL_ZERO`, `PI_CUDA` | Force SYCL RT to consider only devices of the specified backend during the device selection. The `SYCL_BE` environment variable is deprecated and will be removed soon. Please use the new env var `ONEAPI_DEVICE_SELECTOR` instead. |
12-
| `SYCL_DEVICE_TYPE` (deprecated) | CPU, GPU, ACC, HOST | Force SYCL to use the specified device type. If unset, default selection rules are applied. If set to any unlisted value, this control has no effect. If the requested device type is not found, a `sycl::runtime_error` exception is thrown. If a non-default device selector is used, a device must satisfy both the selector and this control to be chosen. This control only has effect on devices created with a selector. The `SYCL_DEVICE_TYPE` environment variable is deprecated and will be removed soon. Please use the new env var `ONEAPI_DEVICE_SELECTOR` instead. |
1311
| `SYCL_DEVICE_FILTER` (deprecated) | `backend:device_type:device_num` | Please use `ONEAPI_DEVICE_SELECTOR` environment variable instead. See section [`SYCL_DEVICE_FILTER`](#sycl_device_filter) below for `SYCL_DEVICE_FILTER` description. |
1412
| `SYCL_DEVICE_ALLOWLIST` | See [below](#sycl_device_allowlist) | Filter out devices that do not match the pattern specified. `BackendName` accepts `host`, `opencl`, `level_zero` or `cuda`. `DeviceType` accepts `host`, `cpu`, `gpu` or `acc`. `DeviceVendorId` accepts uint32_t in hex form (`0xXYZW`). `DriverVersion`, `PlatformVersion`, `DeviceName` and `PlatformName` accept regular expression. Special characters, such as parenthesis, must be escaped. DPC++ runtime will select only those devices which satisfy provided values above and regex. More than one device can be specified using the piping symbol "\|".|
1513
| `SYCL_DISABLE_PARALLEL_FOR_RANGE_ROUNDING` | Any(\*) | Disables automatic rounding-up of `parallel_for` invocation ranges. |

sycl/doc/GetStartedGuide.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -687,13 +687,13 @@ The `simple-sycl-app.exe` application doesn't specify SYCL device for
687687
execution, so SYCL runtime will use `default_selector` logic to select one
688688
of accelerators available in the system.
689689
In this case, the behavior of the `default_selector` can be altered
690-
using the `SYCL_BE` environment variable, setting `PI_CUDA` forces
691-
the usage of the CUDA backend (if available), `PI_HIP` forces
692-
the usage of the HIP backend (if available), `PI_OPENCL` will
690+
using the `ONEAPI_DEVICE_SELECTOR` environment variable, setting `cuda:*` forces
691+
the usage of the CUDA backend (if available), `hip:*` forces
692+
the usage of the HIP backend (if available), `opencl:*` will
693693
force the usage of the OpenCL backend.
694694
695695
```bash
696-
SYCL_BE=PI_CUDA ./simple-sycl-app-cuda.exe
696+
ONEAPI_DEVICE_SELECTOR=cuda:* ./simple-sycl-app-cuda.exe
697697
```
698698
699699
The default is the OpenCL backend if available.
@@ -709,11 +709,11 @@ The results are correct!
709709
```
710710
711711
**NOTE**: Currently, when the application has been built with the CUDA target,
712-
the CUDA backend must be selected at runtime using the `SYCL_BE` environment
712+
the CUDA backend must be selected at runtime using the `ONEAPI_DEVICE_SELECTOR` environment
713713
variable.
714714
715715
```bash
716-
SYCL_BE=PI_CUDA ./simple-sycl-app-cuda.exe
716+
ONEAPI_DEVICE_SELECTOR=cuda:* ./simple-sycl-app-cuda.exe
717717
```
718718
719719
**NOTE**: DPC++/SYCL developers can specify SYCL device for execution using

sycl/doc/design/PluginInterface.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ stored in the associated platforms during platform object construction.
9797
The PI API calls are later forwarded using this information.
9898
A plugin is said to "bind" after this process completes with no errors.
9999
During device selection, the user can prefer selection of a device from a
100-
specific Plugin or Backend using the env SYCL_BE. The correspondence between
101-
a plugin and a SYCL_BE value is currently hardcoded in the runtime.
100+
specific Plugin or Backend using the env ONEAPI_DEVICE_SELECTOR. The correspondence between
101+
a plugin and a ONEAPI_DEVICE_SELECTOR value is currently hardcoded in the runtime.
102102
( TBD: Make this a part of configuration file).
103-
Eg: SYCL_BE=PI_OPENCL corresponds to OpenCL Plugin.
103+
Eg: ONEAPI_DEVICE_SELECTOR=opencl:* corresponds to OpenCL Plugin.
104104

105105
#### OpenCL plugin
106106

sycl/include/sycl/detail/pi.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ template <class To, class From> To cast(From value);
159159
// Holds the PluginInformation for the plugin that is bound.
160160
// Currently a global variable is used to store OpenCL plugin information to be
161161
// used with SYCL Interoperability Constructors.
162+
// TODO: GlobalPlugin does not seem to be needed anymore. Consider removing it!
162163
extern std::shared_ptr<plugin> GlobalPlugin;
163164

164165
// Performs PI one-time initialization.

sycl/source/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ set(SYCL_SOURCES
132132
"detail/error_handling/enqueue_kernel.cpp"
133133
"detail/event_impl.cpp"
134134
"detail/filter_selector_impl.cpp"
135-
"detail/force_device.cpp"
136135
"detail/global_handler.cpp"
137136
"detail/helpers.cpp"
138137
"detail/handler_proxy.cpp"

sycl/source/detail/config.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ CONFIG(SYCL_PRINT_EXECUTION_GRAPH, 32, __SYCL_PRINT_EXECUTION_GRAPH)
1414
CONFIG(SYCL_DISABLE_EXECUTION_GRAPH_CLEANUP, 1, __SYCL_DISABLE_EXECUTION_GRAPH_CLEANUP)
1515
CONFIG(SYCL_DISABLE_POST_ENQUEUE_CLEANUP, 1, __SYCL_DISABLE_POST_ENQUEUE_CLEANUP)
1616
CONFIG(SYCL_DEVICE_ALLOWLIST, 1024, __SYCL_DEVICE_ALLOWLIST)
17-
CONFIG(SYCL_BE, 16, __SYCL_BE)
1817
CONFIG(SYCL_PI_TRACE, 16, __SYCL_PI_TRACE)
1918
CONFIG(SYCL_PARALLEL_FOR_RANGE_ROUNDING_TRACE, 16, __SYCL_PARALLEL_FOR_RANGE_ROUNDING_TRACE)
2019
CONFIG(SYCL_DISABLE_PARALLEL_FOR_RANGE_ROUNDING, 16, __SYCL_DISABLE_PARALLEL_FOR_RANGE_ROUNDING)

sycl/source/detail/config.hpp

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -126,46 +126,6 @@ template <ConfigID Config> class SYCLConfig {
126126
}
127127
};
128128

129-
template <> class SYCLConfig<SYCL_BE> {
130-
using BaseT = SYCLConfigBase<SYCL_BE>;
131-
132-
public:
133-
static backend *get() {
134-
static bool Initialized = false;
135-
static backend *BackendPtr = nullptr;
136-
137-
// Configuration parameters are processed only once, like reading a string
138-
// from environment and converting it into a typed object.
139-
if (Initialized)
140-
return BackendPtr;
141-
142-
const char *ValStr = BaseT::getRawValue();
143-
const std::array<std::pair<std::string, backend>, 6> SyclBeMap = {
144-
{{"PI_OPENCL", backend::opencl},
145-
{"PI_LEVEL_ZERO", backend::ext_oneapi_level_zero},
146-
{"PI_LEVEL0", backend::ext_oneapi_level_zero}, // for backward
147-
// compatibility
148-
{"PI_CUDA", backend::ext_oneapi_cuda},
149-
{"PI_ESIMD_EMULATOR", backend::ext_intel_esimd_emulator},
150-
{"PI_HIP", backend::ext_oneapi_hip}}};
151-
if (ValStr) {
152-
auto It = std::find_if(
153-
std::begin(SyclBeMap), std::end(SyclBeMap),
154-
[&ValStr](const std::pair<std::string, backend> &element) {
155-
return element.first == ValStr;
156-
});
157-
if (It == SyclBeMap.end())
158-
pi::die("Invalid backend. "
159-
"Valid values are "
160-
"PI_OPENCL/PI_LEVEL_ZERO/PI_CUDA/PI_ESIMD_EMULATOR/PI_HIP");
161-
static backend Backend = It->second;
162-
BackendPtr = &Backend;
163-
}
164-
Initialized = true;
165-
return BackendPtr;
166-
}
167-
};
168-
169129
template <> class SYCLConfig<SYCL_PI_TRACE> {
170130
using BaseT = SYCLConfigBase<SYCL_PI_TRACE>;
171131

@@ -336,18 +296,6 @@ class __SYCL2020_DEPRECATED("Use SYCLConfig<ONEAPI_DEVICE_SELECTOR> instead")
336296
FilterList = &GlobalHandler::instance().getDeviceFilterList(ValStr);
337297
}
338298

339-
// TODO: remove the following code when we remove the support for legacy
340-
// env vars.
341-
// Emit the deprecation warning message if SYCL_BE or SYCL_DEVICE_TYPE is
342-
// set.
343-
if (SYCLConfig<SYCL_BE>::get() || getenv("SYCL_DEVICE_TYPE")) {
344-
std::cerr << "\nWARNING: The legacy environment variables SYCL_BE and "
345-
"SYCL_DEVICE_TYPE are deprecated. Please use "
346-
"SYCL_DEVICE_FILTER instead. For details, please refer to "
347-
"https://github.com/intel/llvm/blob/sycl/sycl/doc/"
348-
"EnvironmentVariables.md\n\n";
349-
}
350-
351299
// As mentioned above, configuration parameters are processed only once.
352300
// If multiple threads are checking this env var at the same time,
353301
// they will end up setting the configration to the same value.

sycl/source/detail/force_device.cpp

Lines changed: 0 additions & 50 deletions
This file was deleted.

sycl/source/detail/force_device.hpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

sycl/source/detail/pi.cpp

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ std::string memFlagsToString(pi_mem_flags Flags) {
265265

266266
// GlobalPlugin is a global Plugin used with Interoperability constructors that
267267
// use OpenCL objects to construct SYCL class objects.
268+
// TODO: GlobalPlugin does not seem to be needed anymore. Consider removing it!
268269
std::shared_ptr<plugin> GlobalPlugin;
269270

270271
// Find the plugin at the appropriate location and return the location.
@@ -441,39 +442,6 @@ static void initializePlugins(std::vector<plugin> &Plugins) {
441442
}
442443
continue;
443444
}
444-
backend *BE = SYCLConfig<SYCL_BE>::get();
445-
// Use OpenCL as the default interoperability plugin.
446-
// This will go away when we make backend interoperability selection
447-
// explicit in SYCL-2020.
448-
backend InteropBE = BE ? *BE : backend::opencl;
449-
450-
if (InteropBE == backend::opencl &&
451-
PluginNames[I].first.find("opencl") != std::string::npos) {
452-
// Use the OpenCL plugin as the GlobalPlugin
453-
GlobalPlugin =
454-
std::make_shared<plugin>(PluginInformation, backend::opencl, Library);
455-
} else if (InteropBE == backend::ext_oneapi_cuda &&
456-
PluginNames[I].first.find("cuda") != std::string::npos) {
457-
// Use the CUDA plugin as the GlobalPlugin
458-
GlobalPlugin = std::make_shared<plugin>(
459-
PluginInformation, backend::ext_oneapi_cuda, Library);
460-
} else if (InteropBE == backend::ext_oneapi_hip &&
461-
PluginNames[I].first.find("hip") != std::string::npos) {
462-
// Use the HIP plugin as the GlobalPlugin
463-
GlobalPlugin = std::make_shared<plugin>(PluginInformation,
464-
backend::ext_oneapi_hip, Library);
465-
} else if (InteropBE == backend::ext_oneapi_level_zero &&
466-
PluginNames[I].first.find("level_zero") != std::string::npos) {
467-
// Use the LEVEL_ZERO plugin as the GlobalPlugin
468-
GlobalPlugin = std::make_shared<plugin>(
469-
PluginInformation, backend::ext_oneapi_level_zero, Library);
470-
} else if (InteropBE == backend::ext_intel_esimd_emulator &&
471-
PluginNames[I].first.find("esimd_emulator") !=
472-
std::string::npos) {
473-
// Use the ESIMD_EMULATOR plugin as the GlobalPlugin
474-
GlobalPlugin = std::make_shared<plugin>(
475-
PluginInformation, backend::ext_intel_esimd_emulator, Library);
476-
}
477445
plugin &NewPlugin = Plugins.emplace_back(
478446
plugin(PluginInformation, PluginNames[I].second, Library));
479447
if (trace(TraceLevel::PI_TRACE_BASIC))

0 commit comments

Comments
 (0)