vecmem 1.14.0
Loading...
Searching...
No Matches
sycl_custom_device_atomic_ref.hpp
1/*
2 * VecMem project, part of the ACTS project (R&D line)
3 *
4 * (c) 2022-2024 CERN for the benefit of the ACTS project
5 *
6 * Mozilla Public License Version 2.0
7 */
8#pragma once
9
10// Local include(s).
11#include "vecmem/memory/device_address_space.hpp"
12#include "vecmem/memory/memory_order.hpp"
13
14// System include(s).
15#include <type_traits>
16
17namespace vecmem {
18namespace sycl {
19
25template <typename T,
26 device_address_space address = device_address_space::global>
28
29public:
32
34 typedef T value_type;
41
43
46
47 static_assert(
48 std::is_integral<value_type>::value,
49 "vecmem::sycl::custom_device_atomic_ref only accepts built-in "
50 "integral types");
51
53
58
61 delete;
62
65
71
73 void store(value_type data,
74 memory_order order = memory_order::seq_cst) const;
76 value_type load(memory_order order = memory_order::seq_cst) const;
77
80 memory_order order = memory_order::seq_cst) const;
81
85 memory_order failure) const;
89 memory_order order = memory_order::seq_cst) const;
90
92
95
98 memory_order order = memory_order::seq_cst) const;
101 memory_order order = memory_order::seq_cst) const;
102
105 memory_order order = memory_order::seq_cst) const;
108 memory_order order = memory_order::seq_cst) const;
111 memory_order order = memory_order::seq_cst) const;
112
114
115private:
117 pointer m_ptr;
118
119}; // class custom_device_atomic_ref
120
121} // namespace sycl
122} // namespace vecmem
123
124// Include the implementation.
125#include "vecmem/memory/impl/sycl_custom_device_atomic_ref.ipp"
Custom implementation for atomic operations in SYCL device code.
Definition sycl_custom_device_atomic_ref.hpp:27
value_type difference_type
Difference between two objects.
Definition sycl_custom_device_atomic_ref.hpp:36
void store(value_type data, memory_order order=memory_order::seq_cst) const
Set the variable to the desired value.
Definition sycl_custom_device_atomic_ref.ipp:81
value_type fetch_sub(value_type data, memory_order order=memory_order::seq_cst) const
Substitute a chosen value from the stored variable.
Definition sycl_custom_device_atomic_ref.ipp:139
T value_type
Type managed by the object.
Definition sycl_custom_device_atomic_ref.hpp:34
value_type exchange(value_type data, memory_order order=memory_order::seq_cst) const
Exchange the current value of the variable with a different one.
Definition sycl_custom_device_atomic_ref.ipp:95
value_type fetch_or(value_type data, memory_order order=memory_order::seq_cst) const
Replace the current value with the specified value OR-d to it.
Definition sycl_custom_device_atomic_ref.ipp:155
custom_device_atomic_ref & operator=(const custom_device_atomic_ref &)=delete
Disable the assignment operator.
value_type fetch_xor(value_type data, memory_order order=memory_order::seq_cst) const
Replace the current value with the specified value XOR-d to it.
Definition sycl_custom_device_atomic_ref.ipp:163
value_type * pointer
Pointer to the value in global memory.
Definition sycl_custom_device_atomic_ref.hpp:38
value_type load(memory_order order=memory_order::seq_cst) const
Get the value of the variable.
Definition sycl_custom_device_atomic_ref.ipp:88
value_type & reference
Reference to a value given by the user.
Definition sycl_custom_device_atomic_ref.hpp:40
value_type fetch_add(value_type data, memory_order order=memory_order::seq_cst) const
Add a chosen value to the stored variable.
Definition sycl_custom_device_atomic_ref.ipp:131
value_type fetch_and(value_type data, memory_order order=memory_order::seq_cst) const
Replace the current value with the specified value AND-ed to it.
Definition sycl_custom_device_atomic_ref.ipp:147
bool compare_exchange_strong(reference expected, value_type desired, memory_order success, memory_order failure) const
Compare against the current value, and exchange only if different.
Definition sycl_custom_device_atomic_ref.ipp:118
Main namespace for the vecmem classes/functions.
Definition atomic_ref.hpp:16
device_address_space
Custom definition for the device memory adress space.
Definition device_address_space.hpp:12
std::vector< T, vecmem::polymorphic_allocator< T > > vector
Alias type for vectors with our polymorphic allocator.
Definition vector.hpp:35
memory_order
Custom (dummy) definition for the memory order.
Definition memory_order.hpp:31