// // Created by root on 4/27/21. // #include "gpu_svo/cl_class.h" opencl::opencl() { std::vector all_platforms; cl::Platform::get(&all_platforms); if (all_platforms.size() == 0){ std::cerr << " No platforms found. Check OpenCL installation!\n"; exit(1); } //get default device of the default platform std::vector all_devices; for(auto i:all_platforms){ std::cout << "Find platform number:"<< i.getInfo() << "\n"; i.getDevices(CL_DEVICE_TYPE_GPU, &all_devices); } if (all_devices.size() == 0){ std::cout << " No devices found. Check OpenCL installation!\n"; exit(1); } device = all_devices[0]; std::cout << "CL_DEVICE_NAME: " << device.getInfo() <<'\n' << "CL_DEVICE_OPENCL_C_VERSION: " <()<<'\n' << "CL_DEVICE_BUILT_IN_KERNELS: " <()<<'\n' << "CL_DEVICE_COMPILER_AVAILABLE: " <()<<'\n' << "CL_DEVICE_LOCAL_MEM_SIZE: " <()<<'\n' << "CL_DEVICE_GLOBAL_MEM_SIZE: " <()<<'\n'; context=new cl::Context({ device }); cl::Program::Sources sources; read_cl fast(std::string(KERNEL_DIR)+"/fast-gray.cl"); sources.push_back({ fast.src_str, fast.size }); program=new cl::Program(*context, sources); if(program->build({ device },"-DFAST_THRESH=40") !=0) std::cout << " Error building: " << program->getBuildInfo(device)<<'\n' <getBuildInfo(device) << '\n'; queue=new cl::CommandQueue(*context,device,0,NULL); } opencl::~opencl() { } void opencl::clear_buf() { queue->finish(); queue->flush(); _kernels.clear(); }