syclreference.com
  1. SYCL
  2. | API Reference
  3. | Atomics
  4. | atomic

atomic<T, addressSpace>

Implementation of the SYCL atomic class according to 1.2 spec. (section 3.8). On host, calls C++ atomic functions on an std::atomic; on device uses SPIR-mangled OpenCL 1.2 functions to achieve same result.

template <typename T, access::address_space addressSpace>
struct cl::sycl::atomic;

Member Functions

(constructor)
compare_exchange_strong

Atomically compare and optionally exchange expected with *m_data. Calls C++11 equivalent on host, has to be implemented “by hand” on device because OpenCL 1.2 and C++ 11 have different semantics for compare and exchange. If *m_data == expected, performs *m_data = desired and returns true. Otherwise, performs expected = *m_data and returns false.

exchange

Atomically exchange operand with *m_data.

fetch_add

Atomically add operand to *m_data. param operand the value to add to *m_data. param mem_order the ordering to use. Can only be memory_order_relaxed. return the old value of *m_data.

fetch_and

Atomically bitwise-and operand with *m_data.

fetch_max

Atomically compare operand to *m_data, storing the larger of the two in *m_data.

fetch_min

Atomically compare operand to *m_data, storing the smaller of the two in *m_data.

fetch_or

Atomically bitwise-or operand with *m_data.

fetch_sub

Atomically subtract operand from *m_data.

fetch_xor

Atomically bitwise-xor operand with *m_data.

load

Atomically load from m_data. Calls C++11 equivalent on host, on device it either calls atomic_add with operand = 0, discarding the result.

store

Atomically store operand in m_data. Calls C++11 equivalent on host, on device it calls exchange, discarding the result.

syclreference.com — SYCL Reference Pages

Last updated: 2019-01-24 00:24:52 +0000