vtk-m2/vtkm/exec
Kenneth Moreland 28ecf3636d Change interface of atomic compare and swap
The old atomic compare and swap operations (`vtkm::AtomicCompareAndSwap`
and `vtkm::exec::AtomicArrayExecutionObject::CompareAndSwap`) had an
order of arguments that was confusing. The order of the arguments was
shared pointer (or index), desired value, expected value. Most people
probably assume expected value comes before desired value. And this
order conflicts with the order in the `std` methods, GCC atomics, and
Kokkos.

Change the interface of atomic operations to be patterned off the
`std::atomic_compare_exchange` and `std::atomic<T>::compare_exchange`
methods. First, these methods have a more intuitive order of parameters
(shared pointer, expected, desired). Second, rather than take a value
for the expected and return the actual old value, they take a pointer to
the expected value (or reference in `AtomicArrayExecutionObject`) and
modify this value in the case that it does not match the actual value.
This makes it harder to mix up the expected and desired parameters.
Also, because the methods return a bool indicating whether the value was
changed, there is an additional benefit that compare-exchange loops are
implemented easier.

For example, consider you want to apply the function `MyOp` on a
`sharedValue` atomically. With the old interface, you would have to do
something like this.

```cpp
T oldValue;
T newValue;
do
{
  oldValue = *sharedValue;
  newValue = MyOp(oldValue);
} while (vtkm::AtomicCompareAndSwap(sharedValue, newValue, oldValue) != oldValue);
```

With the new interface, this is simplfied to this.

```cpp
T oldValue = *sharedValue;
while (!vtkm::AtomicCompareExchange(sharedValue, &oldValue, MyOp(oldValue));
```
2020-10-20 08:39:22 -06:00
..
arg Update ConnectivityExtrude to follow clangs rules on markup 2020-09-25 09:37:46 -04:00
cuda clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
internal clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
kokkos Add Kokkos backend 2020-08-12 13:55:24 -04:00
openmp Label tests which exercise a given Device Adapter 2019-09-13 15:52:40 -04:00
serial Remove ArrayHandleStreaming capabilities 2020-03-24 15:01:56 -06:00
tbb Label tests which exercise a given Device Adapter 2019-09-13 15:52:40 -04:00
testing clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
AtomicArrayExecutionObject.h Change interface of atomic compare and swap 2020-10-20 08:39:22 -06:00
BoundaryState.h Optimize StructuredPointGradient for non boundary points. 2020-05-22 14:58:38 -04:00
CellDerivative.h Remove some unneeded include statements from vtkm/exec 2020-06-22 09:28:51 -04:00
CellEdge.h Remove some unneeded include statements from vtkm/exec 2020-06-22 09:28:51 -04:00
CellFace.h clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
CellInside.h Switch from VTK-c to LCL 2019-10-07 15:38:36 -04:00
CellInterpolate.h Remove some unneeded include statements from vtkm/exec 2020-06-22 09:28:51 -04:00
CellLocator.h Deprecation macro has to come before VTKM_EXEC or VTKM_EXEC_CONT 2020-09-23 10:02:37 -04:00
CellLocatorBoundingIntervalHierarchyExec.h clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
CellLocatorRectilinearGrid.h Fix for small euler step for particle advection. 2020-04-23 16:14:28 -04:00
CellLocatorTwoLevel.h Rename CellLocatorUniformBins to CellLocatorTwoLevel 2020-09-21 15:42:47 -06:00
CellLocatorUniformGrid.h CoordinateSystem data is VariantArrayHandle 2020-07-14 08:50:39 -06:00
CellMeasure.h clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
CMakeLists.txt Rename CellLocatorUniformBins to CellLocatorTwoLevel 2020-09-21 15:42:47 -06:00
ColorTable.h Remove virtual methods from ColorTable 2020-09-14 13:26:16 -06:00
ColorTable.hxx Fix warning about return value 2020-09-14 15:04:03 -06:00
ConnectivityExplicit.h Refactor CellSetExplicit to remove NumIndices. 2019-09-30 12:27:13 -04:00
ConnectivityExtrude.h Update ConnectivityExtrude to follow clangs rules on markup 2020-09-25 09:37:46 -04:00
ConnectivityPermuted.h Correct warnings found by GCC 9.2 2019-12-02 09:33:35 -05:00
ConnectivityStructured.h Add CellNeighborhood 2020-07-15 14:41:32 -06:00
ExecutionWholeArray.h Support using Token calling PrepareForExecution in ExecutionObject 2020-02-25 07:41:39 -07:00
FieldNeighborhood.h Add CellNeighborhood 2020-07-15 14:41:32 -06:00
FunctorBase.h Always export VTK-m functor symbols 2019-08-01 12:53:54 -04:00
ParametricCoordinates.h Make sure return value of cell operations is initialized 2020-03-14 00:24:13 -06:00
PointLocator.h Update VTK-m code to use new Vec aliases 2019-07-31 12:55:40 -06:00
PointLocatorSparseGrid.h Rename PointLocatorUniformGrid to PointLocatorSparseGrid 2020-09-21 15:42:41 -06:00
TaskBase.h conslidate the license statement 2019-04-17 10:57:13 -06:00