Skip to main content

Command Palette

Search for a command to run...

OneAPI, WSL2, and Intel Arc A370M

Updated
3 min read

Tony Mongkolsmai has a good write-up on some problems on WSL2 and multiple GPUS. A solution for multiple Intel GPUs, in Tony's case an integrated U770 and a discrete Arc A770, is to deactivate U770 in the Windows Device Manager to force Level Zero to run on the discrete GPU. And it works for my Asus laptop with an Arc A370M. But, that's annoying because the A370M lacks some features that make my laptop useable like dimming the laptop monitor. Or controlling the color output.

Device control via environmental variables

There's a better way in WSL2 to do this. There are environmental variables available for both SYCL and OneAPI that can control which devices and platforms will show up when running a sycl application. SYCL_DEVICE_FILTER is an environmental variable that can select on backend, device type, and device number.

As an example, here's an unfiltered sycl-ls call on my Ubuntu 22.04 setup with OneAPI:

[opencl:acc:0] Intel(R) FPGA Emulation Platform for OpenCL(TM), Intel(R) FPGA Emulation Device 1.2 [2022.15.12.0.01_081451] 
[opencl:cpu:1] Intel(R) OpenCL, 12th Gen Intel(R) Core(TM) i7-12700H 3.0 [2022.15.12.0.01_081451] 
[opencl:gpu:2] Intel(R) OpenCL HD Graphics, Intel(R) Graphics [0x5693] 3.0 [22.49.25018.23] 
[opencl:gpu:3] Intel(R) OpenCL HD Graphics, Intel(R) Graphics [0x46a6] 3.0 [22.49.25018.23] 
[ext_oneapi_level_zero:gpu:0] Intel(R) Level-Zero, Intel(R) Graphics [0x5693] 1.3 [1.3.25018] 
[ext_oneapi_level_zero:gpu:1] Intel(R) Level-Zero, Intel(R) Graphics [0x46a6] 1.3 [1.3.25018]

An OpenCL FPGA emulation, one CPU OpenCL backends, two GPU OpenCL backends, and two Level Zero backends are listed. But, by using a particular environment variable to select the backend, SYCL_DEVICE_FILTER=level_zero sycl-ls the output changes:

[ext_oneapi_level_zero:gpu:0] Intel(R) Level-Zero, Intel(R) Graphics [0x5693] 1.3 [1.3.25018]
[ext_oneapi_level_zero:gpu:1] Intel(R) Level-Zero, Intel(R) Graphics [0x46a6] 1.3 [1.3.25018]

The environment variable selected for a Level Zero backend, and sycl-ls only lists Level Zero devices. Success! But, if an app were to run with only this Level Zero backend filter, the application would still fail as Tony described.

To fix the problem, the device needs to be selected via the device-num. The Arc A370M has a hex code of (0x5693) so it's device-num is 0. Therefore, to run an application using only the Arc A370M requires the environment variable to be set like SYCL_DEVICE_FILTER=level_zero:0 sycl-ls. And the output of this call is:

[ext_oneapi_level_zero:gpu:0] Intel(R) Level-Zero, Intel(R) Graphics [0x5693] 1.3 [1.3.25018]

Now, SYCL applications can be run in WSL2 without using the Windows Device Manager to turn off integrated devices.

SYCL_DEVICE_FILTER=level_zero:0 ./src/mandelbrot_usm 
     Platform Name: Intel(R) Level-Zero
  Platform Version: 1.3
       Device Name: Intel(R) Graphics [0x5693]
    Max Work Group: 1024
 Max Compute Units: 128

Parallel Mandelbrot set using USM.
 Rendered image output to file: mandelbrot.png (output too large to display in text)
       Serial time: 0.0267753s
     Parallel time: 0.000552919s
Successfully computed Mandelbrot set.

Deprecation

It should be noted that SYCL_DEVICE_FILTER is deprecated. And using SYCL_DEVICE_ALLOWLIST is also deprecated, because there's a warning when you use it.

SYCL_DEVICE_ALLOWLIST=PlatformName:{{.*Level.*}} sycl-ls

WARNING: PlatformName in SYCL_DEVICE_ALLOWLIST is deprecated. Please use BackendName, DeviceType and DeviceVendorId instead. For details, please refer to https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md


WARNING: PlatformName in SYCL_DEVICE_ALLOWLIST is deprecated. Please use BackendName, DeviceType and DeviceVendorId instead. For details, please refer to https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md


WARNING: PlatformName in SYCL_DEVICE_ALLOWLIST is deprecated. Please use BackendName, DeviceType and DeviceVendorId instead. For details, please refer to https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md


WARNING: PlatformName in SYCL_DEVICE_ALLOWLIST is deprecated. Please use BackendName, DeviceType and DeviceVendorId instead. For details, please refer to https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md


WARNING: PlatformName in SYCL_DEVICE_ALLOWLIST is deprecated. Please use BackendName, DeviceType and DeviceVendorId instead. For details, please refer to https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md


WARNING: PlatformName in SYCL_DEVICE_ALLOWLIST is deprecated. Please use BackendName, DeviceType and DeviceVendorId instead. For details, please refer to https://github.com/intel/llvm/blob/sycl/sycl/doc/EnvironmentVariables.md

[ext_oneapi_level_zero:gpu:0] Intel(R) Level-Zero, Intel(R) Graphics [0x5693] 1.3 [1.3.25018]
[ext_oneapi_level_zero:gpu:1] Intel(R) Level-Zero, Intel(R) Graphics [0x46a6] 1.3 [1.3.25018]

It should be noted that DeviceVendorId doesn't work anymore.

Finally, I couldn't get ONEAPI_DEVICE_SELECTOR to work properly, so that's why I used SYCL_DEVICE_FILTER. In the future, I assume that ONEAPI_DEVICE_SELECTOR will work in WSL2.

More from this blog

It needs to be written down

59 posts