16 #ifndef dealii_cuda_atomic_h 17 #define dealii_cuda_atomic_h 19 #include <deal.II/base/config.h> 21 #ifdef DEAL_II_WITH_CUDA 23 DEAL_II_NAMESPACE_OPEN
36 return atomicAdd(address,val);
49 #if __CUDACC_VER_MAJOR__ >= 8 && ( !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 600 ) 50 return atomicAdd(address,val);
53 unsigned long long int *address_as_ull =
54 reinterpret_cast<unsigned long long int *
>(address);
55 unsigned long long int old = *address_as_ull, assumed;
59 old = atomicCAS(address_as_ull, assumed,
60 __double_as_longlong(val + __longlong_as_double(assumed)));
62 while (assumed != old);
64 return __longlong_as_double(old);
77 int *address_as_int =
reinterpret_cast<int *
>(address);
78 int old = *address_as_int, assumed;
82 old = atomicCAS(address_as_int, assumed,
83 atomicMax(address_as_int, __float_as_int(val)));
85 while (assumed != old);
87 return __longlong_as_double(old);
99 unsigned long long int *address_as_ull =
100 reinterpret_cast<unsigned long long int *
>(address);
101 unsigned long long int old = *address_as_ull, assumed;
105 old = atomicCAS(address_as_ull, assumed,
106 atomicMax(address_as_ull,
107 static_cast<unsigned long long int>(__double_as_longlong(val))));
109 while (assumed != old);
111 return __longlong_as_double(old);
116 DEAL_II_NAMESPACE_CLOSE
float atomicMax_wrapper(float *address, float val)
float atomicAdd_wrapper(float *address, float val)