atomic_exchange#

Header File: <Kokkos_Core.hpp>

Usage#

old_val = atomic_exchange(ptr_to_value, new_value);

Atomically sets the value at the address given by ptr_to_value to new_value and returns the previously stored value at the address.

Description#

template<class T>
T atomic_exchange(T *const ptr_to_value, const T new_value);#

Atomically executes old_value = *ptr_to_value; *ptr_to_value = new_value; return old_value;, where old_value is the value at address ptr_to_value before doing the exchange.

Parameters:
  • ptr_to_value – address of the value to be updated

  • new_value – new value