NAMD
Functions
DeviceCUDAkernel.cu File Reference
#include <stdio.h>
#include "CudaUtils.h"
#include <cuda.h>

Go to the source code of this file.

Functions

__global__ void read_CUDA_ARCH_kernel (int *cuda_arch)
 
int read_CUDA_ARCH ()
 

Function Documentation

int read_CUDA_ARCH ( )

Definition at line 38 of file DeviceCUDAkernel.cu.

References cudaCheck, and cudaDie().

38  {
39  int *d_cuda_arch;
40  int h_cuda_arch;
41  allocate_device<int>(&d_cuda_arch, 1);
42 
43  read_CUDA_ARCH_kernel <<< 1, 1 >>> (d_cuda_arch);
44  cudaError_t err = cudaGetLastError();
45  if (err != cudaSuccess) {
46  char str[1024];
47  sprintf(str, "Error executing CUDA kernel read_CUDA_ARCH_kernel in file %s\nError string: %s\nPossible cause: Device compute capability is less than the compute capability the code was compiled for.\n",
48  __FILE__,cudaGetErrorString(err));
49  cudaDie(str);
50  }
51  cudaCheck(cudaDeviceSynchronize());
52 
53  copy_DtoH_sync<int>(d_cuda_arch, &h_cuda_arch, 1);
54  deallocate_device<int>(&d_cuda_arch);
55 
56  return h_cuda_arch;
57 }
void cudaDie(const char *msg, cudaError_t err=cudaSuccess)
Definition: CudaUtils.C:9
#define cudaCheck(stmt)
Definition: CudaUtils.h:79
__global__ void read_CUDA_ARCH_kernel ( int *  cuda_arch)

Definition at line 7 of file DeviceCUDAkernel.cu.

7  {
8  if (threadIdx.x == 0) {
9 
10 #if __CUDA_ARCH__ == 100
11  *cuda_arch = 100;
12 #elif __CUDA_ARCH__ == 110
13  *cuda_arch = 110;
14 #elif __CUDA_ARCH__ == 120
15  *cuda_arch = 120;
16 #elif __CUDA_ARCH__ == 130
17  *cuda_arch = 130;
18 #elif __CUDA_ARCH__ == 200
19  *cuda_arch = 200;
20 #elif __CUDA_ARCH__ == 210
21  *cuda_arch = 210;
22 #elif __CUDA_ARCH__ == 300
23  *cuda_arch = 300;
24 #elif __CUDA_ARCH__ == 350
25  *cuda_arch = 350;
26 #elif __CUDA_ARCH__ == 500
27  *cuda_arch = 500;
28 #else
29  *cuda_arch = 500;
30 #endif
31 
32  }
33 }