You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

92 lines
3.0 KiB

#define CL_HPP_MINIMUM_OPENCL_VERSION 120
#define CL_HPP_TARGET_OPENCL_VERSION 120
#include <QCoreApplication>
#include <CL/cl2.hpp>
#include <QDebug>
int main(int argc, char* argv[])
{
QCoreApplication a(argc, argv);
//std::vector<cl::Platform> all_platforms;
////std::vector<cl::Device> 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<CL_PLATFORM_NAME>().data();
//}
//std::vector<cl::Device> all_devices;
//all_platforms.front().getDevices(CL_DEVICE_TYPE_GPU, &all_devices);
//foreach(auto device, all_devices)
//{
//qDebug() << device.getInfo<CL_DEVICE_NAME>().data();
//}
////cl::Context main_context(all_devices.front());
////cl::Program program(main_context)
///
///
///
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
int platform_id = 0;
int device_id = 0;
qDebug() << "Number of Platforms: " << platforms.size();
for(std::vector<cl::Platform>::iterator it = platforms.begin(); it != platforms.end(); ++it)
{
cl::Platform platform(*it);
qDebug() << "Platform ID: " << platform_id++;
qDebug() << "Platform Name: " << platform.getInfo<CL_PLATFORM_NAME>().data();
qDebug() << "Platform Vendor: " << platform.getInfo<CL_PLATFORM_VENDOR>().data();
std::vector<cl::Device> devices;
platform.getDevices(CL_DEVICE_TYPE_GPU | CL_DEVICE_TYPE_CPU, &devices);
for(std::vector<cl::Device>::iterator it2 = devices.begin(); it2 != devices.end(); ++it2)
{
cl::Device device(*it2);
qDebug() << "\tDevice " << device_id++ << ": ";
qDebug() << "\t\tDevice Name: " << device.getInfo<CL_DEVICE_NAME>().data();
qDebug() << "\t\tDevice Vendor: " << device.getInfo<CL_DEVICE_VENDOR>().data();
qDebug() << "\t\tDevice Version: " << device.getInfo<CL_DEVICE_VERSION>().data();
switch(device.getInfo<CL_DEVICE_TYPE>())
{
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<CL_DEVICE_MAX_COMPUTE_UNITS>();
qDebug() << "\t\tDevice Global Memory: " << device.getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>();
qDebug() << "\t\tDevice Max Clock Frequency: " <<
device.getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>();
qDebug() << "\t\tDevice Max Memory Allocation: " <<
device.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>();
qDebug() << "\t\tDevice Local Memory: " << device.getInfo<CL_DEVICE_LOCAL_MEM_SIZE>();
qDebug() << "\t\tDevice Available: " << device.getInfo<CL_DEVICE_AVAILABLE>();
}
qDebug();
}
return a.exec();
}