Display CUDA driver version in output header

This mimics the OpenCL change in issue #4.
This commit is contained in:
Tom Deakin 2015-09-24 12:03:44 +01:00
parent e608ec2909
commit 70330c7b9b

View File

@ -46,6 +46,7 @@
#include "common.h" #include "common.h"
std::string getDeviceName(int device); std::string getDeviceName(int device);
int getDriver(void);
// Code to check CUDA errors // Code to check CUDA errors
void check_cuda_error(void) void check_cuda_error(void)
@ -162,6 +163,9 @@ int main(int argc, char *argv[])
// Print out device name // Print out device name
std::cout << "Using CUDA device " << getDeviceName(deviceIndex) << std::endl; std::cout << "Using CUDA device " << getDeviceName(deviceIndex) << std::endl;
// Print out device CUDA driver version
std::cout << "Driver: " << getDriver() << std::endl;
// Check buffers fit on the device // Check buffers fit on the device
cudaDeviceProp props; cudaDeviceProp props;
cudaGetDeviceProperties(&props, deviceIndex); cudaGetDeviceProperties(&props, deviceIndex);
@ -358,6 +362,14 @@ std::string getDeviceName(int device)
return std::string(prop.name); return std::string(prop.name);
} }
int getDriver(void)
{
int driver;
cudaDriverGetVersion(&driver);
check_cuda_error();
return driver;
}
void listDevices(void) void listDevices(void)
{ {
// Get number of devices // Get number of devices