11#if defined(__HIP_DEVICE_COMPILE__)
12#include <hip/hip_runtime.h>
16#if defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
17#include <sycl/sycl.hpp>
21#if defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
22#define __VECMEM_SYCL_ATOMIC_CALL0(FNAME, PTR) \
23 ::sycl::atomic_##FNAME<value_type>( \
24 ::sycl::atomic<value_type>(::sycl::global_ptr<value_type>(PTR)))
25#define __VECMEM_SYCL_ATOMIC_CALL1(FNAME, PTR, ARG1) \
26 ::sycl::atomic_##FNAME<value_type>( \
27 ::sycl::atomic<value_type>(::sycl::global_ptr<value_type>(PTR)), ARG1)
28#define __VECMEM_SYCL_ATOMIC_CALL2(FNAME, PTR, ARG1, ARG2) \
29 ::sycl::atomic_##FNAME<value_type>( \
30 ::sycl::atomic<value_type>(::sycl::global_ptr<value_type>(PTR)), ARG1, \
42#if (defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)) && \
43 (!defined(SYCL_LANGUAGE_VERSION))
47#elif defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
48 __VECMEM_SYCL_ATOMIC_CALL1(store, m_ptr, data);
57#if (defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)) && \
58 (!defined(SYCL_LANGUAGE_VERSION))
64#elif defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
65 return __VECMEM_SYCL_ATOMIC_CALL0(load, m_ptr);
74#if (defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)) && \
75 (!defined(SYCL_LANGUAGE_VERSION))
77#elif defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
78 return __VECMEM_SYCL_ATOMIC_CALL1(exchange, m_ptr, data);
90#if (defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)) && \
91 (!defined(SYCL_LANGUAGE_VERSION))
93#elif defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
94 return __VECMEM_SYCL_ATOMIC_CALL2(compare_exchange_strong, m_ptr,
expected,
111#if (defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)) && \
112 (!defined(SYCL_LANGUAGE_VERSION))
114#elif defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
115 return __VECMEM_SYCL_ATOMIC_CALL1(fetch_add, m_ptr, data);
127#if (defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)) && \
128 (!defined(SYCL_LANGUAGE_VERSION))
130#elif defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
131 return __VECMEM_SYCL_ATOMIC_CALL1(fetch_sub, m_ptr, data);
143#if (defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)) && \
144 (!defined(SYCL_LANGUAGE_VERSION))
146#elif defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
147 return __VECMEM_SYCL_ATOMIC_CALL1(fetch_and, m_ptr, data);
158#if (defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)) && \
159 (!defined(SYCL_LANGUAGE_VERSION))
161#elif defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
162 return __VECMEM_SYCL_ATOMIC_CALL1(fetch_or, m_ptr, data);
174#if (defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)) && \
175 (!defined(SYCL_LANGUAGE_VERSION))
177#elif defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)
178 return __VECMEM_SYCL_ATOMIC_CALL1(fetch_xor, m_ptr, data);
VECMEM_HOST_AND_DEVICE value_type fetch_and(value_type data)
Replace the current value with the specified value AND-ed to it.
Definition atomic.ipp:140
VECMEM_HOST_AND_DEVICE value_type fetch_sub(value_type data)
Substitute a chosen value from the stored variable.
Definition atomic.ipp:124
VECMEM_HOST_AND_DEVICE value_type load() const
Get the value of the variable.
Definition atomic.ipp:55
value_type * pointer
Pointer to the value in global memory.
Definition atomic.hpp:87
VECMEM_HOST_AND_DEVICE value_type exchange(value_type data)
Exchange the current value of the variable with a different one.
Definition atomic.ipp:72
VECMEM_HOST_AND_DEVICE void store(value_type data)
Set the variable to the desired value.
Definition atomic.ipp:40
value_type & reference
Reference to a value given by the user.
Definition atomic.hpp:89
VECMEM_HOST_AND_DEVICE atomic(pointer ptr)
Constructor, with a pointer to the managed variable.
Definition atomic.ipp:37
T value_type
Type managed by the object.
Definition atomic.hpp:83
VECMEM_HOST_AND_DEVICE value_type fetch_xor(value_type data)
Replace the current value with the specified value XOR-d to it.
Definition atomic.ipp:171
VECMEM_HOST_AND_DEVICE value_type fetch_or(value_type data)
Replace the current value with the specified value OR-d to it.
Definition atomic.ipp:156
VECMEM_HOST_AND_DEVICE bool compare_exchange_strong(reference expected, value_type desired)
Compare against the current value, and exchange only if different.
Definition atomic.ipp:87
VECMEM_HOST_AND_DEVICE value_type fetch_add(value_type data)
Add a chosen value to the stored variable.
Definition atomic.ipp:108
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16
std::vector< T, vecmem::polymorphic_allocator< T > > vector
Alias type for vectors with our polymorphic allocator.
Definition vector.hpp:35