SkePU(integratedwithStarPU)  0.8.1
 All Classes Namespaces Files Functions Enumerations Friends Macros Groups Pages
device_cu.h
Go to the documentation of this file.
1 
5 #ifndef DEVICE_CU_H
6 #define DEVICE_CU_H
7 
8 #ifdef SKEPU_CUDA
9 
10 #include <iostream>
11 #include <cuda.h>
12 
13 #include "../globals.h"
14 
15 namespace skepu
16 {
17 
31 class Device_CU
32 {
33 
34 private:
35  int m_deviceID;
36  cudaDeviceProp m_deviceProp;
37  int m_maxThreads;
38  int m_maxBlocks;
39 
45  void getDeviceProps(int device)
46  {
47  cudaError_t err;
48  err = cudaGetDeviceProperties(&m_deviceProp, device);
49  if (err != cudaSuccess) {std::cerr<<"getDeviceProps failed!\n";}
50  }
51 
52 public:
53 
59  Device_CU(int id)
60  {
61  m_deviceID = id;
62  getDeviceProps(id);
63 
64  if(m_deviceProp.major == 1 && m_deviceProp.minor < 2)
65  {
66  m_maxThreads = 256;
67  }
68  else
69  {
70  m_maxThreads = m_deviceProp.maxThreadsPerBlock;
71  }
72 
73  m_maxBlocks = m_deviceProp.maxGridSize[0];
74  }
75 
76  ~Device_CU() {};
77 
81  int getMaxBlockSize() const {return m_deviceProp.maxThreadsPerBlock;}
82 
86  int getNumComputeUnits() const {return m_deviceProp.multiProcessorCount;}
87 
91  size_t getGlobalMemSize() const {return m_deviceProp.totalGlobalMem;}
92 
96  size_t getSharedMemPerBlock() const {return m_deviceProp.sharedMemPerBlock;}
97 
101  int getMaxThreads() const
102  {
103  #ifdef SKEPU_MAX_GPU_THREADS
104  return SKEPU_MAX_GPU_THREADS;
105  #else
106  return m_maxThreads;
107  #endif
108  }
109 
113  int getMaxBlocks() const {return m_maxBlocks;}
114 
118  int getDeviceID() const {return m_deviceID;}
119 };
120 
121 }
122 
123 #endif
124 
125 #endif
126 
int getMaxThreads() const
Definition: device_cu.h:101
size_t getGlobalMemSize() const
Definition: device_cu.h:91
int getMaxBlockSize() const
Definition: device_cu.h:81
int getMaxBlocks() const
Definition: device_cu.h:113
int getNumComputeUnits() const
Definition: device_cu.h:86
size_t getSharedMemPerBlock() const
Definition: device_cu.h:96
A class representing a CUDA device.
Definition: device_cu.h:31
int getDeviceID() const
Definition: device_cu.h:118
Device_CU(int id)
Definition: device_cu.h:59