I'm struggling saving/loading binary-kernels: If i build from source, the program runs fine. But if i write and load the kernel to binary. I get CL_INVALID_COMMAND_QUEUE calling m_prog.getCommandQueues()[iDevice].enqueueNDRangeKernel. My Platform is in both cases (from binary, from source) Intel and my device is in both cases my CPU.
Maybe helpful additional information:
No exceptions are thrown before CL_INVALID_COMMAND_QUEUE ( with __CL_ENABLE_EXCEPTIONS defined)
program ref count 1
program num devs 1
program num devs 1
program build status for device CL_BUILD_SUCCES
program build log
Device build started
Device build done
Reload Program Binary Object.
.
/// write binaries to file
std::ofstream bfile(filenameGenerator(m_platform, fileName), std::ios::binary);
if (!bfile) return IT_CL_FILE_NOT_FOUND;
std::vector<size_t> sizes = m_prog.getInfo<CL_PROGRAM_BINARY_SIZES>();
std::vector<char*> binaries = m_prog.getInfo<CL_PROGRAM_BINARIES>();
bfile.write((char*)&sizes[0], sizeof(size_t));
bfile.write(binaries[0], sizes[0]);
delete[] binaries[0];
/// ... somewhere else ...
///read binaries from file
ifstream bfile(filenameGenerator(platform, fileName), std::ios::binary);
size_t n;
std::vector<char> buf;
bfile.read((char*)&n, sizeof(size_t));
buf.resize(n);
bfile.read(buf.data(), n);
m_prog = cl::Program(context, devs, cl::Program::Binaries(
1, std::make_pair(static_cast<const void*>(buf.data()), n)));
m_prog.build(devs);
/// later ...
m_prog.getCommandQueues()[iDevice].enqueueNDRangeKernel ///throws
EDIT: added the last two lines of code, to clearify the calling order