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

Tags (2)
0 Likes
4 Replies
Steveyoungs
Journeyman III

Printf in OpenCL?

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
divij
Journeyman III

Printf in OpenCL?

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

0 Likes
ndv
Journeyman III

Re: Printf in OpenCL?

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
scharupa
Staff
Staff

Re: Printf in OpenCL?

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

you just remove printf statement from kernel before debugging using CodeXL

0 Likes