| 217 | } |
| 218 | |
| 219 | bool init_program(const char* pSrc, size_t src_size) |
| 220 | { |
| 221 | cl_int ret; |
| 222 | |
| 223 | if (m_program != nullptr) |
| 224 | { |
| 225 | clReleaseProgram(m_program); |
| 226 | m_program = nullptr; |
| 227 | } |
| 228 | |
| 229 | m_program = clCreateProgramWithSource(m_context, 1, (const char**)&pSrc, (const size_t*)&src_size, &ret); |
| 230 | if (ret != CL_SUCCESS) |
| 231 | { |
| 232 | ocl_error_printf("ocl::init_program: clCreateProgramWithSource() failed!\n"); |
| 233 | return false; |
| 234 | } |
| 235 | |
| 236 | std::string options; |
| 237 | if (m_dev_fp_config & CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT) |
| 238 | { |
| 239 | options += "-cl-fp32-correctly-rounded-divide-sqrt"; |
| 240 | } |
| 241 | |
| 242 | options += " -cl-std=CL1.2"; |
| 243 | //options += " -cl-opt-disable"; |
| 244 | //options += " -cl-mad-enable"; |
| 245 | //options += " -cl-fast-relaxed-math"; |
| 246 | |
| 247 | ret = clBuildProgram(m_program, 1, &m_device_id, |
| 248 | options.size() ? options.c_str() : nullptr, // options |
| 249 | nullptr, // notify |
| 250 | nullptr); // user_data |
| 251 | |
| 252 | if (ret != CL_SUCCESS) |
| 253 | { |
| 254 | const cl_int build_program_result = ret; |
| 255 | |
| 256 | size_t ret_val_size; |
| 257 | ret = clGetProgramBuildInfo(m_program, m_device_id, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); |
| 258 | if (ret != CL_SUCCESS) |
| 259 | { |
| 260 | ocl_error_printf("ocl::init_program: clGetProgramBuildInfo() failed!\n"); |
| 261 | return false; |
| 262 | } |
| 263 | |
| 264 | std::vector<char> build_log(ret_val_size + 1); |
| 265 | |
| 266 | ret = clGetProgramBuildInfo(m_program, m_device_id, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log.data(), NULL); |
| 267 | |
| 268 | ocl_error_printf("\nclBuildProgram() failed with error %i:\n%s", build_program_result, build_log.data()); |
| 269 | |
| 270 | return false; |
| 271 | } |
| 272 | |
| 273 | return true; |
| 274 | } |
| 275 | |
| 276 | cl_kernel create_kernel(const char* pName) |
no test coverage detected