codelets是否可以引用其他文件中的代码,如头文件?
如果我有一个codelet文件
//FileA.cpp
#include "FileB.h"
class SomeCustomVertex : public Vertex {
public:
bool compute() {
int a = SomeConstantDefinedInFileB;
}
...
}和一些其他的"codelet“文件
//FileB.h
const int SomeConstantDefineInFileB = 42;在主机图形程序中:
graph.addCodelets({"codelets/FileA.cpp", "codelets/FileB.h"});我从popc得到一个编译错误
fatal error: 'FileB.h' file not found
#include "FileB.h"
^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
terminate called after throwing an instance of 'poplar::graph_program_compilation_error'
what(): Codelet compilation failed (see compiler output for details)发布于 2021-01-25 23:32:23
我想通了。
Graph::addCodelets有一个参数StringRef compileFlags = "",您可以用它来注入编译器选项。
popc --help显示一个选项
-I arg Add directory to include search path因此,当我在主机程序中使用graph.addCodelets({"codelets/FileA.cpp"}, "-I codelets");,并将我的codelets放在'codelets‘子目录中时,这是有效的。不需要在参数中显式列出".h“文件。
顺便说一句,这也是确保定制代码集的编译器优化(-O3)的好方法。
https://stackoverflow.com/questions/65887644
复制相似问题