TP fractalTP fractal..
[GPU.git] / WCudaMSE / BilatTools_Cuda / src / core / cudatools / header / host / Device.h
1 #ifndef DEVICE_H
2 #define DEVICE_H
3
4 #include "cuda_runtime.h"
5 #include <string>
6
7 using std::string;
8
9 /*----------------------------------------------------------------------*\
10 |* Declaration *|
11 \*---------------------------------------------------------------------*/
12
13 /**
14 * idDevice in [0,nbDevice-1]
15 *
16 * dim3.x
17 * dim3.y
18 * dim3.z
19 *
20 * sm=1.2 major=1 minor=2
21 */
22 class Device
23 {
24 /*--------------------------------------*\
25 |* Constructor *|
26 \*-------------------------------------*/
27 public:
28
29 /*--------------------------------------*\
30 |* Methodes *|
31 \*-------------------------------------*/
32
33 public:
34
35 /*--------------*\
36 |* Wrapper *|
37 \*-------------*/
38
39 /**
40 * wrapper for cudaDeviceSynchronize()
41 */
42 static void synchronize(void);
43
44 /*--------------*\
45 |* Tools *|
46 \*-------------*/
47
48 /**
49 * message = nameKernel by example
50 */
51 static void checkKernelError(const char *message = NULL);
52
53 /**
54 * Booth:
55 * assertDim(dg, db);
56 * checkDimOPtimiser(dg, db);
57 */
58 static void checkDimError(const dim3& dg, const dim3& db);
59
60 static void checkDimOptimiser(const dim3& dg, const dim3& db);
61 static void assertDim(const dim3& dg, const dim3& db);
62
63 static int dim(const dim3& dim);
64 static int nbThread(const dim3& dg, const dim3& db);
65
66 static void print(const dim3& dg, const dim3& db);
67
68 /*--------------*\
69 |* get *|
70 \*-------------*/
71
72 static int getRuntimeVersion(void);
73 static int getDriverVersion(void);
74
75 static int getDeviceCount(void);
76 static int getDeviceId(void);
77
78 static cudaDeviceProp getDeviceProp(int idDevice);
79 static cudaDeviceProp getDeviceProp(void);
80
81 static string getNameSimple(int idDevice);
82 static string getNameSimple(void);
83
84 static string getName(int idDevice);
85 static string getName(void);
86
87 static dim3 getMaxGridDim(int idDevice);
88 static dim3 getMaxGridDim(void);
89
90 static dim3 getMaxBlockDim(int idDevice);
91 static dim3 getMaxBlockDim(void);
92
93 static int getWarpSize(int idDevice);
94 static int getWarpSize(void);
95
96 static int getMaxThreadPerBlock(int idDevice);
97 static int getMaxThreadPerBlock(void);
98
99 static int getMPCount(void);
100 static int getMPCount(int idDevice);
101
102 static int getCapacityMajor(int idDevice);
103 static int getCapacityMajor(void);
104
105 static int getCapacityMinor(int idDevice);
106 static int getCapacityMinor(void);
107
108 static int getAsyncEngineCount(int idDevice);
109 static int getAsyncEngineCount(void);
110
111 /*--------------*\
112 |* print *|
113 \*-------------*/
114
115 static void printAll(void);
116 static void printAllSimple(void);
117
118 static void print(int idDevice);
119 static void print(void);
120
121 static void printCurrent(void);
122
123 /*--------------*\
124 |* Is *|
125 \*-------------*/
126
127 static bool isCuda(void);
128
129 static bool isFermi(int idDevice);
130 static bool isFermi(void);
131
132 static bool isKepler(int idDevice);
133 static bool isKepler(void);
134
135 static bool isUVAEnable(int idDevice);
136 static bool isUVAEnable(void);
137
138 static bool isAtomicShareMemoryEnable(int idDevice);
139 static bool isAtomicShareMemoryEnable(void);
140
141 static bool isHostMapMemoryEnable(int idDevice);
142 static bool isHostMapMemoryEnable(void);
143
144 static bool isECCEnable(int idDevice);
145 static bool isECCEnable(void);
146
147 static bool isAsyncEngine(int idDevice);
148 static bool isAsyncEngine(void);
149
150 /*--------------*\
151 |* load *|
152 \*-------------*/
153
154 /**
155 * Force load
156 */
157 static void loadCudaDriver(int deviceID, bool isMapMemoryEnable = true);
158 /**
159 * Force load
160 */
161 static void loadCudaDriver(bool isMapMemoryEnable = true);
162 /**
163 * Force load
164 */
165 static void loadCudaDriverAll(bool isMapMemoryEnable = true);
166
167 /*--------------*\
168 |* p2p *|
169 \*-------------*/
170
171 /**
172 * use delete[] ptrMatrixP2PCompatibility after usage
173 * raw major vectoriser
174 */
175 static int* p2pMatrixCompatibility(void);
176
177 /**
178 * to be used after HANDLE_ERROR(cudaGLSetGLDevice(deviceId));
179 */
180 static void p2pEnableALL(void);
181
182 static void printP2PmatrixCompatibility(void);
183
184 /*--------------------------------------*\
185 |* Attributs *|
186 \*-------------------------------------*/
187
188 private:
189
190 };
191
192 #endif
193
194 /*----------------------------------------------------------------------*\
195 |* End *|
196 \*---------------------------------------------------------------------*/
197