Skip to content

test: refactor & add helpers for handling Views of arbitrary rank#221

Open
dssgabriel wants to merge 35 commits intokokkos:developfrom
dssgabriel:test/view-utils
Open

test: refactor & add helpers for handling Views of arbitrary rank#221
dssgabriel wants to merge 35 commits intokokkos:developfrom
dssgabriel:test/view-utils

Conversation

@dssgabriel
Copy link
Copy Markdown
Collaborator

@dssgabriel dssgabriel commented Mar 18, 2026

Description

Refactored implementation of view builder helpers and added new ones, all now MD-capable:

  • Refactored ViewBuilder struct into a free function (build_view) that allows building views of arbitrary type and dimension, contiguous or not.
  • Added view initialization (init_view) and error counting (count_error) helpers.

These changes make it possible to write only the high-level test function and pass different kinds of Views to it. Such tests better mirror user code that Kokkos Comm is designed to handle correctly.
It is now trivial to test views of higher dimensions (>2), contiguous or not (provided we support them)*.

*Note (rant)

We currently don't support non-contiguous Views of rank higher than 2 with the DeepCopy packing strategy due to limitations stemming from a similar implementation approach to the one refactored in this PR.

In (a) follow-up PR(s), all tests should be refactored to use this new mechanism. Additionally, this will let us easily enhance existing tests to actually assert the expected behavior of all the functionalities Kokkos Comm is designed to provide.

Additional context

Motivation
Initializing views and counting errors were the two problematic pieces of code that forced us to have dedicated test functions for each view dimension we wanted to test. The new helpers abstract away the required MD logic, letting us write simpler tests that are much more representative of what users would write.

Changes

  • Affected areas: unit tests
  • Breaking change(s)? no

Details:

  • Refactored ViewBuilder struct into a free function for building views of arbitrary type and dimension (contiguous or not)
  • Added view initialization and error counting helpers (MD-capable)
  • Wrapped the helpers in a test_utils:: namespace
  • Removed redundant view_builder.hpp and consolidated logic into view_utils.hpp
  • Updated dependent tests in unit_tests/test_sendrecv.cpp

Checklist

  • Tests are up-to-date
  • Documentation is up-to-date

Simple wrapper of `int` with UDL for easy creation
Makes the code much easier to read for functions with attributes and
long type/param/tparam names.
Signed-off-by: Gabriel Dos Santos <gabriel.dossantos@cea.fr>
Signed-off-by: Gabriel Dos Santos <gabriel.dossantos@cea.fr>
Signed-off-by: Gabriel Dos Santos <gabriel.dossantos@cea.fr>
Signed-off-by: Gabriel Dos Santos <gabriel.dossantos@cea.fr>
Signed-off-by: Gabriel Dos Santos <gabriel.dossantos@cea.fr>
Signed-off-by: Gabriel Dos Santos <gabriel.dossantos@cea.fr>
Signed-off-by: Gabriel Dos Santos <gabriel.dossantos@cea.fr>
`do_iteration` was taking its variadic arguments by value, causing the
compiler to attempt a copy of any argument passed to it. This triggered
a compile error when passing a `Communicator`, whose copy constructor is
deleted by design.

Fixed by taking `Args&&...` and forwarding with
`std::forward<Args>(args)...`.
Correctly replace `exec_` with the passed in `exec` parameter.
Directly call the factory `split` instead of factory `duplicate`, since
member functions can access their rank without having to recompute it.
For both MPI and NCCL specializations, covers:
- Factory functions (`from_raw`, `duplicate`, `split`);
- Accessors (`comm`, `size`, `rank`);
- Move semantics.
Some drive-by updates:
- Removed mentions of `barrier` in the core API
- Fixed mentions of ~~`Req`~~ -> `Request`
This could lead to a compilation error if both MPI and NCCL backends
were enabled at the same time, where `DefaultCommunicationSpace` would
be defined twice.
Now, we ensure it is only defined once. NCCL takes precedence over MPI
if it has been enabled.
@dssgabriel dssgabriel self-assigned this Mar 18, 2026
@dssgabriel dssgabriel added C-enhancement Category: an enhancement or bug fix A-unit-tests Area: KokkosComm unit tests labels Mar 18, 2026
Update tests and docs.
Remove `std::optional` from `from_raw` signature.
Add unit tests for exec() accessor, self-move assignment safety,
duplicate independence chain, and sequential splits.
@dssgabriel dssgabriel changed the title test: refactor & add new MD-capable helpers for handling Views test: refactor & add helpers for handling Views of arbitrary rank Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-unit-tests Area: KokkosComm unit tests C-enhancement Category: an enhancement or bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant