Builds the program with \p options. If the program fails to compile, this function will throw an opencl_error exception. \code try { // attempt to compile to program program.build(); } catch(boost::compute::opencl_error &e){ // program failed to compile, print out the build log std::cout << program.build_log() << std::endl; } \endcode \see_opencl_ref{clBuildProgram}
| 254 | /// |
| 255 | /// \see_opencl_ref{clBuildProgram} |
| 256 | void build(const std::string &options = std::string()) |
| 257 | { |
| 258 | const char *options_string = 0; |
| 259 | |
| 260 | if(!options.empty()){ |
| 261 | options_string = options.c_str(); |
| 262 | } |
| 263 | |
| 264 | cl_int ret = clBuildProgram(m_program, 0, 0, options_string, 0, 0); |
| 265 | |
| 266 | #ifdef BOOST_COMPUTE_DEBUG_KERNEL_COMPILATION |
| 267 | if(ret != CL_SUCCESS){ |
| 268 | // print the error, source code and build log |
| 269 | std::cerr << "Boost.Compute: " |
| 270 | << "kernel compilation failed (" << ret << ")\n" |
| 271 | << "--- source ---\n" |
| 272 | << source() |
| 273 | << "\n--- build log ---\n" |
| 274 | << build_log() |
| 275 | << std::endl; |
| 276 | } |
| 277 | #endif |
| 278 | |
| 279 | if(ret != CL_SUCCESS){ |
| 280 | BOOST_THROW_EXCEPTION(program_build_failure(ret, build_log())); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | #if defined(BOOST_COMPUTE_CL_VERSION_1_2) || defined(BOOST_COMPUTE_DOXYGEN_INVOKED) |
| 285 | /// Compiles the program with \p options. |