Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*

Using printf inside kernel code

student4
Beginner
620 Views

Hi,

 

This screenshot is taken from Intel oneAPI Programming Guide(pg 44).

student4_0-1649406899056.png

 

According to the documentation, printf can be used inside the kernel code for debugging.
But when I used inside my kernel code, it shows an error 'sycl kernel cannot call undefined function'.
q.submit([&](sycl::handler& h){
h.single_task([=]() {
printf
});
});

 

Appreciate your help.

Thank you.

0 Kudos
3 Replies
QM
Employee
602 Views

That's because you are not calling the function with right syntax. printf(...) is in cl::sycl::ext::oneapi::experimental namespace, you need to specify a namespace for an external function. I would recommend using sycl::stream for the ease of use. 

0 Kudos
HemanthCH_Intel
Moderator
563 Views

Hi,


We haven't heard back from you. Could you please provide any updates on your issue?


Thanks & Regards,

Hemanth


0 Kudos
HemanthCH_Intel
Moderator
545 Views

Hi,


We assume that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Thanks & Regards,

Hemanth


0 Kudos
Reply