Skip to content

Draft: rusticl: implement RUSTICL_DEVICE_ENABLE

Thomas Debesse requested to merge illwieckz/mesa:rusticl_device_enable into main

See !18934 (closed) (clover: implement CLOVER_DEVICE_ENABLE like AMD APP's GPU_DEVICE_ORDINAL) for detailed explanations about the feature, the purpose, why it is named this way, and why the environment variable name differs between Clover and rusticl.

So this implements the RUSTICL_DEVICE_ENABLE environment variable like the proposed CLOVER_DEVICE_ENABLE one.

This is the first time in my life I write rust code, so I expect this to be a cargo cult festival and to be wrong in many ways.

Something I know to be wrong is that I convert an unsigned number to an signed one as I use [-1] as a trick to make the difference between an empty list (no or empty RUSTICL_DEVICE_ENABLE, meaning all devices should be listed) and an invalid list (RUSTICL_DEVICE_ENABLE only containing invalid values, meaning no device should be listed). It means if we have more devices than the max of unsigned int, some will not be listed. I'm not sure that's a big issue because that means a crazy amount of devices.

Here are some examples of usage, running on a branch merging this MR, !18934 (closed) and rusticl/wip_nv to get all features required for the demonstration:

clinfo --list
Platform #0: Clover
 +-- Device #0: AMD Radeon R9 390 Series (hawaii, LLVM 16.0.0, DRM 3.42, 5.15.0-50-generic)
 `-- Device #1: AMD Radeon HD 8500 series (oland, LLVM 16.0.0, DRM 3.42, 5.15.0-50-generic)
Platform #1: rusticl
 +-- Device #0: AMD Radeon R9 390 Series (hawaii, LLVM 16.0.0, DRM 3.42, 5.15.0-50-generic)
 `-- Device #1: AMD Radeon HD 8500 series (oland, LLVM 16.0.0, DRM 3.42, 5.15.0-50-generic)

CLOVER_DEVICE_ENABLE='0' RUSTICL_DEVICE_ENABLE='1' clinfo --list
Platform #0: Clover
 `-- Device #0: AMD Radeon R9 390 Series (hawaii, LLVM 16.0.0, DRM 3.42, 5.15.0-50-generic)
Platform #1: rusticl
 `-- Device #0: AMD Radeon HD 8500 series (oland, LLVM 16.0.0, DRM 3.42, 5.15.0-50-generic)

CLOVER_DEVICE_ENABLE='1' RUSTICL_DEVICE_ENABLE='0' clinfo --list
Platform #0: Clover
 `-- Device #0: AMD Radeon HD 8500 series (oland, LLVM 16.0.0, DRM 3.42, 5.15.0-50-generic)
Platform #1: rusticl
 `-- Device #0: AMD Radeon R9 390 Series (hawaii, LLVM 16.0.0, DRM 3.42, 5.15.0-50-generic)

CLOVER_DEVICE_ENABLE=',' RUSTICL_DEVICE_ENABLE='0,1' clinfo --list
Platform #0: rusticl
 +-- Device #0: AMD Radeon R9 390 Series (hawaii, LLVM 16.0.0, DRM 3.42, 5.15.0-50-generic)
 `-- Device #1: AMD Radeon HD 8500 series (oland, LLVM 16.0.0, DRM 3.42, 5.15.0-50-generic)
Platform #1: Clover

CLOVER_DEVICE_ENABLE='0,1' RUSTICL_DEVICE_ENABLE=',' clinfo --list
Platform #0: Clover
 +-- Device #0: AMD Radeon R9 390 Series (hawaii, LLVM 16.0.0, DRM 3.42, 5.15.0-50-generic)
 `-- Device #1: AMD Radeon HD 8500 series (oland, LLVM 16.0.0, DRM 3.42, 5.15.0-50-generic)
Platform #1: rusticl
Edited by Thomas Debesse

Merge request reports