Implement some CUDA routines for device info
This commit is contained in:
parent
a1cab96c57
commit
d1f8cd1b48
@ -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>;
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user