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.
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.