vtk-m2/vtkm/testing
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
..
CMakeLists.txt Add atomic free functions 2020-08-20 13:40:43 -06:00
Testing.h clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
UnitTestAlgorithms.cxx Consolidate tests for base vtkm code that is device-specific 2020-08-18 14:30:25 -06:00
UnitTestAtomic.cxx Change interface of atomic compare and swap 2020-10-20 08:39:22 -06:00
UnitTestBinaryOperators.cxx Make BinaryOperators/Predicates more flexible. 2019-12-18 15:51:59 -05:00
UnitTestBinaryPredicates.cxx added missing MinAndMax BinaryOperator tests, updated formatting 2019-04-30 09:43:17 -06:00
UnitTestBounds.cxx Update VTK-m code to use new Vec aliases 2019-07-31 12:55:40 -06:00
UnitTestCellShape.cxx conslidate the license statement 2019-04-17 10:57:13 -06:00
UnitTestDeprecated.cxx Fix warnings 2020-08-12 13:55:24 -04:00
UnitTestExceptions.cxx RuntimeDeviceTracker can't be copied and is only accessible via reference. 2019-05-20 11:43:05 -04:00
UnitTestGeometry.cxx clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
UnitTestHash.cxx Update VTK-m code to use new Vec aliases 2019-07-31 12:55:40 -06:00
UnitTestList.cxx More testing of long lists 2020-01-09 10:33:49 -07:00
UnitTestListTag.cxx Implement old ListTag features with new ListTag implementations 2019-12-08 19:20:34 -07:00
UnitTestMath.cxx clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
UnitTestMatrix.cxx clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
UnitTestNewtonsMethod.cxx conslidate the license statement 2019-04-17 10:57:13 -06:00
UnitTestNoAssert.cxx clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
UnitTestPair.cxx Update lists in TypeListTag.h 2019-12-05 11:05:19 -07:00
UnitTestRange.cxx conslidate the license statement 2019-04-17 10:57:13 -06:00
UnitTestTesting.cxx conslidate the license statement 2019-04-17 10:57:13 -06:00
UnitTestTransform3D.cxx Update lists in TypeListTag.h 2019-12-05 11:05:19 -07:00
UnitTestTuple.cxx Add vtkmstd::integer_sequence 2020-03-16 17:12:16 -06:00
UnitTestTypeList.cxx Remove instances of ListTag in favor of List 2019-12-06 21:32:36 -07:00
UnitTestTypeListTag.cxx Remove instances of ListTag in favor of List 2019-12-06 21:32:36 -07:00
UnitTestTypes.cxx Deprecate ListTag operations 2019-12-05 11:27:31 -05:00
UnitTestTypeTraits.cxx conslidate the license statement 2019-04-17 10:57:13 -06:00
UnitTestUnaryPredicates.cxx added missing MinAndMax BinaryOperator tests, updated formatting 2019-04-30 09:43:17 -06:00
UnitTestVecAxisAlignedPointCoordinates.cxx Update VTK-m code to use new Vec aliases 2019-07-31 12:55:40 -06:00
UnitTestVecFromPortal.cxx Update lists in TypeListTag.h 2019-12-05 11:05:19 -07:00
UnitTestVecFromPortalPermute.cxx Update lists in TypeListTag.h 2019-12-05 11:05:19 -07:00
UnitTestVectorAnalysis.cxx Update lists in TypeListTag.h 2019-12-05 11:05:19 -07:00
UnitTestVecTraits.cxx clang-format: reformat the repository with clang-format-9 2020-08-24 14:01:08 -04:00
UnitTestVecVariable.cxx Update lists in TypeListTag.h 2019-12-05 11:05:19 -07:00
VecTraitsTests.h Add recursive component queries to VecTraits 2019-09-09 08:19:15 -06:00