You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sycl/doc/EnvironmentVariables.md
+52-2Lines changed: 52 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,9 @@ compiler and runtime.
7
7
8
8
| Environment variable | Values | Description |
9
9
| -------------------- | ------ | ----------- |
10
-
|`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. We are planning to deprecate `SYCL_BE` environment variable in the future. The specific grace period is not decided yet. Please use the new env var `SYCL_DEVICE_FILTER` instead. |
11
-
|`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. We are planning to deprecate `SYCL_DEVICE_TYPE` environment variable in the future. The specific grace period is not decided yet. Please use the new env var `SYCL_DEVICE_FILTER` instead. |
10
+
|`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. |
12
13
|`SYCL_DEVICE_FILTER`|`backend:device_type:device_num`| See Section [`SYCL_DEVICE_FILTER`](#sycl_device_filter) below. |
13
14
|`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 "\|".|
`(*) Note: Any means this environment variable is effective when set to any non-null value.`
30
31
32
+
### `ONEAPI_DEVICE_SELECTOR`
33
+
34
+
With no environment variables set to say otherwise, all platforms and devices presently on the machine are available. The default choice will be one of these devices, usually preferring a Level Zero GPU device, if available. The `ONEAPI_DEVICE_SELECTOR` can be used to limit that choice of devices, and to expose GPU sub-devices or sub-sub-devices as individual devices.
35
+
36
+
The syntax of this environment variable follows this BNF grammar:
37
+
```
38
+
ONEAPI_DEVICE_SELECTOR = <selector-string>
39
+
<selector-string> ::= <term>[;<term>...]
40
+
<term> ::= <backend>:<devices>
41
+
<backend> ::= { * | level_zero | opencl | cuda | hip | esimd_emulator } // case insensitive
Each term in the grammar selects a collection of devices from a particular backend. The device names cpu, gpu, and fpga select all devices from that backend with the corresponding type. A backend's device can also be selected by its numeric index (zero-based) or by using `*` which selects all devices in the backend.
47
+
48
+
The dot syntax (e.g. `<num>.<num>`) causes one or more GPU sub-devices to be exposed to the application as SYCL root devices. For example, `1.0` exposes the first sub-device of the second device as a SYCL root device. The syntax `<num>.*` exposes all sub-devices of the give device as SYCL root devices. The syntax `*.*` exposes all sub-devices of all GPU devices as SYCL root devices.
49
+
50
+
In general, a term with one or more asterisks ( `*` ) matches all backends, devices, or sub-devices with the given pattern. However, a warning is generated if the term does not match anything. For example, `*:gpu` matches all GPU devices in all backends (ignoring backends with no GPU devices), but it generates a warning if there are no GPU devices in any backend. Likewise, `level_zero:*.*` matches all sub-devices of partitionable GPUs in the Level Zero backend, but it generates a warning if there are no Level Zero GPU devices that are partitionable into sub-devices.
51
+
52
+
The device indices are zero-based and are unique only within a backend. Therefore, `level_zero:0` is a different device from `cuda:0`. To see the indices of all available devices, run the `sycl-ls` tool. Note that different backends sometimes expose the same hardware as different "devices". For example, the level_zero and opencl backends both expose the Intel GPU devices.
53
+
54
+
55
+
Additionally, if a sub-device is chosen (via numeric index or wildcard), then an additional layer of partitioning can be specified. In other words, a sub-sub-device can be selected. Like sub-devices, this is done with a period ( `.` ) and a sub-sub-device specifier which is a wildcard symbol ( `*` ) or a numeric index. Example `ONEAPI_DEVICE_SELECTOR=level_zero:0.*.*` would partition device 0 into sub-devices and then partition each of those into sub-sub-devices. The range of grandchild sub-sub-devices would be the final devices available to the app, neither device 0, nor its child partitions would be in that list.
56
+
57
+
58
+
The following examples further illustrate the usage of this environment variable:
59
+
60
+
| Example | Result |
61
+
-----------|---------
62
+
|`ONEAPI_DEVICE_SELECTOR=opencl:*`| Only the OpenCL devices are available |
63
+
|`ONEAPI_DEVICE_SELECTOR=level_zero:gpu`| Only GPU devices on the Level Zero platform are available.|
64
+
|`ONEAPI_DEVICE_SELECTOR="opencl:gpu;level_zero:gpu"`| GPU devices from both Level Zero and OpenCL are available. Note that escaping (like quotation marks) will likely be needed when using semi-colon separated entries. |
65
+
|`ONEAPI_DEVICE_SELECTOR=opencl:gpu,cpu`| Only CPU and GPU devices on the OpenCL platform are available.|
66
+
|`ONEAPI_DEVICE_SELECTOR=opencl:0`| Only the device with index 0 on the OpenCL backend is available. |
67
+
|`ONEAPI_DEVICE_SELECTOR=hip:0,2`| Only devices with indices of 0 and 2 from the HIP backend are available. |
68
+
|`ONEAPI_DEVICE_SELECTOR=opencl:0.*`| All the sub-devices from the OpenCL device with index 0 are exposed as SYCL root devices. No other devices are available. |
69
+
|`ONEAPI_DEVICE_SELECTOR=opencl:0.2`| The third sub-device (2 in zero-based counting) of the OpenCL device with index 0 will be the sole device available. |
70
+
|`ONEAPI_DEVICE_SELECTOR=level_zero:*,*.*`| Exposes Level Zero devices to the application in two different ways. Each device (aka "card") is exposed as a SYCL root device and each sub-device is also exposed as a SYCL root device.|
71
+
72
+
73
+
Notes:
74
+
- The backend argument is always required. An error will be thrown if it is absent.
75
+
- Additionally, the backend MUST be followed by colon ( `:` ) and at least one device specifier of some sort, else an error is thrown.
76
+
- For sub-devices and sub-sub-devices, the parent device must support partitioning (`info::partition_property::partition_by_affinity_domain` and `info::partition_affinity_domain::next_partitionable`. See the SYCL 2020 specification for a precise definition.) For Intel GPUs, the sub-device and sub-sub-device syntax can be used to expose tiles or CCSs to the SYCL application as root devices. The exact mapping between sub-device, sub-sub-device, tiles, and CCSs is specific to the hardware.
77
+
- The semi-colon character ( `;` ) is treated specially by many shells, so you may need to enclose the string in quotes if the selection string contains this character.
78
+
79
+
80
+
31
81
### `SYCL_DEVICE_ALLOWLIST`
32
82
33
83
A list of devices and their driver version following the pattern:
0 commit comments