Skip to content

Add MPI support for std::optional#32

Closed
Wentzell wants to merge 89 commits into1.3.xfrom
unstable
Closed

Add MPI support for std::optional#32
Wentzell wants to merge 89 commits into1.3.xfrom
unstable

Conversation

@Wentzell
Copy link
Member

@Wentzell Wentzell commented Dec 4, 2025

Summary

  • Add mpi_broadcast, mpi_reduce, and mpi_reduce_into implementations for std::optional<T>
  • All ranks must have consistent has_value state for reduce operations (throws std::runtime_error otherwise)
  • Include optional.hpp from main mpi.hpp header

Test plan

  • Added test/c++/mpi_optional.cpp with tests for broadcast and reduce operations
  • Tests pass with np2, np4, and nompi configurations

Co-Authored-By: Claude noreply@anthropic.com

Wentzell and others added 30 commits April 19, 2024 11:24
Co-authored-by: Dylan Simon <dylan@dylex.net>
Co-authored-by: Alexander Hampel <ahampel@flatironinstitute.org>
Wentzell and others added 29 commits May 16, 2025 17:46
This commit introduces comprehensive support for MPI one-sided communication (RMA) and shared memory windows:

- Add mpi::window<T> class wrapping MPI_Win for remote memory access
  * Support for MPI_Win_create (existing buffer) and MPI_Win_allocate
  * RMA operations: get() and put() with type safety
  * Synchronization primitives: fence(), lock/unlock(), flush(), sync()
  * Active target synchronization: start/complete/post/wait()
  * RAII-compliant with automatic resource cleanup

- Add mpi::shared_window<T> for zero-copy intra-node communication
  * Uses MPI_Win_allocate_shared for POSIX shared memory
  * Query operations to access memory from other ranks on same node
  * Rank-aware base(), size(), and disp_unit() methods

- Add mpi::group class wrapping MPI_Group
  * Group operations: union, intersection, difference, include/exclude
  * Rank translation between groups and communicators
  * Support for active target synchronization epochs

- Add shared_communicator class for node-local communication
  * Extends communicator with split_shared() support

- Comprehensive test coverage including shared array and distributed shared array tests
…ecking

Major refactoring and documentation improvements across all MPI wrapper classes:

- Standardize member variable naming with trailing underscores (com_ → comm_, grp_ → group_, etc.)
- Enhance documentation with detailed @brief and @details tags throughout
- Wrap all MPI calls with check_mpi_call() for consistent error handling
- Simplify method implementations and remove unnecessary complexity
- Remove noexcept specifiers where not appropriate
- Remove data() getters in favor of base() for consistency
- Improve getter methods to return stored attributes directly
- Refactor get() and put() methods with clearer type requirements

Testing improvements:
- Rename mpi_comm_split.cpp to mpi_communicator.cpp
- Add comprehensive mpi_group.cpp test file
- Update and expand mpi_window.cpp tests
Address remaining inconsistencies and improve code clarity:

- Standardize communicator member variable naming from com_ to comm_ across all classes for consistency with mpi::window

- Fix window::size() semantics to return element count instead of bytes, matching constructor parameter units

- Simplify test code in mpi_window.cpp:
  * Use structured bindings and modern C++ patterns
  * Remove redundant variables and computations
  * Clearer comments and better use of mpi::chunk

- Fix window::owned_ member initialization ordering to correctly handle both MPI and non-MPI cases

- Remove redundant forward declaration of shared_window

- Simplify get_communicator() implementations to return comm_ directly

- Update build_multi_node.yml workflow with improvements from app4triqs

- Minor documentation clarifications in group and window classes
Implement mpi_broadcast, mpi_reduce, and mpi_reduce_into for
std::optional. All ranks must have consistent has_value state
for reduce operations.

Co-Authored-By: Claude <noreply@anthropic.com>
@Wentzell Wentzell closed this Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants