在Xcode下以递归方式包含OpenCL源中的文件 [英] Recursive include of files in OpenCL source under Xcode

查看:126
本文介绍了在Xcode下以递归方式包含OpenCL源中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个可以在我的GPU设备上运行的调用OpenCL代码的主机程序. cl源具有以下形式:

I'm looking to build a host program calling OpenCL code running on my GPU device. The cl source has the following form:

#include "skip_mwc.cl"
typedef struct{ uint x; uint c; } mwc64x_state_t;
//blah...

如果我放弃了#include指令并复制/粘贴了"skip_mwc.cl"的内容,直接在此来源中,我可以部分构建"并至少得到一些错误,表明我的编译器(clang9 cl编译器)至少可以识别内核代码.使用#include方法时,出现以下错误:

If I get rid of the #include directive and copy/paste the content of "skip_mwc.cl" directly into this source, I can partially "build" and at least get some errors, showing that my compiler (clang9 cl compiler) can at least recognize the kernels code. With the #include approach I get the following error:

Build log::
<program source>:9:10: fatal error: 'skip_mwc.cl' file not found
#include "skip_mwc.cl"

我已经检查过,并且文件在搜索路径中,所以我倾向于认为我的Xcode IDE不能正确索引.cl文件来执行自动文件包含(如.c或.cpp).

I have checked and the file is there in the search paths, so I'm inclined to believe that my Xcode IDE doesn't index .cl files properly to perform automatic file inclusion (as in .c or .cpp).

我真的想避免不得不将源文件从一个文件复制/粘贴到另一个文件中.非常欢迎和需要来自熟悉Xcode的人的任何建议,他们遇到了这个问题并设法解决了这个问题.

I really want to avoid having to copy/paste source from one file into the other. Any suggestions from someone familiar with Xcode, who has encountered this problem and managed to solve it, are very welcome and needed.

谢谢, A

推荐答案

两种可能的解决方案:

  1. clBuildProgram()中设置-I include_dir编译器选项,另请参见此答案.
  2. 使用fstream从C ++读取两个文件,并将它们的内容字符串连接.
  1. Set the -I include_dir compiler option in clBuildProgram(), see also this answer.
  2. Read both files from C++ with fstream and string-concatenate their content.

另请参见通过字符串化宏将OpenCL代码嵌入可执行文件的选项.

Also see the option of embedding the OpenCL code into the executable via stringification macro.

这篇关于在Xcode下以递归方式包含OpenCL源中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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