Skip to content

Conversation

@psychocoderHPC
Copy link
Member

@psychocoderHPC psychocoderHPC commented Aug 3, 2022

clang CUDA is exposing atomic*_block() function signatures even if these can not be used by the selected architecture.
This leads to compile issues if clang is used as CUDA compiler.

Our tests cases have not checked all combinations of atomics, therefore the second commit refactors the atomic tests and fixes #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 force-pushed the fix-atomics branch 7 times, most recently from a5cb324 to 5e233b9 Compare August 5, 2022 14:49
@psychocoderHPC psychocoderHPC marked this pull request as draft August 5, 2022 14:59
@psychocoderHPC psychocoderHPC force-pushed the fix-atomics branch 8 times, most recently from d95dbb9 to 3e773d2 Compare August 8, 2022 08:53
@psychocoderHPC
Copy link
Member Author

For an unknown reason, the OpenACC test shows access to invalid memory and HIP requires over 60 minutes to compile the atomic test.

using Op = alpaka::AtomicAdd;

template<typename... TArgs>
static ALPAKA_FN_ACC auto atomic(TArgs&&... args)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkelling found out that this variadic template usage is the root of the nvhpc error (invalid memory access)

@psychocoderHPC
Copy link
Member Author

The fix for atomics is already merged with #1773.
Still open is to extent the test and check if we still run into the issue that compiling tests takes ages.

@psychocoderHPC psychocoderHPC changed the title fix clang CUDA atomics and refactor atomic tests CIrefactor atomic tests Sep 8, 2023
@psychocoderHPC psychocoderHPC changed the title CIrefactor atomic tests CI: refactor and extend atomic tests Sep 8, 2023
Atomic decrement implemented

```C++
((old >= value) ? 0 : static_cast<T>(old - 1))
```

instead of

```C++
(old == static_cast<T>(0) || old > value) ? value : static_cast<T>(old - static_cast<T>(1))
```
@psychocoderHPC
Copy link
Member Author

Note the reason why this PR was never merged is that old HIP compilers running into stack issues and the compile time was increasing to an unacceptable time.

- add define `ALPAKA_ARCH_AMD` as replacement for `ALPAKA_COMP_HIP`
- set for backwards compatibility `ALPAKA_COMP_HIP` to `ALPAKA_ARCH_AMD`
- `ALPAKA_ARCH_AMD` behaves like `ALPAKA_ARCH_PTX` and provides the
  AMD architecture as version number
- move pre-prozessor version number generators to own file
- add more/better tests for the version macros
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<*>()`
Clang for HIP as problems if we have all atomic tests within one kernel
and throws the compiler error: `error: stack size limit exceeded (155632) in _ZN6alpaka16uniform_cuda_hip6de`, therefore we split the tests into multiple kernel to workaround the issue.
@psychocoderHPC psychocoderHPC requested review from a team and SimeonEhrig and removed request for SimeonEhrig November 27, 2025 13:01
@psychocoderHPC psychocoderHPC added this to the 2.1.0 milestone Nov 27, 2025
@psychocoderHPC
Copy link
Member Author

I rebased the PR against the latest dev, including the fix in #2582

@psychocoderHPC psychocoderHPC marked this pull request as ready for review November 27, 2025 13:02
psychocoderHPC added a commit to psychocoderHPC/alpaka3 that referenced this pull request Nov 27, 2025
Moving over the never merged atomic test from alpaka mainline alpaka-group/alpaka#1772
psychocoderHPC added a commit to psychocoderHPC/alpaka3 that referenced this pull request Nov 27, 2025
Moving over the never merged atomic test from alpaka mainline alpaka-group/alpaka#1772
psychocoderHPC added a commit to psychocoderHPC/alpaka3 that referenced this pull request Nov 27, 2025
Moving over the never merged atomic test from alpaka mainline alpaka-group/alpaka#1772
psychocoderHPC added a commit to psychocoderHPC/alpaka3 that referenced this pull request Nov 27, 2025
Moving over the never merged atomic test from alpaka mainline alpaka-group/alpaka#1772
psychocoderHPC added a commit to psychocoderHPC/alpaka3 that referenced this pull request Nov 27, 2025
Moving over the never merged atomic test from alpaka mainline alpaka-group/alpaka#1772
psychocoderHPC added a commit to psychocoderHPC/alpaka3 that referenced this pull request Nov 28, 2025
Moving over the never merged atomic test from alpaka mainline alpaka-group/alpaka#1772
@psychocoderHPC psychocoderHPC force-pushed the fix-atomics branch 2 times, most recently from 8158db5 to 194411c Compare November 28, 2025 09:34
@psychocoderHPC
Copy link
Member Author

I refactored the test gain and hope that HIP is not running into the wall time anymore.
Each operation is now performed within its own kernel, which should simplify the work for the compiler.

psychocoderHPC added a commit to psychocoderHPC/alpaka3 that referenced this pull request Nov 28, 2025
Moving over the never merged atomic test from alpaka mainline alpaka-group/alpaka#1772
@psychocoderHPC psychocoderHPC force-pushed the fix-atomics branch 2 times, most recently from 18a7522 to da14a7f Compare November 28, 2025 10:21
Change the test structore that each atomic operation is tested within
its own kernel to workaround compiler issues with HIP.
HIP 6.0 - 6.2 running in the CI into walltime limits because the compile
time explodes due to the test.
ikbuibui pushed a commit to alpaka-group/alpaka3 that referenced this pull request Nov 28, 2025
* fix `atomicDec()` and test all atomic operations

Moving over the never merged atomic test from alpaka mainline alpaka-group/alpaka#1772

* apply review comments
@psychocoderHPC psychocoderHPC modified the milestones: 2.1.0, 2.2.0 Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

atomic Unit tests for Dec and Inc not check edge cases

1 participant