cuda_utils.h 1.05 KB
Newer Older
1
2
#pragma once

3
4
#include <stdio.h>

5
6
7
8
9
10
11
12
13
14
#if defined(__CUDACC__) || defined(_NVHPC_CUDA)
  #define HOST_DEVICE_INLINE __forceinline__ __host__ __device__
  #define DEVICE_INLINE __forceinline__ __device__
  #define HOST_INLINE __forceinline__ __host__
#else
  #define HOST_DEVICE_INLINE inline
  #define DEVICE_INLINE inline
  #define HOST_INLINE inline
#endif

15
16
17
18
19
20
21
22
23
24
#define CUDA_CHECK(cmd)                                             \
  do {                                                              \
    cudaError_t e = cmd;                                            \
    if (e != cudaSuccess) {                                         \
      printf("Failed: Cuda error %s:%d '%s'\n", __FILE__, __LINE__, \
             cudaGetErrorString(e));                                \
      exit(EXIT_FAILURE);                                           \
    }                                                               \
  } while (0)

25
int64_t get_device_attribute(int64_t attribute, int64_t device_id);
26

27
int64_t get_max_shared_memory_per_block_device_attribute(int64_t device_id);