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
sycl::queue { [](sycl::device dev) {
return "xilinx_u200_gen3x16_xdma_1_202110_1" == dev.template get_info<sycl::info::device::name>();
} };
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
sycl::queue { [](sycl::device dev) {
return ("xilinx_u200_gen3x16_xdma_1_202110_1" == dev.template get_info<sycl::info::device::name>()) - 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.
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
sycl::queue { [](sycl::device dev) { return "xilinx_u200_gen3x16_xdma_1_202110_1" == dev.template get_info<sycl::info::device::name>(); } };and to throw if there is no such device.
The problem is that in this code the returned
boolis converted to anint, so when the device does exist it works becausetrueis converted to1, but if it is not the case,falseis 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
sycl::queue { [](sycl::device dev) { return ("xilinx_u200_gen3x16_xdma_1_202110_1" == dev.template get_info<sycl::info::device::name>()) - 1; } };to convert
0or1to-1or0for example.Having a different behavior for the
sycl::queueconstructor with a device selector returning aboolwould be cleaner.