OpenCL编译器预处理定义? [英] OpenCL compiler preprocessing definitions?
问题描述
我正在Snow Leopard上开发OpenCL代码,并且了解OpenCL即时编译是由Clang/LLVM完成的.是否完全使用了C预处理器?有没有办法用编译器设置预处理定义?存在哪些定义?
I am developing OpenCL code on Snow Leopard and understand that the OpenCL just-in-time compilation is done by Clang/LLVM. Is the C preprocessor used at all? Is there a way to set preprocessing definitions with the compiler? What definitions exist?
我希望代码知道它是针对CPU还是GPU编译的,因此例如可以使用printf语句进行调试.
I would like the code to be aware of whether it is compiled for CPU or GPU so I for instance can use printf statements for debugging.
推荐答案
clBuildProgram
API使用编译器参数(const char * options
参数).
the clBuildProgram
API takes compiler arguments (the const char * options
parameter).
-D MYMACRO
被理解,-D MYMACRO=value
也被理解.
-D MYMACRO
is understood, so is -D MYMACRO=value
.
关于哪些预定义的宏,请参见OpenCL规范以获取完整列表(第6.9节).非详尽清单:
As to what predefined macros, see the OpenCL specification for a full list (Section 6.9). A non exhaustive list:
-
__FILE__
-
__LINE__
-
__OPENCL_VERSION__
__FILE__
__LINE__
__OPENCL_VERSION__
这篇关于OpenCL编译器预处理定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!