-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,28 @@ | ||
``atomic_exchange`` | ||
=================== | ||
|
||
.. role::cpp(code) | ||
:language: cpp | ||
.. role:: cppkokkos(code) | ||
:language: cppkokkos | ||
|
||
Header File: ``Kokkos_Core.hpp`` | ||
Header File: <Kokkos_Core.hpp> | ||
|
||
Usage: | ||
Usage | ||
----- | ||
|
||
.. code-block:: cpp | ||
old_val = atomic_exchange(ptr_to_value,new_value); | ||
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. | ||
|
||
Synopsis | ||
-------- | ||
|
||
.. code-block:: cpp | ||
template<class T> | ||
T atomic_exchange(T* const ptr_to_value, const T new_value); | ||
Description | ||
----------- | ||
|
||
- .. code-block:: cpp | ||
.. cppkokkos:function:: template<class T> T atomic_exchange(T* const ptr_to_value, const T new_value); | ||
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. | ||
|
||
Atomically executes ``old_value = *ptr_to_value; *ptr_to_value = new_value; return old_value;``. | ||
:param ptr_to_value: address of the value to be updated | ||
|
||
- ``ptr_to_value``: address of the to be updated value. | ||
- ``new_value``: new value. | ||
- ``old_value``: value at address ``ptr_to_value`` before doing the exchange. | ||
:param new_value: new value |