Openholo  v4.2
Open Source Digital Holographic Library
CUDA.h
Go to the documentation of this file.
1 #pragma once
2 #include <cuda_runtime_api.h>
3 #include <sys.h> //for LOG() macro
4 #include <atomic>
5 #include <mutex>
6 
7 class CUDA
8 {
9 private:
10  CUDA();
11  ~CUDA();
12  static CUDA *instance;
13  cudaDeviceProp devProp;
14 
15  int m_nThread;
16 public:
17  static CUDA* getInstance() {
18  if (instance == nullptr) {
19  instance = new CUDA();
20  atexit(releaseInstance);
21  }
22  return instance;
23  }
24 
25  static void releaseInstance() {
26  if (instance != nullptr) {
27  delete instance;
28  instance = nullptr;
29  }
30  }
31 
32  void setCurThreads(int thread) { m_nThread = thread; }
33  int getCurThreads() { return m_nThread; }
34  int getMaxThreads() { return devProp.maxThreadsPerBlock; }
35  int getWarpSize() { return devProp.warpSize; }
36  void printMemoryInfo(uint64_t total, uint64_t free);
37 
38 private:
39  bool printDevInfo();
40 
41 public:
42 
43 private:
44 };
static CUDA * getInstance()
Definition: CUDA.h:17
void printMemoryInfo(uint64_t total, uint64_t free)
Definition: CUDA.cpp:78
int getMaxThreads()
Definition: CUDA.h:34
int getWarpSize()
Definition: CUDA.h:35
void setCurThreads(int thread)
Definition: CUDA.h:32
int getCurThreads()
Definition: CUDA.h:33
Definition: CUDA.h:7
static void releaseInstance()
Definition: CUDA.h:25