开发者

OpenCL build program from binary

开发者 https://www.devze.com 2023-01-05 03:52 出处:网络
I\'m trying to test the OpenCL functionality of building a program from pre-compiled binaries. So far I\'ve managed to create the binary file, but I\'m having trouble to load it. I\'m trying to adapt

I'm trying to test the OpenCL functionality of building a program from pre-compiled binaries. So far I've managed to create the binary file, but I'm having trouble to load it. I'm trying to adapt this code for use with the C++ bindings:

FILE* fp = fopen("oclLLtoUTM.ptx", "r");
fseek (fp , 0 , SEEK_END);
const size_t lSize = ftell(fp);
rewind(fp);
unsigned char* buffer;
buffer = (unsigned char*) malloc (lSize);
fread(buffer, 1, lSize, fp);
fclose(fp);

cl_int status;
cpProgram = clCreateProgramWithBinary(cxGPUContext, 1, (const cl_device_id *)cdDevices,
&lSize, (const unsigned char**)&buffer,
&status, &ciErr1);

if (ciErr1 != CL_SUCCESS)
{
cout<<"Error in clCreateProgramWithBinary, Line "<<__LINE__<<" in file "<<__FILE__<<" "<<endl;
Cleanup(EXIT_FAILURE);
}

ciErr1 = clBuildProgram(cpProgram, 0, NULL, NULL, NULL, NULL);

Can 开发者_如何学Canyone give me a hand with this, or suggest a link where i can find it solved (I need to use C++ bindings)?

Thanks in advance!

0

精彩评论

暂无评论...
验证码 换一张
取 消