#define CL_HPP_MINIMUM_OPENCL_VERSION 120 #define CL_HPP_TARGET_OPENCL_VERSION 120 #include #include #include int main(int argc, char* argv[]) { QCoreApplication a(argc, argv); //std::vector all_platforms; ////std::vector all_dev; //cl::Platform::get(&all_platforms); ////cl::Device::get(&all_dev); //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()); ////cl::Program program(main_context) /// /// /// std::vector platforms; cl::Platform::get(&platforms); int platform_id = 0; int device_id = 0; qDebug() << "Number of Platforms: " << platforms.size(); for(std::vector::iterator it = platforms.begin(); it != platforms.end(); ++it) { cl::Platform platform(*it); qDebug() << "Platform ID: " << platform_id++; qDebug() << "Platform Name: " << platform.getInfo().data(); qDebug() << "Platform Vendor: " << platform.getInfo().data(); std::vector devices; platform.getDevices(CL_DEVICE_TYPE_GPU | CL_DEVICE_TYPE_CPU, &devices); for(std::vector::iterator it2 = devices.begin(); it2 != devices.end(); ++it2) { cl::Device device(*it2); qDebug() << "\tDevice " << device_id++ << ": "; qDebug() << "\t\tDevice Name: " << device.getInfo().data(); qDebug() << "\t\tDevice Vendor: " << device.getInfo().data(); qDebug() << "\t\tDevice Version: " << device.getInfo().data(); switch(device.getInfo()) { case 4: qDebug() << "\t\tDevice Type: GPU"; break; case 2: qDebug() << "\t\tDevice Type: CPU"; break; default: qDebug() << "\t\tDevice Type: unknown"; } qDebug() << "\t\tDevice Max Compute Units: " << device.getInfo(); qDebug() << "\t\tDevice Global Memory: " << device.getInfo(); qDebug() << "\t\tDevice Max Clock Frequency: " << device.getInfo(); qDebug() << "\t\tDevice Max Memory Allocation: " << device.getInfo(); qDebug() << "\t\tDevice Local Memory: " << device.getInfo(); qDebug() << "\t\tDevice Available: " << device.getInfo(); } qDebug(); } return a.exec(); }