Fixup: fixed bug in binaries retrieval
This commit is contained in:
@@ -343,6 +343,7 @@ inline typename detail::return_type<cl_program, CL_PROGRAM_BINARIES>::Result inf
|
|||||||
std::vector<size_t> sizes = info<CL_PROGRAM_BINARY_SIZES>(handle);
|
std::vector<size_t> sizes = info<CL_PROGRAM_BINARY_SIZES>(handle);
|
||||||
for(unsigned int s: sizes)
|
for(unsigned int s: sizes)
|
||||||
res.push_back(new unsigned char[s]);
|
res.push_back(new unsigned char[s]);
|
||||||
|
clGetProgramInfo(handle, CL_PROGRAM_BINARIES, sizeof(unsigned char**), (void*)res.data(), NULL);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -107,23 +107,23 @@ Program::Program(Context const & context, std::string const & source) : backend_
|
|||||||
|
|
||||||
//Load cached program
|
//Load cached program
|
||||||
const char * build_opt = "";
|
const char * build_opt = "";
|
||||||
// if(cache_path.size())
|
if(cache_path.size())
|
||||||
// {
|
{
|
||||||
// std::ifstream cached(fname, std::ios::binary);
|
std::ifstream cached(fname, std::ios::binary);
|
||||||
// if (cached)
|
if (cached)
|
||||||
// {
|
{
|
||||||
// std::size_t len;
|
std::size_t len;
|
||||||
// std::vector<char> buffer;
|
std::vector<char> buffer;
|
||||||
// cached.read((char*)&len, sizeof(std::size_t));
|
cached.read((char*)&len, sizeof(std::size_t));
|
||||||
// buffer.resize(len);
|
buffer.resize(len);
|
||||||
// cached.read((char*)buffer.data(), std::streamsize(len));
|
cached.read((char*)buffer.data(), std::streamsize(len));
|
||||||
// char* cbuffer = buffer.data();
|
char* cbuffer = buffer.data();
|
||||||
// h_.cl() = clCreateProgramWithBinary(context_.h_.cl(), devices.size(), devices.data(), &len, (const unsigned char **)&cbuffer, NULL, &err);
|
h_.cl() = clCreateProgramWithBinary(context_.h_.cl(), devices.size(), devices.data(), &len, (const unsigned char **)&cbuffer, NULL, &err);
|
||||||
// ocl::check(err);
|
ocl::check(err);
|
||||||
// ocl::check(clBuildProgram(h_.cl(), devices.size(), devices.data(), build_opt, NULL, NULL));
|
ocl::check(clBuildProgram(h_.cl(), devices.size(), devices.data(), build_opt, NULL, NULL));
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
std::size_t srclen = source.size();
|
std::size_t srclen = source.size();
|
||||||
const char * csrc = source.c_str();
|
const char * csrc = source.c_str();
|
||||||
@@ -147,6 +147,8 @@ Program::Program(Context const & context, std::string const & source) : backend_
|
|||||||
cached.write((char*)&sizes[0], sizeof(std::size_t));
|
cached.write((char*)&sizes[0], sizeof(std::size_t));
|
||||||
std::vector<unsigned char*> binaries = ocl::info<CL_PROGRAM_BINARIES>(h_.cl());
|
std::vector<unsigned char*> binaries = ocl::info<CL_PROGRAM_BINARIES>(h_.cl());
|
||||||
cached.write((char*)binaries[0], std::streamsize(sizes[0]));
|
cached.write((char*)binaries[0], std::streamsize(sizes[0]));
|
||||||
|
for(unsigned char * ptr: binaries)
|
||||||
|
delete[] ptr;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user