4

Hi I trying to debug OpenCL kernel code on PS3. Here is the code:

#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable

int offset() {
    return 'A' - 'a';
}

__kernel void tKernel(__global unsigned char *in, __global unsigned char *out) {    
    size_t i;
    printf(“var”);
    for (i = 0; i < 10; i++)
        out[i] = in[i] + offset();
}

In IBM OpenCL_guide.pdf in section 4.3.3 on page 18, there are describe debugging kernel with printf method. So I add the printf function to my kernel and trying test it. But OpenCL compile gave me this error:

"IBM_OpenCL_kernel.cl", line 9.15: 1506-766 (S) The universal character name "?" is not in the allowable range for an identifier.

I also have exported LD_LIBRARY_PATH variable. Can anyone have this problem?

pierre tautou
  • 777
  • 2
  • 19
  • 36

3 Answers3

8

I don't know about the IBM implementation, but printf() is a non-standard OpenCL function. On the AMD platform, you have to enable the extension through:

#pragma OPENCL EXTENSION cl_amd_printf : enable

before printf() will work. Perhaps an extension needs to be enabled on the IBM platform as well?

(Update) From this page, the possible extension name to use might be cl_intel_printf, so try:

#pragma OPENCL EXTENSION cl_intel_printf : enable
prunge
  • 20,579
  • 3
  • 71
  • 75
6

It seems that your implementation of OpenCL doesn't support printf, or maybe you are using hardware device instead of emulated one.

In my opinion you shouldn't use printf at all, it is not sharp enough tool to give answers with more complex hardware-dependent problems. Try using additional argument aka '__global float* output'. Fill it inside the kernel with something like if (something_happened) { output[get_global_id(0)] = the_value_you_need_to_debug; } this will help you diagnose any possible issue and this approach is platform independent

Lu4
  • 13,853
  • 12
  • 68
  • 122
0

printf function is not supported while building in the system. You can only use it in software and hardware emulation.

KittoMi
  • 442
  • 2
  • 16