Is there any means to print values from within OpenCL C code? ... for debugging.
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.
Thank you for the post. This was very valuable for me.
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.
It should works. it wont work if you debugging using codexl.
you just remove printf statement from kernel before debugging using CodeXL
Retrieving data ...