cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

jski
Journeyman III

Printf in OpenCL?

Is there any means to print values from within OpenCL C code?  ... for debugging.

---jski

0 Likes
4 Replies
Steveyoungs
Journeyman III

You can use printf from with the OpenCL code.

It is a vendor extension which you first need to enable within your OpenCL code.

#pragma OPENCL EXTENSION cl_amd_printf : enable

then just use printf in a similar manner to C code

The AMD Accelerated Parallel Processing OpenCL™ Programming Guide (v1.2c)  has more information in appendix A.8.5

On windows output is sent to stdout / stderr so if you have a GUI application you'll need to hook those streams or create a console window.

Steve

0 Likes

Thank you for the post. This was very valuable for me.

0 Likes

After installing CodeXL my printf stopped working in GPU. It worked before and is still working in CPU. Is there any way to change it back, or maybe revert the changes CodeXL did to may GPU? I am on Linux Mint.

0 Likes

It should works. it wont work if you debugging using codexl.

you just remove printf statement from kernel before debugging using CodeXL

0 Likes