forked from kokkos/kokkos-core-wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kokkos#120: atomic_compare_exchange md to rst
- Loading branch information
1 parent
80d8a47
commit ab3302e
Showing
2 changed files
with
41 additions
and
32 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
``atomic_compare_exchange`` | ||
=========================== | ||
|
||
.. role::cpp(code) | ||
:language: cpp | ||
Header File: ``Kokkos_Core.hpp`` | ||
|
||
Usage: | ||
|
||
.. code-block:: cpp | ||
old_val = atomic_compare_exchange(ptr_to_value,comparison_value, new_value); | ||
Atomically sets the value at the address given by ``ptr_to_value`` to ``new_value`` if the current value at ``ptr_to_value`` | ||
is equal to ``comparison_value``, and returns the previously stored value at the address independent on whether | ||
the exchange has happened. | ||
|
||
Synopsis | ||
-------- | ||
|
||
.. code-block:: cpp | ||
template<class T> | ||
T atomic_compare_exchange(T* const ptr_to_value, const T comparison_value, const T new_value); | ||
Description | ||
----------- | ||
|
||
- .. code-block:: cpp | ||
|
||
template<class T> | ||
T atomic_compare_exchange(T* const ptr_to_value, const T comparison_value, const T new_value); | ||
|
||
Atomically executes ``old_value = *ptr_to_value; if(old_value==comparison_value) *ptr_to_value = new_value; return old_value;``. | ||
|
||
- ``ptr_to_value``: address of the to be updated value. | ||
- ``comparison_value``: value to be compared to. | ||
- ``new_value``: new value. | ||
- ``old_value``: value at address ``ptr_to_value`` before doing the exchange. |