how to create do offline compilation in opencl and create its binary?

前端 未结 1 1724
失恋的感觉
失恋的感觉 2021-01-14 16:02

In online compilation of OpenCl, we have to do...

program = clCreateProgramWithSource(context, 1, (const char **)&source_str, (const size_t *)&source         


        
相关标签:
1条回答
  • 2021-01-14 16:47

    Once the program has been created you can use clGetProgramInfo with CL_PROGRAM_BINARY_SIZES and then CL_PROGRAM_BINARIES, storing the resulting binary programs (one for each device of the context) into a buffer you supply. You can then save this binary data to disk for use in later runs.

    Not all devices might support binaries, so you will need to check the CL_PROGRAM_BINARY_SIZES result (it returns a zero size for that device if binaries are not supported).

    To save time in the future (say in future runs of your application), you can use clCreateProgramWithBinary with the returned binaries. However, you will only ever want to do this with exactly the same hardware. Even when the graphics driver changes for the same hardware, you might want to throw the binary away and rebuild since there is potential the OpenCL compiler in the new driver has bugfixes and/or performance improvements.

    0 讨论(0)
提交回复
热议问题