OpenCL compiler preprocessing definitions?
I am developing OpenCL code on Snow Leopard and I understand that OpenCL compilation is instantly done by Clang / LLVM. Is the C preprocessor used at all? Is there a way to set preprocessing definitions in the compiler? What are the definitions?
I would like the code to know if it is compiled for CPU or GPU, so I can, for example, use printf commands to debug.
+2
source to share
2 answers
You can also use the OpenCL preprocessor to define definitions (for example in C):
#define dot3(x1, y1, z1, x2, y2, z2) ((x1)*(x2) + (y1)*(y2) + (z1)*(z2))
(note the parentheses, they are important because you can put any expression in variables and the expression is evaluated correctly)
This helps to improve the speed of your application.
+1
source to share