I am currently working on a project about OpenCL and ran into some troubles when I was trying to build the program. So I have the following code:
//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);
The code compiles fine, but I will get a clBuildProgram(-11) erro when I try to run it. I have verified that my kernel file can be successfully opened. Am I missing something here? Or is there a way to debug this error?
Thanks in advance!