【发布时间】:2015-04-07 20:59:22
【问题描述】:
我目前正在从事一个关于 OpenCL 的项目,在尝试构建该程序时遇到了一些麻烦。所以我有以下代码:
//Read source file
std::ifstream sourceFile("calculation_kernel.cl");
std::string sourceCode(std::istreambuf_iterator<char>(sourceFile), (std::istreambuf_iterator<char>()));
cl::Program::Sources source(1, std::make_pair(sourceCode.c_str(), sourceCode.length()+1));
if (sourceFile.is_open()){
printf("the file is open\n");
}else{
printf("error opening file\n");
}
// Make program of the source code in the context
cl::Program program = cl::Program(context, source);
// Build program for these specific devices
program.build(devices);
代码编译得很好,但是当我尝试运行它时会得到一个 clBuildProgram(-11) 错误。我已经验证我的内核文件可以成功打开。 我在这里错过了什么吗?或者有没有办法调试这个错误?
提前致谢!
【问题讨论】: