OpenCL: How to check for build errors using the C++ wrapper -


if build opencl program source code this

cl::program program = cl::program(context, sourcecode); program.build(devices); 

i check if successful. saw few examples of how in c, since project ist in c++ wondering how (in case goes wrong) readable text message indicates might issue using c++ wrapper.

i have enabled exceptions

#define cl_hpp_enable_exceptions  

but not know if build(...) throws exception.

i using amd app sdk 3.0 , cl2.hpp khronos webpage (as not included in sdk).

the cl::program::build() function indeed throw exception if build fails. here's how can build log:

cl::program program = cl::program(context, sourcecode); try {   program.build(devices); } catch (cl::error& e) {   if (e.err() == cl_build_program_failure)   {     (cl::device dev : devices)     {       // check build status       cl_build_status status = program.getbuildinfo<cl_program_build_status>(dev);       if (status != cl_build_error)         continue;        // build log       std::string name     = dev.getinfo<cl_device_name>();       std::string buildlog = program.getbuildinfo<cl_program_build_log>(dev);       std::cerr << "build log " << name << ":" << std::endl                 << buildlog << std::endl;   }   else   {     throw e;   } } 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -