#define CL_HPP_MINIMUM_OPENCL_VERSION 120 #define CL_HPP_TARGET_OPENCL_VERSION 120 #include #include #include #include #include int main(int argc, char* argv[]) { QCoreApplication a(argc, argv); std::vector all_platforms; cl::Platform::get(&all_platforms); qDebug() << "Number of platforms found:" << all_platforms.size(); foreach(auto platform, all_platforms) { qDebug() << platform.getInfo().data(); } std::vector all_devices; all_platforms.front().getDevices(CL_DEVICE_TYPE_GPU, &all_devices); foreach(auto device, all_devices) { qDebug() << device.getInfo().data(); } cl::Context main_context(all_devices.front()); QFile cl_file("../OpenCL/test1.cl"); if(!cl_file.open(QIODevice::ReadOnly)) { qDebug() << cl_file.errorString(); } auto script = cl_file.readAll(); qDebug() << script; cl_file.close(); cl_int error; cl::Program program(main_context, script.toStdString(), CL_TRUE, &error); qDebug() << error; cl::Kernel kernel(program, "myVeryFirstFinction", &error); qDebug() << error; cl::KernelFunctor<> Functor(kernel); cl::CommandQueue queue(main_context, all_devices.front()); cl::EnqueueArgs enargs(queue, cl::NDRange(5)); Functor(enargs); return a.exec(); }