12 #ifndef MFEM_BACKENDS_HPP 13 #define MFEM_BACKENDS_HPP 15 #include "../config/config.hpp" 19 #include <library_types.h> 20 #include <cuda_runtime.h> 26 #include <hip/hip_runtime.h> 38 #define CUB_IGNORE_DEPRECATED_CPP_DIALECT 39 #define THRUST_IGNORE_DEPRECATED_CPP_DIALECT 40 #include "RAJA/RAJA.hpp" 41 #if defined(RAJA_ENABLE_CUDA) && !defined(MFEM_USE_CUDA) 42 #error When RAJA is built with CUDA, MFEM_USE_CUDA=YES is required 46 #if !(defined(MFEM_USE_CUDA) || defined(MFEM_USE_HIP)) 49 #define MFEM_HOST_DEVICE 51 #define MFEM_DEVICE_SYNC 53 #define MFEM_STREAM_SYNC 56 #if !((defined(MFEM_USE_CUDA) && defined(__CUDA_ARCH__)) || \ 57 (defined(MFEM_USE_HIP) && defined(__HIP_DEVICE_COMPILE__))) 59 #define MFEM_SYNC_THREAD 60 #define MFEM_BLOCK_ID(k) 0 61 #define MFEM_THREAD_ID(k) 0 62 #define MFEM_THREAD_SIZE(k) 1 63 #define MFEM_FOREACH_THREAD(i,k,N) for(int i=0; i<N; i++) 67 #if defined(MFEM_USE_CUDA) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ < 600 70 unsigned long long int *ptr = (
unsigned long long int *)
add;
71 unsigned long long int old = *ptr, reg;
75 old = atomicCAS(ptr, reg,
76 __double_as_longlong(val + __longlong_as_double(reg)));
79 return __longlong_as_double(old);
86 #if ((defined(MFEM_USE_CUDA) && defined(__CUDA_ARCH__)) || \ 87 (defined(MFEM_USE_HIP) && defined(__HIP_DEVICE_COMPILE__))) 91 #ifdef MFEM_USE_OPENMP 99 #endif // MFEM_BACKENDS_HPP MFEM_DEVICE double atomicAdd(double *add, double val)
MFEM_HOST_DEVICE T AtomicAdd(T &add, const T val)
void add(const Vector &v1, const Vector &v2, Vector &v)