OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
cuda_util.hpp
1/*
2 * cuda_util.hpp
3 *
4 * Created on: Jun 13, 2018
5 * Author: i-bird
6 */
7
8#ifndef OPENFPM_DATA_SRC_UTIL_CUDA_UTIL_HPP_
9#define OPENFPM_DATA_SRC_UTIL_CUDA_UTIL_HPP_
10
11#include "config.h"
12
13#if defined(CUDIFY_USE_ALPAKA)
14#define CUDA_ON_CPU
15#elif defined(CUDIFY_USE_OPENMP)
16#define CUDA_ON_CPU
17#elif defined(CUDIFY_USE_SEQUENTIAL)
18#define CUDA_ON_CPU
19#endif
20
21#if defined(__HIP__)
22 // If hip fill NVCC think it is Nvidia compiler
23 #ifdef __NVCC__
24 #undef __NVCC__
25 #include <hip/hip_runtime.h>
26 #define __NVCC__
27 #else
28 #include <hip/hip_runtime.h>
29 #endif
30#elif defined(CUDIFY_USE_CUDA)
31#include <cuda_runtime.h>
32#endif
33
34#ifdef CUDA_GPU
35
36 #ifndef __NVCC__
37
38 #ifndef __host__
39 #define __host__
40 #define __device__
41 #define __shared__ static thread_local
42 #define __global__ inline
43 #endif
44
45 #else
46
47 #ifndef __host__
48 #define __host__
49 #define __device__
50 #define __global__ inline
51 #endif
52
53 #ifdef CUDA_ON_CPU
54
55 #ifdef __shared__
56 #undef __shared__
57 #endif
58 #define __shared__ static thread_local
59
60 #else
61
62 #ifndef __shared__
63 #define __shared__
64 #endif
65
66 #endif
67
68 #endif
69#else
70
71#ifndef __host__
72#define __host__
73#define __device__
74#define __shared__ static thread_local
75#define __global__ inline
76#endif
77
78#endif
79
80
81#endif /* OPENFPM_DATA_SRC_UTIL_CUDA_UTIL_HPP_ */