To debug my OpenCL kernel,
I used "Debugging CPU Kernels with GDB" method as explained in OpenCL Programming Guide book by making two changes in the program
1. CL_DEVICE_TYPE_GPU to CL_DEVICE_TYPE_CPU to ensure that program is executed on CPU.
2. compiled the kernel by setting compiler option parameter of clBuildProgram() as option="-g -O0".
Debugging went successfully on CPU and i got correct result as well.
After changing the device type from CPU to GPU, my result was still correct.
But when i changed the compiler option=NULL and device type was even GPU, I got wrong result for fewer inputs. Again when I set the compiler option="-g -O0" and device type was GPU, i got the correct result for all the input.
So I want to know,
1. what actually happens when OpenCL kernels are built with -g option?
2. Why I am getting wrong results for fewer inputs when i remove -g option from clBuildProgram?