-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeviceQuery.cu
More file actions
76 lines (58 loc) · 2.45 KB
/
Copy pathDeviceQuery.cu
File metadata and controls
76 lines (58 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "cuda_runtime.h"
#include <stdio.h>
#include <iostream>
using namespace std;
inline int _ConvertSMVer2Cores(int major, int minor) {
typedef struct {
int SM; // M = SM Major version,
// m = SM minor versionS
int Cores;
} sSMtoCores;
sSMtoCores nGpuArchCoresPerSM[] = {
{ 0x10, 8 }, //Tesla (SM 1.0) G80
{ 0x11, 8 },
{ 0x12, 8 },
{ 0x13, 8 },
{ 0x20, 32 },
{ 0x21, 48 },
{ 0x30, 192 },
{ 0x35, 192 },
{ -1, -1 } //none of the above/ default/ error
};
int i = 0;
while (nGpuArchCoresPerSM[i].SM != -1) {
if (nGpuArchCoresPerSM[i].SM == ((major << 4) + minor)) {
return nGpuArchCoresPerSM[i].Cores;
}
i++;
}
printf(
"MapSMtoCores for SM %d.%d is undefined."
" Default to use %d Cores/SM\n",
major, minor, nGpuArchCoresPerSM[i - 1].Cores);
return nGpuArchCoresPerSM[i - 1].Cores;
}
int main() {
int device_count;
cudaGetDeviceCount(&device_count);
cudaDeviceProp device_Properties;
cout << "Number of Devices: " << device_count << endl;
for (int i = 0; i < device_count; i++) {
cudaGetDeviceProperties(&device_Properties, i);
cout << "Type of CUDA Device: " << device_Properties.name << endl;
cout << "Device Number: " << i + 1 << endl;
cout << "Clock Rate: " << device_Properties.clockRate << endl;
cout << "Number of Streaming Multiprocessors: " << device_Properties.multiProcessorCount << endl;
cout << "Number of Cores: " << _ConvertSMVer2Cores(device_Properties.major, device_Properties.minor) << endl;
cout << "Warp Size: " << device_Properties.warpSize << endl;
cout << "Amount of Global Memory: " << device_Properties.totalGlobalMem << endl;
cout << "Amount of Constant Memory: " << device_Properties.totalConstMem << endl;
cout << "Amount of Shared Memory Per Block: " << device_Properties.sharedMemPerBlock << endl;
cout << "Registers Available Per Block: " << device_Properties.regsPerBlock << endl;
cout << "Max Threads Per Block: " << device_Properties.maxThreadsPerBlock << endl;
cout << "Max Dimension Size of Block: " << endl;
cout << "X: " << device_Properties.maxThreadsDim[0] << " Y: " << device_Properties.maxThreadsDim[1] << " Z: " << device_Properties.maxThreadsDim[2] << endl;
cout << "Max Dimension Size of Grid: " << endl;
cout << "X: " << device_Properties.maxGridSize[0] << " Y: "<< device_Properties.maxGridSize[1] << " Z: " << device_Properties.maxGridSize[2] << endl;
}
}