17 #ifndef KOKKOS_IMPL_PUBLIC_INCLUDE
18 #include <Kokkos_Macros.hpp>
20 "Including non-public Kokkos header files is not allowed.");
22 #ifndef KOKKOS_DESUL_ATOMICS_VOLATILE_WRAPPER_HPP_
23 #define KOKKOS_DESUL_ATOMICS_VOLATILE_WRAPPER_HPP_
24 #include <Kokkos_Macros.hpp>
25 #include <desul/atomics.hpp>
27 #ifdef KOKKOS_ENABLE_ATOMICS_BYPASS
28 #define KOKKOS_DESUL_MEM_SCOPE desul::MemoryScopeCaller()
30 #define KOKKOS_DESUL_MEM_SCOPE desul::MemoryScopeDevice()
36 template<
class T> KOKKOS_INLINE_FUNCTION
37 T atomic_load(
volatile T*
const dest) {
return desul::atomic_load(const_cast<T*>(dest), desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
39 template<
class T> KOKKOS_INLINE_FUNCTION
40 void atomic_store(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_store(const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
43 template<
class T> KOKKOS_INLINE_FUNCTION
44 T atomic_fetch_add (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_add (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
46 template<
class T> KOKKOS_INLINE_FUNCTION
47 T atomic_fetch_sub (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_sub (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
49 template<
class T> KOKKOS_INLINE_FUNCTION
50 T atomic_fetch_max (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_max (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
52 template<
class T> KOKKOS_INLINE_FUNCTION
53 T atomic_fetch_min (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_min (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
55 template<
class T> KOKKOS_INLINE_FUNCTION
56 T atomic_fetch_mul (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_mul (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
58 template<
class T> KOKKOS_INLINE_FUNCTION
59 T atomic_fetch_div (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_div (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
61 template<
class T> KOKKOS_INLINE_FUNCTION
62 T atomic_fetch_mod (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_mod (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
64 template<
class T> KOKKOS_INLINE_FUNCTION
65 T atomic_fetch_and (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_and (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
67 template<
class T> KOKKOS_INLINE_FUNCTION
68 T atomic_fetch_or (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_or (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
70 template<
class T> KOKKOS_INLINE_FUNCTION
71 T atomic_fetch_xor (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_xor (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
73 template<
class T> KOKKOS_INLINE_FUNCTION
74 T atomic_fetch_nand(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_nand(const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
76 template<
class T> KOKKOS_INLINE_FUNCTION
77 T atomic_fetch_lshift(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_lshift(const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
79 template<
class T> KOKKOS_INLINE_FUNCTION
80 T atomic_fetch_rshift(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_fetch_rshift(const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
82 template<
class T> KOKKOS_INLINE_FUNCTION
83 T atomic_fetch_inc(
volatile T*
const dest) {
return desul::atomic_fetch_inc(const_cast<T*>(dest),desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
85 template<
class T> KOKKOS_INLINE_FUNCTION
86 T atomic_fetch_dec(
volatile T*
const dest) {
return desul::atomic_fetch_dec(const_cast<T*>(dest),desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
90 template<
class T> KOKKOS_INLINE_FUNCTION
91 T atomic_add_fetch (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_add_fetch (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
93 template<
class T> KOKKOS_INLINE_FUNCTION
94 T atomic_sub_fetch (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_sub_fetch (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
96 template<
class T> KOKKOS_INLINE_FUNCTION
97 T atomic_max_fetch (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_max_fetch (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
99 template<
class T> KOKKOS_INLINE_FUNCTION
100 T atomic_min_fetch (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_min_fetch (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
102 template<
class T> KOKKOS_INLINE_FUNCTION
103 T atomic_mul_fetch (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_mul_fetch (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
105 template<
class T> KOKKOS_INLINE_FUNCTION
106 T atomic_div_fetch (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_div_fetch (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
108 template<
class T> KOKKOS_INLINE_FUNCTION
109 T atomic_mod_fetch (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_mod_fetch (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
111 template<
class T> KOKKOS_INLINE_FUNCTION
112 T atomic_and_fetch (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_and_fetch (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
114 template<
class T> KOKKOS_INLINE_FUNCTION
115 T atomic_or_fetch (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_or_fetch (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
117 template<
class T> KOKKOS_INLINE_FUNCTION
118 T atomic_xor_fetch (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_xor_fetch (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
120 template<
class T> KOKKOS_INLINE_FUNCTION
121 T atomic_nand_fetch(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_nand_fetch(const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
123 template<
class T> KOKKOS_INLINE_FUNCTION
124 T atomic_lshift_fetch(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_lshift_fetch(const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
126 template<
class T> KOKKOS_INLINE_FUNCTION
127 T atomic_rshift_fetch(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_rshift_fetch(const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
129 template<
class T> KOKKOS_INLINE_FUNCTION
130 T atomic_inc_fetch(
volatile T*
const dest) {
return desul::atomic_inc_fetch(const_cast<T*>(dest),desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
132 template<
class T> KOKKOS_INLINE_FUNCTION
133 T atomic_dec_fetch(
volatile T*
const dest) {
return desul::atomic_dec_fetch(const_cast<T*>(dest),desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
137 template<
class T> KOKKOS_INLINE_FUNCTION
138 void atomic_add(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_add (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
140 template<
class T> KOKKOS_INLINE_FUNCTION
141 void atomic_sub(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_sub (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
143 template<
class T> KOKKOS_INLINE_FUNCTION
144 void atomic_mul(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_mul (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
146 template<
class T> KOKKOS_INLINE_FUNCTION
147 void atomic_div(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_div (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
149 template<
class T> KOKKOS_INLINE_FUNCTION
150 void atomic_min(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_min (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
152 template<
class T> KOKKOS_INLINE_FUNCTION
153 void atomic_max(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_max (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
156 template<
class T> KOKKOS_INLINE_FUNCTION
157 void atomic_and(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) { (void) desul::atomic_fetch_and (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
160 template<
class T> KOKKOS_INLINE_FUNCTION
161 void atomic_or (
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) { (void) desul::atomic_fetch_or (const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
163 template<
class T> KOKKOS_INLINE_FUNCTION
164 void atomic_inc(
volatile T*
const dest) {
return desul::atomic_inc(const_cast<T*>(dest),desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
166 template<
class T> KOKKOS_INLINE_FUNCTION
167 void atomic_dec(
volatile T*
const dest) {
return desul::atomic_dec(const_cast<T*>(dest),desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
169 template<
class T> KOKKOS_INLINE_FUNCTION
170 void atomic_increment(
volatile T*
const dest) {
return desul::atomic_inc(const_cast<T*>(dest),desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
172 template<
class T> KOKKOS_INLINE_FUNCTION
173 void atomic_decrement(
volatile T*
const dest) {
return desul::atomic_dec(const_cast<T*>(dest),desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
177 template<
class T> KOKKOS_INLINE_FUNCTION
178 T atomic_exchange(
volatile T*
const dest, desul::Impl::dont_deduce_this_parameter_t<const T> val) {
return desul::atomic_exchange(const_cast<T*>(dest), val, desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE); }
180 template<
class T> KOKKOS_INLINE_FUNCTION
181 bool atomic_compare_exchange_strong(
volatile T*
const dest, T& expected,
const T desired) {
182 return desul::atomic_compare_exchange_strong(const_cast<T*>(dest),expected, desired,
183 desul::MemoryOrderRelaxed(), desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE);
186 template<
class T> KOKKOS_INLINE_FUNCTION
187 T atomic_compare_exchange(
volatile T*
const dest,
const T compare,
const T desired) {
188 return desul::atomic_compare_exchange(const_cast<T*>(dest),compare, desired,
189 desul::MemoryOrderRelaxed(), KOKKOS_DESUL_MEM_SCOPE);
193 #undef KOKKOS_DESUL_MEM_SCOPE