KhronosGroup / KhronosGroup/SYCL-Docs
Provide a user-friendly version of queue construction from a device selector callable returning a `bool`
- Dominant language
- JavaScript
- Stars
- 158
- Forks
- 80
- Avg merge
- 7d 6h
- Merged PRs (30d)
- 5
Description
There are common use cases when a user wants to use a very precise device in her code and uses for example a boolean predicate to filter the device, like
```c++
sycl::queue { [](sycl::device dev) {
return "xilinx_u200_gen3x16_xdma_1_202110_1" == dev.template get_info();
} };
```
and to throw if there is no such device.
The problem is that in this code the returned `bool` is converted to an `int`, so when the device does exist it works because `true` is converted to `1`, but if it is not the case, `false` is converted to 0, so any other existing device is then equivalent, which is surprising.
To avoid this, the code has to be changed into something like
```c++
sycl::queue { [](sycl::device dev) {
return ("xilinx_u200_gen3x16_xdma_1_202110_1" == dev.template get_info()) - 1;
} };
```
to convert `0` or `1` to `-1` or `0` for example.
Having a different behavior for the `sycl::queue` constructor with a device selector returning a `bool` would be cleaner.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the sycl::queue constructor and device selector behavior described in the issue, including how a callable returning bool is currently interpreted. Define the intended behavior for a bool-returning selector and update the relevant SYCL specification text; done means the documented construction no longer treats false as selecting an arbitrary device.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100