AnsweredAssumed Answered

printf() misbehave?

Question asked by Raistmer on Feb 24, 2013
Latest reply on Mar 3, 2013 by himanshu.gautam



I want to check correctness of one of kernels so trying to print debug info from it:



__kernel void GPU_fetch_array_kernel_cl(__global float* src, __global int* offsets, __global int* f_int, __global float4* dest,

                    const uint offset, const uint stride){

          uint threadID=get_global_id(0)+offset;

          uint j=get_global_id(1);

          int k=0;

          int l=0;

          float4 acc=(float4)0.f;

          int n_per=f_int[threadID];



                              l+=(4*j);//R: index to data array computed





#if 1








to ensure that printf() allowed I used next line near beginning of CL file:



#pragma OPENCL EXTENSION cl_amd_printf : enable



but then no debug info from kernel printed and app crashes on this buffer read:



err=clEnqueueReadBuffer(cq, gpu_results,CL_TRUE,0,sizeof(cl_uint),&CPU_result,0, NULL, NULL);OCL_LOG_ERR("clEnqueueReadBuffer->CPU_result");



When I comment out extension enabling, that is:



//#pragma OPENCL EXTENSION cl_amd_printf : enable



debug info from kernel starts printing (!). And no compilation error on printf line.

Also, no crash on later buffer reading.

Why so? Why "legal" extension enabling leads to crash while illegal usage of printf from kernel works just OK ?