Skip to content

feat(core): add contiguous packing support for Views of arbitrary rank#222

Open
dssgabriel wants to merge 6 commits intokokkos:developfrom
dssgabriel:feature/md-contiguous-packing
Open

feat(core): add contiguous packing support for Views of arbitrary rank#222
dssgabriel wants to merge 6 commits intokokkos:developfrom
dssgabriel:feature/md-contiguous-packing

Conversation

@dssgabriel
Copy link
Copy Markdown
Collaborator

Description

Refactors the contiguous packing infrastructure to add support for Views of any dimensions using variadic templates, replacing the previous implementation, which limited us to 2D Views at most.

Additional context

Changes

  • Affected areas: core
  • Breaking change(s)? no
  • Add support for Views of arbitrary rank in allocate_contiguous_for via std::index_sequence and parameter pack expansion refactoring, replacing if constexpr branches for rank 1 and 2
  • Refactor resize_contiguous_for with the same approach for consistency
  • Make View label an optional parameter in allocate_contiguous_for (use a default value if omitted). This change does not affect any user-facing interfaces and is just a convenience in preparation for a larger refactoring of non-contiguous handling strategies.
  • Update MPI and NCCL backend packers to use the new allocate_contiguous_for signature

Checklist

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

Signed-off-by: Gabriel Dos Santos <gabriel.dossantos@cea.fr>
Signed-off-by: Gabriel Dos Santos <gabriel.dossantos@cea.fr>
No public docs since these APIs are internal impl details of Kokkos
Comm. Helps with linting for developers though.

Signed-off-by: Gabriel Dos Santos <gabriel.dossantos@cea.fr>
@dssgabriel dssgabriel self-assigned this Mar 25, 2026
@dssgabriel dssgabriel added C-enhancement Category: an enhancement or bug fix A-core Area: KokkosComm core library implementation labels Mar 25, 2026
Copy link
Copy Markdown
Member

@cedricchevalier19 cedricchevalier19 left a comment

Choose a reason for hiding this comment

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

No blockers but some questions.

template <KokkosExecutionSpace ES>
static auto allocate_packed_for(const ES &space, const std::string &label, const V &src) -> Args {
auto packed = KokkosComm::Impl::allocate_contiguous_for(space, label, src);
auto packed = KokkosComm::Impl::allocate_contiguous_for(space, src, label);
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.

In Kokkos, label is often the first parameter.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I am reverting this.

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.

It means it is before space also.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good to know, thanks! The previous interface wasn't even very Kokkos-like then 😅

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I simply reverted it to what it was; I would have had to propagate the change to the backend-specific Packers and to the primitives with non-contiguous support as well, which would have made it an unnecessarily large change.

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>
@dssgabriel dssgabriel added this to the Version 0.3.0 milestone Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-core Area: KokkosComm core library implementation C-enhancement Category: an enhancement or bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants