Tensor Comprehensions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cuda_info.h
Go to the documentation of this file.
1 
16 #pragma once
17 
18 #include <string>
19 #include <vector>
20 
21 namespace tc {
22 
23 //
24 // This functionality in this type of class has been rewritten over and over
25 // again. Here we just provide a static singleton and basic properties.
26 // Consider lifting stuff up from fbcuda rather than reinventing the wheel
27 //
28 class CudaGPUInfo {
29  CudaGPUInfo(const std::vector<std::string>& gpuNames) : gpuNames_(gpuNames) {}
30 
31  public:
32  static CudaGPUInfo& GPUInfo();
33 
34  // These functions require init to have been run, they are thus members of
35  // the singleton object and not static functions.
36  int NumberGPUs() const;
37  int CurrentGPUId() const;
38  void SynchronizeCurrentGPU() const;
39  std::string GetGPUName(int id = -1) const;
40  std::string GetCudaDeviceStr() const;
41 
42  std::vector<std::string> gpuNames_;
43 };
44 
45 } // namespace tc
static CudaGPUInfo & GPUInfo()
std::vector< std::string > gpuNames_
Definition: cuda_info.h:42
CudaGPUInfo(const std::vector< std::string > &gpuNames)
Definition: cuda_info.h:29
void SynchronizeCurrentGPU() const
int NumberGPUs() const
std::string GetCudaDeviceStr() const
int CurrentGPUId() const
Definition: cuda_info.h:28
std::string GetGPUName(int id=-1) const