From 3408a7c4891b43db2a896ccb0a021cb1b42f12f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Mon, 8 Aug 2022 08:51:55 +0200 Subject: [PATCH] refactor to hope that the compiletime goes down --- test/unit/atomic/src/AtomicTest.cpp | 83 +++++++++++++---------------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/test/unit/atomic/src/AtomicTest.cpp b/test/unit/atomic/src/AtomicTest.cpp index 075721580ea6..3516e3a44a32 100644 --- a/test/unit/atomic/src/AtomicTest.cpp +++ b/test/unit/atomic/src/AtomicTest.cpp @@ -147,27 +147,7 @@ ALPAKA_FN_ACC auto testAtomicCas(TAcc const& acc, bool* success, T& operand, T o } } -//! check threads hierarchy -ALPAKA_NO_HOST_ACC_WARNING -template -ALPAKA_FN_ACC auto testAtomicHierarchies(TAcc const& acc, bool* success, T& operand, T operandOrig) -> void -{ - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); - testAtomicCombinations(acc, success, operand, operandOrig); -} - -//! check all alpaka hierarchies -ALPAKA_NO_HOST_ACC_WARNING -template -ALPAKA_FN_ACC auto testAtomicCasHierarchies(TAcc const& acc, bool* success, T& operand, T operandOrig) -> void -{ - testAtomicCas(acc, success, operand, operandOrig); - testAtomicCas(acc, success, operand, operandOrig); - testAtomicCas(acc, success, operand, operandOrig); -} - -template +template class AtomicTestKernel { public: @@ -176,30 +156,30 @@ class AtomicTestKernel { auto& operand = alpaka::declareSharedVar(acc); - testAtomicHierarchies(acc, success, operand, operandOrig); - testAtomicHierarchies(acc, success, operand, operandOrig); - testAtomicHierarchies(acc, success, operand, operandOrig); - testAtomicHierarchies(acc, success, operand, operandOrig); - testAtomicHierarchies(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, operand, operandOrig); - testAtomicHierarchies(acc, success, operand, operandOrig); - testAtomicHierarchies(acc, success, operand, operandOrig); - testAtomicHierarchies(acc, success, operand, operandOrig); + testAtomicCombinations(acc, success, operand, operandOrig); + testAtomicCombinations(acc, success, operand, operandOrig); + testAtomicCombinations(acc, success, operand, operandOrig); if constexpr(std::is_unsigned_v) { // atomicInc / atomicDec are implemented only for unsigned integer types - testAtomicHierarchies(acc, success, operand, operandOrig); - testAtomicHierarchies(acc, success, operand, operandOrig); + testAtomicCombinations(acc, success, operand, operandOrig); + testAtomicCombinations(acc, success, operand, operandOrig); } - testAtomicCasHierarchies(acc, success, operand, operandOrig); + testAtomicCas(acc, success, operand, operandOrig); } }; -template -class AtomicTestKernel>> +template +class AtomicTestKernel>> { public: ALPAKA_NO_HOST_ACC_WARNING @@ -207,23 +187,24 @@ class AtomicTestKernel>> { auto& operand = alpaka::declareSharedVar(acc); - testAtomicHierarchies(acc, success, operand, operandOrig); - testAtomicHierarchies(acc, success, operand, operandOrig); - testAtomicHierarchies(acc, success, operand, operandOrig); - testAtomicHierarchies(acc, success, operand, operandOrig); - testAtomicHierarchies(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, operand, operandOrig); // Inc, Dec, Or, And, Xor are not supported on float/double types - testAtomicCasHierarchies(acc, success, operand, operandOrig); + testAtomicCas(acc, success, operand, operandOrig); } }; #if(defined(ALPAKA_ACC_GPU_CUDA_ENABLED) && BOOST_LANG_CUDA) || (defined(ALPAKA_ACC_GPU_HIP_ENABLED) && BOOST_LANG_HIP) -template +template class AtomicTestKernel< + THierarchy, alpaka::AccGpuUniformCudaHipRt, T, std::enable_if_t> @@ -242,10 +223,12 @@ class AtomicTestKernel< #endif -#if defined(ALPAKA_ACC_ANY_BT_OACC_ENABLED) - -template -class AtomicTestKernel, T, std::enable_if_t> +template +class AtomicTestKernel< + THierarchy, + alpaka::AccOacc, + T, + std::enable_if_t> { public: ALPAKA_NO_HOST_ACC_WARNING @@ -269,8 +252,14 @@ struct TestAtomicOperations T value = static_cast(32); - AtomicTestKernel kernel; - REQUIRE(fixture(kernel, value)); + AtomicTestKernel kernelAtomicThreads; + REQUIRE(fixture(kernelAtomicThreads, value)); + + AtomicTestKernel kernelAtomicBlocks; + REQUIRE(fixture(kernelAtomicBlocks, value)); + + AtomicTestKernel kernelAtomicGrids; + REQUIRE(fixture(kernelAtomicGrids, value)); } };