diff --git a/test/unit/atomic/src/AtomicTest.cpp b/test/unit/atomic/src/AtomicTest.cpp index ab833f57de4e..1e2c00cd6513 100644 --- a/test/unit/atomic/src/AtomicTest.cpp +++ b/test/unit/atomic/src/AtomicTest.cpp @@ -42,13 +42,14 @@ ALPAKA_FN_INLINE ALPAKA_FN_HOST_ACC auto equals(double a, double b) -> bool ALPAKA_NO_HOST_ACC_WARNING template -ALPAKA_FN_ACC auto testAtomicCall(TAcc const& acc, bool* success, T& operand, T operandOrig, T value) -> void +ALPAKA_FN_ACC auto testAtomicCall(TAcc const& acc, bool* success, T operandOrig, T value) -> void { auto op = typename TOp::Op{}; + auto& operand = alpaka::declareSharedVar(acc); + // check if the function `alpaka::atomicOp<*>` is callable { - // left operand is half of the right operand = operandOrig; T reference = operand; op(&reference, value); @@ -62,7 +63,6 @@ ALPAKA_FN_ACC auto testAtomicCall(TAcc const& acc, bool* success, T& operand, T // check if the function `alpaka::atomic*()` is callable { - // left operand is half of the right operand = operandOrig; T reference = operand; op(&reference, value); @@ -77,44 +77,43 @@ ALPAKA_FN_ACC auto testAtomicCall(TAcc const& acc, bool* success, T& operand, T ALPAKA_NO_HOST_ACC_WARNING template -ALPAKA_FN_ACC auto testAtomicCombinations(TAcc const& acc, bool* success, T& operand, T operandOrig) -> void +ALPAKA_FN_ACC auto testAtomicCombinations(TAcc const& acc, bool* success, T operandOrig) -> void { - // helper variables to avoid compiler conversion warnings/errors - T constexpr one = static_cast(1); - T constexpr two = static_cast(2); { // left operand is half of the right - T const value = static_cast(operandOrig / two); - testAtomicCall(acc, success, operand, operandOrig, value); + T const value = static_cast(operandOrig / static_cast(2)); + testAtomicCall(acc, success, operandOrig, value); } { // left operand is twice as large as the right - T const value = static_cast(operandOrig * two); - testAtomicCall(acc, success, operand, operandOrig, value); + T const value = static_cast(operandOrig * static_cast(2)); + testAtomicCall(acc, success, operandOrig, value); } { // left operand is larger by one - T const value = static_cast(operandOrig + one); - testAtomicCall(acc, success, operand, operandOrig, value); + T const value = static_cast(operandOrig + static_cast(1)); + testAtomicCall(acc, success, operandOrig, value); } { // left operand is smaller by one - T const value = static_cast(operandOrig - one); - testAtomicCall(acc, success, operand, operandOrig, value); + T const value = static_cast(operandOrig - static_cast(1)); + testAtomicCall(acc, success, operandOrig, value); } { // both operands are equal T const value = operandOrig; - testAtomicCall(acc, success, operand, operandOrig, value); + testAtomicCall(acc, success, operandOrig, value); } } ALPAKA_NO_HOST_ACC_WARNING template -ALPAKA_FN_ACC auto testAtomicCas(TAcc const& acc, bool* success, T& operand, T operandOrig) -> void +ALPAKA_FN_ACC auto testAtomicCas(TAcc const& acc, bool* success, T operandOrig) -> void { T const value = static_cast(4); + auto& operand = alpaka::declareSharedVar(acc); + // with match { T const compare = operandOrig; @@ -159,22 +158,20 @@ class AtomicTestKernel ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_ACC auto operator()(TAcc const& acc, bool* success, T operandOrig) const -> void { - auto& operand = alpaka::declareSharedVar(acc); - - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); + testAtomicCombinations(acc, success, operandOrig); + testAtomicCombinations(acc, success, operandOrig); + testAtomicCombinations(acc, success, operandOrig); + testAtomicCombinations(acc, success, operandOrig); + testAtomicCombinations(acc, success, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); + testAtomicCombinations(acc, success, operandOrig); + testAtomicCombinations(acc, success, operandOrig); + testAtomicCombinations(acc, success, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); + testAtomicCombinations(acc, success, operandOrig); + testAtomicCombinations(acc, success, operandOrig); - testAtomicCas(acc, success, operand, operandOrig); + testAtomicCas(acc, success, operandOrig); } }; @@ -186,17 +183,15 @@ class AtomicTestKernel void { - auto& operand = alpaka::declareSharedVar(acc); - - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); + testAtomicCombinations(acc, success, operandOrig); + testAtomicCombinations(acc, success, operandOrig); + testAtomicCombinations(acc, success, operandOrig); + testAtomicCombinations(acc, success, operandOrig); + testAtomicCombinations(acc, success, operandOrig); // Inc, Dec, Or, And, Xor are not supported on float/double types - testAtomicCas(acc, success, operand, operandOrig); + testAtomicCas(acc, success, operandOrig); } }; @@ -256,13 +251,13 @@ struct TestAtomicOperations alpaka::test::KernelExecutionFixture fixture(alpaka::Vec::ones()); T value = static_cast(32); - +#if 0 AtomicTestKernel kernelAtomicThreads; REQUIRE(fixture(kernelAtomicThreads, value)); AtomicTestKernel kernelAtomicBlocks; REQUIRE(fixture(kernelAtomicBlocks, value)); - +#endif AtomicTestKernel kernelAtomicGrids; REQUIRE(fixture(kernelAtomicGrids, value)); } @@ -274,19 +269,19 @@ TEMPLATE_LIST_TEST_CASE("atomicOperationsWorking", "[atomic]", TestAccs) { using Acc = TestType; - TestAtomicOperations::testAtomicOperations(); - TestAtomicOperations::testAtomicOperations(); - TestAtomicOperations::testAtomicOperations(); - TestAtomicOperations::testAtomicOperations(); + // TestAtomicOperations::testAtomicOperations(); + // TestAtomicOperations::testAtomicOperations(); + // TestAtomicOperations::testAtomicOperations(); + // TestAtomicOperations::testAtomicOperations(); TestAtomicOperations::testAtomicOperations(); TestAtomicOperations::testAtomicOperations(); - TestAtomicOperations::testAtomicOperations(); - TestAtomicOperations::testAtomicOperations(); - TestAtomicOperations::testAtomicOperations(); - TestAtomicOperations::testAtomicOperations(); + // TestAtomicOperations::testAtomicOperations(); + // TestAtomicOperations::testAtomicOperations(); + // TestAtomicOperations::testAtomicOperations(); + // TestAtomicOperations::testAtomicOperations(); - TestAtomicOperations::testAtomicOperations(); - TestAtomicOperations::testAtomicOperations(); + // TestAtomicOperations::testAtomicOperations(); + // TestAtomicOperations::testAtomicOperations(); }