GPU Workshop sample code
 All Data Structures Namespaces Files Functions Variables Macros Pages
helper_cuda.cu
Go to the documentation of this file.
1 
11 
13 int _ConvertSMVer2Cores(int major, int minor)
14 {
15  // Defines for GPU Architecture types (using the SM version to determine the # of cores per SM
16  typedef struct
17  {
18  int SM; // 0xMm (hexidecimal notation), M = SM Major version, and m = SM minor version
19  int Cores;
20  } sSMtoCores;
21 
22  sSMtoCores nGpuArchCoresPerSM[] =
23  {
24  { 0x10, 8 }, // Tesla Generation (SM 1.0) G80 class
25  { 0x11, 8 }, // Tesla Generation (SM 1.1) G8x class
26  { 0x12, 8 }, // Tesla Generation (SM 1.2) G9x class
27  { 0x13, 8 }, // Tesla Generation (SM 1.3) GT200 class
28  { 0x20, 32 }, // Fermi Generation (SM 2.0) GF100 class
29  { 0x21, 48 }, // Fermi Generation (SM 2.1) GF10x class
30  { 0x30, 192}, // Kepler Generation (SM 3.0) GK10x class
31  { 0x35, 192}, // Kepler Generation (SM 3.5) GK11x class
32  { -1, -1 }
33  };
34 
35  int index = 0;
36 
37  while (nGpuArchCoresPerSM[index].SM != -1)
38  {
39  if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor))
40  {
41  return nGpuArchCoresPerSM[index].Cores;
42  }
43 
44  index++;
45  }
46 
47  // If we don't find the values, we default use the previous one to run properly
48  printf("MapSMtoCores for SM %d.%d is undefined. Default to use %d Cores/SM\n", major, minor, nGpuArchCoresPerSM[7].Cores);
49  return nGpuArchCoresPerSM[7].Cores;
50 }