Print out OpenCL device version for chosen device in output header

Resolves #4
This commit is contained in:
Tom Deakin 2015-09-24 11:49:08 +01:00
parent cecddb146b
commit e608ec2909

View File

@ -49,6 +49,7 @@
#include "common.h" #include "common.h"
std::string getDeviceName(const cl::Device& device); std::string getDeviceName(const cl::Device& device);
std::string getDeviceDriver(const cl::Device& device);
unsigned getDeviceList(std::vector<cl::Device>& devices); unsigned getDeviceList(std::vector<cl::Device>& devices);
@ -163,6 +164,10 @@ int main(int argc, char *argv[])
std::string name = getDeviceName(device); std::string name = getDeviceName(device);
std::cout << "Using OpenCL device " << name << std::endl; std::cout << "Using OpenCL device " << name << std::endl;
// Print out OpenCL driver version for this device
std::string driver = getDeviceDriver(device);
std::cout << "Driver: " << driver << std::endl;
// Check device can do double precision if requested // Check device can do double precision if requested
if (!useFloat && !device.getInfo<CL_DEVICE_DOUBLE_FP_CONFIG>()) if (!useFloat && !device.getInfo<CL_DEVICE_DOUBLE_FP_CONFIG>())
throw std::runtime_error("Device does not support double precision, please use --float"); throw std::runtime_error("Device does not support double precision, please use --float");
@ -442,6 +447,22 @@ std::string getDeviceName(const cl::Device& device)
return name; return name;
} }
std::string getDeviceDriver(const cl::Device& device)
{
std::string driver;
try
{
device.getInfo(CL_DRIVER_VERSION, &driver);
}
catch (cl::Error &e)
{
die("Getting device driver", e);
}
return driver;
}
void listDevices(void) void listDevices(void)
{ {
// Get list of devices // Get list of devices