Skip to content

fixed doc string for alpaka::Vec named components#505

Open
SimeonEhrig wants to merge 1 commit intoalpaka-group:devfrom
SimeonEhrig:fixVecNamedComponentsDocString
Open

fixed doc string for alpaka::Vec named components#505
SimeonEhrig wants to merge 1 commit intoalpaka-group:devfrom
SimeonEhrig:fixVecNamedComponentsDocString

Conversation

@SimeonEhrig
Copy link
Copy Markdown
Member

  • refactor macro ALPAKA_NAMED_ARRAY_ACCESS to avoid misunderstandings

Before the components was created with:

        ALPAKA_NAMED_ARRAY_ACCESS(x, 0u)
        ALPAKA_NAMED_ARRAY_ACCESS(y, 1u)
        ALPAKA_NAMED_ARRAY_ACCESS(z, 2u)
        ALPAKA_NAMED_ARRAY_ACCESS(w, 3u)

This was misleading because it look likes x would point to index position 0.

  • fixed doc string also for assignment and binary operators

- refactor macro `ALPAKA_NAMED_ARRAY_ACCESS` to avoid misunderstandings
- fixed doc string also for assignment and binary operators
@SimeonEhrig SimeonEhrig added bug Something isn't working documentation Improvements or additions to documentation refactoring This issue or pull request already exists labels Apr 23, 2026
@SimeonEhrig SimeonEhrig requested a review from ikbuibui April 23, 2026 09:39
Copy link
Copy Markdown
Member

@psychocoderHPC psychocoderHPC left a comment

Choose a reason for hiding this comment

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

a bug is introduced

Comment thread include/alpaka/Vec.hpp
#define ALPAKA_NAMED_ARRAY_ACCESS(functionName, dimValue) \
constexpr decltype(auto) functionName() requires(T_dim >= dimValue + 1) \
#define ALPAKA_NAMED_ARRAY_ACCESS(functionName, index_pos) \
constexpr decltype(auto) functionName() requires(index_pos >= 0) \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This introduces a bug. The index position is unsigned and using for the call DIM - 3u for w will be a large number if the vector is one dimensional and it will be allowed to call w() because the condition is true.
The requires must be indexPos < T_dim.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

or IndexPos >=0 && indexPos < T_dim because the other could throw a compiler error if dim is one.

Comment thread include/alpaka/Vec.hpp
*/
#define ALPAKA_NAMED_ARRAY_ACCESS(functionName, dimValue) \
constexpr decltype(auto) functionName() requires(T_dim >= dimValue + 1) \
#define ALPAKA_NAMED_ARRAY_ACCESS(functionName, index_pos) \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

index_pos should be indexPos because we use camelaCase not snake_case namings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation refactoring This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants