From e608ec2909d2936c88a05acc684572300ac32782 Mon Sep 17 00:00:00 2001 From: Tom Deakin Date: Thu, 24 Sep 2015 11:49:08 +0100 Subject: [PATCH] Print out OpenCL device version for chosen device in output header Resolves #4 --- ocl-stream.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ocl-stream.cpp b/ocl-stream.cpp index 819ec9d..1a46295 100644 --- a/ocl-stream.cpp +++ b/ocl-stream.cpp @@ -49,6 +49,7 @@ #include "common.h" std::string getDeviceName(const cl::Device& device); +std::string getDeviceDriver(const cl::Device& device); unsigned getDeviceList(std::vector& devices); @@ -163,6 +164,10 @@ int main(int argc, char *argv[]) std::string name = getDeviceName(device); 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 if (!useFloat && !device.getInfo()) 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; } +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) { // Get list of devices