Implement some CUDA routines for device info

This commit is contained in:
Tom Deakin 2016-04-28 23:06:06 +01:00
parent a1cab96c57
commit d1f8cd1b48
3 changed files with 30 additions and 3 deletions

View File

@ -134,6 +134,28 @@ void CUDAStream<T>::triad()
check_error();
}
template <class T>
std::string CUDAStream<T>::getDeviceName(const int device)
{
cudaSetDevice(device);
check_error();
cudaDeviceProp props;
cudaGetDeviceProperties(&props, device);
check_error();
return std::string(props.name);
}
template <class T>
std::string CUDAStream<T>::getDeviceDriver(const int device)
{
cudaSetDevice(device);
check_error();
int driver;
cudaDriverGetVersion(&driver);
check_error();
return std::to_string(driver);
}
template class CUDAStream<float>;
template class CUDAStream<double>;

View File

@ -31,5 +31,9 @@ class CUDAStream : public Stream<T>
virtual void write_arrays(const std::vector<T>& a, const std::vector<T>& b, const std::vector<T>& c) override;
virtual void read_arrays(std::vector<T>& a, std::vector<T>& b, std::vector<T>& c) override;
static void listDevices(void);
static std::string getDeviceName(const int device);
static std::string getDeviceDriver(const int device);
};

View File

@ -2,6 +2,7 @@
#pragma once
#include <vector>
#include <string>
template <class T>
class Stream
@ -19,9 +20,9 @@ class Stream
virtual void read_arrays(std::vector<T>& a, std::vector<T>& b, std::vector<T>& c) = 0;
// Implementation specific device functions
static std::vector<int> getDeviceList();
static std::vector<int> getDeviceName();
static std::vector<int> getDeviceDriver();
static void listDevices(void);
static std::string getDeviceName(const int);
static std::string getDeviceDriver(const int);
};