- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How can I select host device? I need this for debug purposes.
According to documentation (https://intel.github.io/llvm-docs/doxygen/group__sycl__api__dev__sel.html#ga9fb90c16e9bfa0fbf5ae4675b51f489e), `default_selector_v` selects host device, which, if I understand correctly, is CPU without acceleration.
However, this code:
```
auto d_selector{ sycl::default_selector_v };
...
queue q(d_selector, exception_handler)
std::cout << "Running on device: "
<< q.get_device().get_info<info::device::name>() << "\n";
```
outputs this:
`Running on device: Intel(R) Graphics [0x9a60]`
I use oneAPI 2023.2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
For debugging SYCL kernels, you can use Intel Distribution for GDB. You can debug the application on CPU and GPU using gdb-oneapi.
Please refer to the below links for more references.
Please let us know if you face any issues.
Thanks and Regards,
Pendyala Sesha Srinivas
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I try to use deprecated host_selector:
`auto d_selector{ sycl::host_selector{} };`
Then I get the exception:
"No device of requested type available."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, when I use usual `cpu_selector_v`, I can debug the device code, which is a bit surprising for me as device which is chosen by cpu_selector_v clearly uses vectorization, and I thought it performs the code on OpenCL backend.
I can close the topic now, but I still would like to know if CPU-device is the same as host device (it shouldn't be, as it is noticeably faster than usual C++ scalar code), and, if not, why I still able to debug device code when it is selected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thank you for posting in Intel Communities.
>> How can I select host device? I need this for debug purposes.
"host device" typically refers to the CPU. This device is used for debugging and running code on the CPU
As per SYCL 2020, "host_selector" is deprecated. For selecting the SYCL host device, you can use default_selector_v.
In your case, default_selector_v selects an Intel Graphics device instead of the host(CPU).
The default_selector_v queries all root devices from all SYCL backends in the system, calls the device selector on each device, and selects the one that returns the highest score.
>>Ok, when I use usual `cpu_selector_v`, I can debug the device code, which is a bit surprising for me as device which is chosen by cpu_selector_v clearly uses vectorization, and I thought it performs the code on OpenCL backend.
I can close the topic now, but I still would like to know if CPU-device is the same as host device (it shouldn't be, as it is noticeably faster than usual C++ scalar code), and, if not, why I still able to debug device code when it is selected.
You can use cpu_selector_v, which should select a CPU device for execution of device code and debug purposes.
Here while you are using cpu_selector_v, your CPU device is still considered as a supported device in SYCL which has a supported backend like OpenCL.
Yes, here CPU device is considered as the host device, the CPU provides a guarantee that the device code can always be run as it is always available and can be used for debugging purposes.
You can also check which selector is taking which device and the list of devices available in the system by running the below command.
sycl-ls --verbose
Please refer to the below links for reference:
SYCL 2020 Reference Guide: https://registry.khronos.org/SYCL/specs/sycl-2020/pdf/sycl-2020.pdf
Intel oneAPI Programming Guide: https://www.intel.com/content/www/us/en/docs/oneapi/programming-guide/2023-2/device-selection.html
Data Parallel C++ by James Reinders: https://link.springer.com/book/10.1007/978-1-4842-5574-2
Please let us know if you still face any issues.
Thanks and Regards,
Pendyala Sesha Srinivas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Srinivas,
thank you for your reply.
I may be mistaken, but the SYCL 2020 standard doesn't deprecate the host device. It just doesn't require a SYCL implementation to provide it anymore.
Actually, I am not entirely satisfied with using the device selected by `cpu_selector_v` for debugging.
It remains different from the usual CPU. As far as I can see, on my system it uses an OpenCL backend, and while I can set a breakpoint in a line of code inside a kernel, the debugging capabilities I receive are limited compared to what I could get with a host device, where the code is executed as standard machine code and can be debugged as such. For instance, I cannot use step-by-step debugging.
Could you please suggest a method for debugging SYCL kernels that is as convenient as debugging on the host device?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
For debugging SYCL kernels, you can use Intel Distribution for GDB. You can debug the application on CPU and GPU using gdb-oneapi.
Please refer to the below links for more references.
Please let us know if you face any issues.
Thanks and Regards,
Pendyala Sesha Srinivas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for accepting our solution. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.
Thanks and Regards,
Pendyala Sesha Srinivas

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page