Skip to content

Commit

Permalink
kokkos#120: atomic_compare_exchange md to rst
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay authored and fnrizzi committed Dec 10, 2023
1 parent 80d8a47 commit ab3302e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 32 deletions.
32 changes: 0 additions & 32 deletions docs/source/API/core/atomics/atomic_compare_exchange.md

This file was deleted.

41 changes: 41 additions & 0 deletions docs/source/API/core/atomics/atomic_compare_exchange.rst
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.

0 comments on commit ab3302e

Please sign in to comment.