cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

FangQ
Adept I

macro to enable printf debug in a cl kernel

I am trying to debug an OpenCL kernel translated from a CUDA code. In the CUDA code, I defined a macro:

#ifdef __DEVICE_EMULATION__
#define GPUDEBUG(x)        printf x
#else
#define GPUDEBUG(x)
#endif

to enable printing under device emulation mode. When I ran the translated unit on ATI stream sdk, I can not find a macro similar to "__DEVICE_EMULATION__".

printf does work when using CPU device, but will crash for GPU devices.

I am curious if there is such a macro so that I can keep my debug approach. Or if there is an alternative?

thank you

0 Likes
9 Replies
nou
Exemplar

you can define it manualy.

clBuildProgram(prog, NULL, NULL, "-D __DEVICE_EMULATION__", NULL, NULL);

0 Likes

Originally posted by: nou you can define it manualy.

 

clBuildProgram(prog, NULL, NULL, "-D __DEVICE_EMULATION__", NULL, NULL);

 

 

thank you, it works

0 Likes

I tried by defining

clBuildProgram(prog, NULL, NULL, "-D __DEVICE_EMULATION__", NULL, NULL);

in host app and

#ifdef __DEVICE_EMULATION__
#define GPUDEBUG(x)        printf x
#else
#define GPUDEBUG(x)
#endif

in kernel.

I am unable to Build because of this.

error: expected a ";"
 GPUDEBUG("Hello  Print \n");

and  warning: expression has no effect
  GPUDEBUG("Hello Print\n");

Please let me know for any modifications needed. i am working in ATI GPU HD 4350.

 

0 Likes

try this #define GPUDEBUG(x)        printf(x)

0 Likes

nou,

I tried but its not building.have you tried in ATI Radeon GPU. I am working on RV710.

0 Likes

printf is working only on CPU device.

0 Likes

But Mr FangQ says its working in above messages.I guess he tested in ATI Radeon only.

0 Likes

Pavan,

printf is not supported in GPU.

0 Likes

Hi Omkar,

Thanks for the conclusion.

 

0 Likes