I have following openCL kernel I want to debug. I have put some printf in it but those are not useful as work items are schedules randomly and values printed are not always right. How I can make my work items in kernel execute in serial for debugging purpose?
Following is code
__kernel
void SampleKernel( __global float4* gVtx, __global float4* gColor,
__global float4* gDst,
const int cNvtx,
const int4 cRes )
{
printf("nVertex : %d ", cNvtx);
for(int i =0 ; i < 1; i+=4)
{
printf(" %f ", gVtx[0].x);
printf(" %f ", gVtx[0].y);
printf(" %f ", gVtx[0].z);
printf(" %f ", gVtx[0].w);
}
}
I have also tried putting calls barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE);
before and after printf
but it was not useful.
Can anybody please suggest me way I can serialize work item execution so I can print and debug kernel? Or some other better way to debug OpenCL kernel. I am using RX 580 AMD GPU.