OpenCL编译器预处理定义? [英] OpenCL compiler preprocessing definitions?

查看:142
本文介绍了OpenCL编译器预处理定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆