Skip to content

Commit

Permalink
test broken openACC out of mem
Browse files Browse the repository at this point in the history
  • Loading branch information
psychocoderHPC committed Aug 8, 2022
1 parent e1f7e91 commit d95dbb9
Showing 1 changed file with 40 additions and 45 deletions.
85 changes: 40 additions & 45 deletions test/unit/atomic/src/AtomicTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ ALPAKA_FN_INLINE ALPAKA_FN_HOST_ACC auto equals(double a, double b) -> bool

ALPAKA_NO_HOST_ACC_WARNING
template<typename THierarchy, typename TOp, typename TAcc, typename T>
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<T, __COUNTER__>(acc);

// check if the function `alpaka::atomicOp<*>` is callable
{
// left operand is half of the right
operand = operandOrig;
T reference = operand;
op(&reference, value);
Expand All @@ -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);
Expand All @@ -77,29 +77,26 @@ ALPAKA_FN_ACC auto testAtomicCall(TAcc const& acc, bool* success, T& operand, T

ALPAKA_NO_HOST_ACC_WARNING
template<typename THierarchy, typename TOp, typename TAcc, typename T>
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<T>(1);
T constexpr two = static_cast<T>(2);
{
// left operand is half of the right
T const value = static_cast<T>(operandOrig / two);
T const value = static_cast<T>(operandOrig / static_cast<T>(2));
testAtomicCall<THierarchy, TOp>(acc, success, operand, operandOrig, value);
}
{
// left operand is twice as large as the right
T const value = static_cast<T>(operandOrig * two);
T const value = static_cast<T>(operandOrig * static_cast<T>(2));
testAtomicCall<THierarchy, TOp>(acc, success, operand, operandOrig, value);
}
{
// left operand is larger by one
T const value = static_cast<T>(operandOrig + one);
T const value = static_cast<T>(operandOrig + static_cast<T>(1));
testAtomicCall<THierarchy, TOp>(acc, success, operand, operandOrig, value);
}
{
// left operand is smaller by one
T const value = static_cast<T>(operandOrig - one);
T const value = static_cast<T>(operandOrig - static_cast<T>(1));
testAtomicCall<THierarchy, TOp>(acc, success, operand, operandOrig, value);
}
{
Expand All @@ -111,10 +108,12 @@ ALPAKA_FN_ACC auto testAtomicCombinations(TAcc const& acc, bool* success, T& ope

ALPAKA_NO_HOST_ACC_WARNING
template<typename THierarchy, typename TAcc, typename T>
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<T>(4);

auto& operand = alpaka::declareSharedVar<T, __COUNTER__>(acc);

// with match
{
T const compare = operandOrig;
Expand Down Expand Up @@ -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<T, __COUNTER__>(acc);

testAtomicCombinations<THierarchy, Add>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Sub>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Exch>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Min>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Max>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Add>(acc, success, operandOrig);
testAtomicCombinations<THierarchy, Sub>(acc, success, operandOrig);
testAtomicCombinations<THierarchy, Exch>(acc, success, operandOrig);
testAtomicCombinations<THierarchy, Min>(acc, success, operandOrig);
testAtomicCombinations<THierarchy, Max>(acc, success, operandOrig);

testAtomicCombinations<THierarchy, And>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Or>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Xor>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, And>(acc, success, operandOrig);
testAtomicCombinations<THierarchy, Or>(acc, success, operandOrig);
testAtomicCombinations<THierarchy, Xor>(acc, success, operandOrig);

testAtomicCombinations<THierarchy, Inc>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Dec>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Inc>(acc, success, operandOrig);
testAtomicCombinations<THierarchy, Dec>(acc, success, operandOrig);

testAtomicCas<THierarchy>(acc, success, operand, operandOrig);
testAtomicCas<THierarchy>(acc, success, operandOrig);
}
};

Expand All @@ -186,17 +183,15 @@ class AtomicTestKernel<THierarchy, TAcc, T, std::enable_if_t<std::is_floating_po
ALPAKA_NO_HOST_ACC_WARNING
ALPAKA_FN_ACC auto operator()(TAcc const& acc, bool* success, T operandOrig) const -> void
{
auto& operand = alpaka::declareSharedVar<T, __COUNTER__>(acc);

testAtomicCombinations<THierarchy, Add>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Sub>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Exch>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Min>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Max>(acc, success, operand, operandOrig);
testAtomicCombinations<THierarchy, Add>(acc, success, operandOrig);
testAtomicCombinations<THierarchy, Sub>(acc, success, operandOrig);
testAtomicCombinations<THierarchy, Exch>(acc, success, operandOrig);
testAtomicCombinations<THierarchy, Min>(acc, success, operandOrig);
testAtomicCombinations<THierarchy, Max>(acc, success, operandOrig);

// Inc, Dec, Or, And, Xor are not supported on float/double types

testAtomicCas<THierarchy>(acc, success, operand, operandOrig);
testAtomicCas<THierarchy>(acc, success, operandOrig);
}
};

Expand Down Expand Up @@ -256,13 +251,13 @@ struct TestAtomicOperations
alpaka::test::KernelExecutionFixture<TAcc> fixture(alpaka::Vec<Dim, Idx>::ones());

T value = static_cast<T>(32);

#if 0
AtomicTestKernel<alpaka::hierarchy::Threads, TAcc, T> kernelAtomicThreads;
REQUIRE(fixture(kernelAtomicThreads, value));

AtomicTestKernel<alpaka::hierarchy::Blocks, TAcc, T> kernelAtomicBlocks;
REQUIRE(fixture(kernelAtomicBlocks, value));

#endif
AtomicTestKernel<alpaka::hierarchy::Grids, TAcc, T> kernelAtomicGrids;
REQUIRE(fixture(kernelAtomicGrids, value));
}
Expand All @@ -274,19 +269,19 @@ TEMPLATE_LIST_TEST_CASE("atomicOperationsWorking", "[atomic]", TestAccs)
{
using Acc = TestType;

TestAtomicOperations<Acc, unsigned char>::testAtomicOperations();
TestAtomicOperations<Acc, char>::testAtomicOperations();
TestAtomicOperations<Acc, unsigned short>::testAtomicOperations();
TestAtomicOperations<Acc, short>::testAtomicOperations();
// TestAtomicOperations<Acc, unsigned char>::testAtomicOperations();
// TestAtomicOperations<Acc, char>::testAtomicOperations();
// TestAtomicOperations<Acc, unsigned short>::testAtomicOperations();
// TestAtomicOperations<Acc, short>::testAtomicOperations();

TestAtomicOperations<Acc, unsigned int>::testAtomicOperations();
TestAtomicOperations<Acc, int>::testAtomicOperations();

TestAtomicOperations<Acc, unsigned long>::testAtomicOperations();
TestAtomicOperations<Acc, long>::testAtomicOperations();
TestAtomicOperations<Acc, unsigned long long>::testAtomicOperations();
TestAtomicOperations<Acc, long long>::testAtomicOperations();
// TestAtomicOperations<Acc, unsigned long>::testAtomicOperations();
// TestAtomicOperations<Acc, long>::testAtomicOperations();
// TestAtomicOperations<Acc, unsigned long long>::testAtomicOperations();
// TestAtomicOperations<Acc, long long>::testAtomicOperations();

TestAtomicOperations<Acc, float>::testAtomicOperations();
TestAtomicOperations<Acc, double>::testAtomicOperations();
// TestAtomicOperations<Acc, float>::testAtomicOperations();
// TestAtomicOperations<Acc, double>::testAtomicOperations();
}

0 comments on commit d95dbb9

Please sign in to comment.