MCPcopy Create free account
hub / github.com/GollyGang/ready / BuildProgram

Method BuildProgram

src/readybase/OpenCLImageRD.cpp:48–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46// ----------------------------------------------------------------------------------------------------------------
47
48void OpenCLImageRD::BuildProgram()
49{
50 // create the program
51 this->kernel_source = this->AssembleKernelSourceFromFormula(this->formula);
52 const char* source = this->kernel_source.c_str();
53 size_t source_size = this->kernel_source.length();
54 clReleaseProgram(this->program);
55 cl_int ret;
56 this->program = clCreateProgramWithSource(this->context, 1, &source, &source_size, &ret);
57 throwOnError(ret, "OpenCLImageRD::ReloadKernelIfNeeded : Failed to create program with source: ");
58
59 // build the program
60 ret = clBuildProgram(this->program, 1, &this->device_id, "-cl-denorms-are-zero", NULL, NULL);
61 if (ret != CL_SUCCESS)
62 {
63 size_t build_log_length = 0;
64 cl_int ret2 = clGetProgramBuildInfo(this->program, this->device_id, CL_PROGRAM_BUILD_LOG, 0, 0, &build_log_length);
65 throwOnError(ret2, "OpenCLImageRD::ReloadKernelIfNeeded : retrieving length of program build log failed: ");
66 vector<char> build_log(build_log_length);
67 cl_int ret3 = clGetProgramBuildInfo(this->program, this->device_id, CL_PROGRAM_BUILD_LOG, build_log_length, build_log.data(), 0);
68 throwOnError(ret3, "OpenCLImageRD::ReloadKernelIfNeeded : retrieving program build log failed: ");
69 { ofstream out("kernel.txt"); out << kernel_source; }
70 ostringstream oss;
71 oss << "OpenCLImageRD::ReloadKernelIfNeeded : build failed (kernel saved as kernel.txt):\n\n" << string(build_log.begin(), build_log.end());
72 throwOnError(ret, oss.str().c_str());
73 }
74}
75
76// ----------------------------------------------------------------------------------------------------------------
77

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected