/*! \brief Builds this Program. * * Do not forget to load Kernel objects into this * Program before executing this function. * This Program with all Kernel objects are built. Note that * compiling and linking in seperate stages are note supported * yet. Kernels built with this Program * can be executed on all Device objects within the Context * for which this Program is built. */ void ocl::Program::build() { TRUE_ASSERT(this->_context != 0, "Program has no Context"); TRUE_ASSERT(this->_id == 0, "Program already built"); TRUE_ASSERT(!_kernels.empty(), "No kernels loaded for the program"); std::stringstream stream; this->print(stream); const std::string &t = stream.str(); cl_int status; const char * file_char = t.c_str(); // stream.str().c_str(); _id = clCreateProgramWithSource(this->context().id(), 1, (const char**)&file_char, NULL, &status); OPENCL_SAFE_CALL(status); cl_int buildErr = clBuildProgram(_id, 0, NULL, _options().c_str(), NULL, NULL); checkBuild(buildErr); for(auto k : _kernels){ k.second->create(); } }
/*! \brief Builds this Program. * * Do not forget to load Kernel objects into this * Program before executing this function. * This Program with all Kernel objects are built. Note that * compiling and linking in seperate stages are note supported * yet. Kernels built with this Program * can be executed on all Device objects within the Context * for which this Program is built. */ void ocl::Program::build() { if(this->_context == 0)throw std::runtime_error( "Program has no Context"); if(this->_id != 0) throw std::runtime_error( "Program already built"); if(_kernels.empty()) throw std::runtime_error( "No kernels loaded for the program"); std::stringstream stream; this->print(stream); std::string t = stream.str(); // std::cout << t << std::endl; cl_int status; const char * file_char = t.c_str(); // stream.str().c_str(); _id = clCreateProgramWithSource(this->context().id(), 1, (const char**)&file_char, NULL, &status); OPENCL_SAFE_CALL(status); cl_int buildErr = clBuildProgram(_id, 0, NULL, _options().c_str(), NULL, NULL); checkBuild(buildErr); for(auto& k : _kernels){ k->create(); } }