Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atomic Unit tests for Dec and Inc not check edge cases #1769

Open
psychocoderHPC opened this issue Jul 27, 2022 · 0 comments · May be fixed by #1772
Open

atomic Unit tests for Dec and Inc not check edge cases #1769

psychocoderHPC opened this issue Jul 27, 2022 · 0 comments · May be fixed by #1772

Comments

@psychocoderHPC
Copy link
Member

psychocoderHPC commented Jul 27, 2022

The unit test for atomicDec is not testing the flip around based on the values.

ref = (((old == 0) || (old > value)) ? value : static_cast<T>(old - 1));

Some for atomicInc

ref = ((old >= value) ? 0 : static_cast<T>(old + 1));

We simply test if an value is incremented or decremented:

ALPAKA_NO_HOST_ACC_WARNING
template<typename TAcc, typename T>
ALPAKA_FN_ACC auto testAtomicInc(TAcc const& acc, bool* success, T operandOrig) -> void
{
// \TODO: Check reset to 0 at 'value'.
T const value = static_cast<T>(42);
T const reference = static_cast<T>(operandOrig + 1);
auto& operand = alpaka::declareSharedVar<T, __COUNTER__>(acc);
{
operand = operandOrig;
T const ret = alpaka::atomicOp<alpaka::AtomicInc>(acc, &operand, value);
ALPAKA_CHECK(*success, equals(operandOrig, ret));
ALPAKA_CHECK(*success, equals(operand, reference));
}
{
operand = operandOrig;
T const ret = alpaka::atomicInc(acc, &operand, value);
ALPAKA_CHECK(*success, equals(operandOrig, ret));
ALPAKA_CHECK(*success, equals(operand, reference));
}
}
ALPAKA_NO_HOST_ACC_WARNING
template<typename TAcc, typename T>
ALPAKA_FN_ACC auto testAtomicDec(TAcc const& acc, bool* success, T operandOrig) -> void
{
// \TODO: Check reset to 'value' at 0.
T const value = static_cast<T>(42);
T const reference = static_cast<T>(operandOrig - 1);
auto& operand = alpaka::declareSharedVar<T, __COUNTER__>(acc);
{
operand = operandOrig;
T const ret = alpaka::atomicOp<alpaka::AtomicDec>(acc, &operand, value);
ALPAKA_CHECK(*success, equals(operandOrig, ret));
ALPAKA_CHECK(*success, equals(operand, reference));
}
{
operand = operandOrig;
T const ret = alpaka::atomicDec(acc, &operand, value);
ALPAKA_CHECK(*success, equals(operandOrig, ret));
ALPAKA_CHECK(*success, equals(operand, reference));
}
}

psychocoderHPC added a commit to psychocoderHPC/alpaka that referenced this issue Aug 3, 2022
fix alpaka-group#1769

- test all hierarchies which can be used for atomics
- extent test cases to test for equal, smaller, larger and zero as left
side operand
- test calling `atomic*()` and `atomicOp<*>()`
@psychocoderHPC psychocoderHPC linked a pull request Aug 3, 2022 that will close this issue
psychocoderHPC added a commit to psychocoderHPC/alpaka that referenced this issue Aug 3, 2022
fix alpaka-group#1769

- test all hierarchies which can be used for atomics
- extent test cases to test for equal, smaller, larger and zero as left
side operand
- test calling `atomic*()` and `atomicOp<*>()`
psychocoderHPC added a commit to psychocoderHPC/alpaka that referenced this issue Aug 3, 2022
fix alpaka-group#1769

- test all hierarchies which can be used for atomics
- extent test cases to test for equal, smaller, larger and zero as left
side operand
- test calling `atomic*()` and `atomicOp<*>()`
psychocoderHPC added a commit to psychocoderHPC/alpaka that referenced this issue Aug 3, 2022
fix alpaka-group#1769

- test all hierarchies which can be used for atomics
- extent test cases to test for equal, smaller, larger and zero as left
side operand
- test calling `atomic*()` and `atomicOp<*>()`
psychocoderHPC added a commit to psychocoderHPC/alpaka that referenced this issue Aug 3, 2022
fix alpaka-group#1769

- test all hierarchies which can be used for atomics
- extent test cases to test for equal, smaller, larger and zero as left
side operand
- test calling `atomic*()` and `atomicOp<*>()`
psychocoderHPC added a commit to psychocoderHPC/alpaka that referenced this issue Aug 4, 2022
fix alpaka-group#1769

- test all hierarchies which can be used for atomics
- extent test cases to test for equal, smaller, larger and zero as left
side operand
- test calling the atomic interface `atomic*()` and `atomicOp<*>()`
@j-stephan j-stephan added this to To do in Release 1.0 via automation Sep 2, 2022
@bernhardmgruber bernhardmgruber removed this from To do in Release 1.0 Dec 9, 2022
psychocoderHPC added a commit to psychocoderHPC/alpaka that referenced this issue Jan 22, 2024
fix alpaka-group#1769

- test all hierarchies which can be used for atomics
- extent test cases to test for equal, smaller, larger and zero as left
side operand
- test calling the atomic interface `atomic*()` and `atomicOp<*>()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant