# liyihai-official/mpi-algorithms architecture

> Architecture diagram of the GitHub repository liyihai-official/mpi-algorithms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/liyihai-official/mpi-algorithms
- Repository: https://github.com/liyihai-official/mpi-algorithms

## Overview

MPI-Algorithms combines a custom Bruck all-to-all implementation and variable-count collective examples with distributed 2D/3D Conway simulations. The main simulation flow initializes distributed grids, exchanges halos, evolves cells, and writes binary snapshots. The README documents these capabilities, while excerpts do not show every topology or example implementation detail; the graph omits uncertain internal wiring.

Main entry points: [`conway2D.cc`](https://github.com/liyihai-official/mpi-algorithms/blob/main/conway2D.cc) (2D simulation), [`conway3D.cc`](https://github.com/liyihai-official/mpi-algorithms/blob/main/conway3D.cc) (3D simulation), [`include/multiarray.hpp`](https://github.com/liyihai-official/mpi-algorithms/blob/main/include/multiarray.hpp) (N-D array), [`include/mpi/bruck.hpp`](https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/bruck.hpp) (Bruck all-to-all)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Game simulations"]
  node_game2d["2D simulation<br/>[conway2D.cc]"]
  node_game3d["3D simulation<br/>[conway3D.cc]"]
end

subgraph group_communication["MPI communication"]
  node_grid["Cartesian grid"]
  node_topology["Cartesian topology"]
  node_bruckbench["Bruck benchmark<br/>[bruck_Alltoall.cc]"]
  node_bruck["Bruck all-to-all<br/>[bruck.hpp]"]
  node_alltoallv["Alltoallv examples"]
  node_alltoallv_api["Alltoallv declarations"]
  node_halo["Halo exchange"]
end

subgraph group_data["Array utilities"]
  node_array["N-D array<br/>[multiarray.hpp]"]
  node_types["MPI type mapping<br/>[type.hpp]"]
  node_random["Array randomizer<br/>[randin.hpp]"]
end

subgraph group_io["Output and display"]
  node_writer["Cartesian binary I/O<br/>[io_Cartesian.cc]"]
  node_print["Ordered MPI printing<br/>[print_in_order.hpp]"]
end

node_user(("MPI user"))
node_mpi{{"MPI runtime"}}
node_filesystem[("Output files")]

node_user -->|"runs"| node_game2d
node_user -->|"runs"| node_game3d
node_user -->|"runs"| node_bruckbench
node_game2d -->|"constructs"| node_grid
node_game3d -->|"constructs"| node_grid
node_grid -->|"creates"| node_topology
node_grid -->|"stores"| node_array
node_topology -->|"creates communicator"| node_mpi
node_game2d -->|"initializes cells"| node_random
node_game3d -->|"initializes cells"| node_random
node_game2d -->|"exchanges halos"| node_halo
node_game3d -->|"exchanges halos"| node_halo
node_halo -->|"exchanges data"| node_mpi
node_game2d -->|"evolves grid"| node_array
node_game3d -->|"evolves grid"| node_array
node_game2d -->|"writes snapshots"| node_writer
node_game3d -->|"writes snapshots"| node_writer
node_writer -->|"writes collectively"| node_mpi
node_writer -->|"writes binary data"| node_filesystem
node_bruckbench -->|"benchmarks"| node_bruck
node_bruckbench -->|"compares collective"| node_mpi
node_bruck -->|"sends and receives"| node_mpi
node_bruck -->|"maps element type"| node_types
node_bruck -->|"reads and fills"| node_array
node_alltoallv_api -->|"declares examples"| node_alltoallv
node_alltoallv -->|"exchanges variable blocks"| node_mpi
node_alltoallv -->|"maps element type"| node_types
node_alltoallv -->|"prints layouts"| node_print
node_print -->|"gathers text"| node_mpi
node_print -->|"reads arrays"| node_array

click node_game2d "https://github.com/liyihai-official/mpi-algorithms/blob/main/conway2D.cc"
click node_game3d "https://github.com/liyihai-official/mpi-algorithms/blob/main/conway3D.cc"
click node_grid "https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/topology_Cartesian.hpp"
click node_topology "https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/topology_Cartesian.hpp"
click node_bruckbench "https://github.com/liyihai-official/mpi-algorithms/blob/main/bruck_Alltoall.cc"
click node_bruck "https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/bruck.hpp"
click node_alltoallv "https://github.com/liyihai-official/mpi-algorithms/blob/main/src/mpi/alltoall_examples.cc"
click node_alltoallv_api "https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/alltoalll_examples.hpp"
click node_halo "https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/topology_Cartesian_exhange.inl"
click node_array "https://github.com/liyihai-official/mpi-algorithms/blob/main/include/multiarray.hpp"
click node_types "https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/type.hpp"
click node_random "https://github.com/liyihai-official/mpi-algorithms/blob/main/include/randin.hpp"
click node_writer "https://github.com/liyihai-official/mpi-algorithms/blob/main/src/mpi/io_Cartesian.cc"
click node_print "https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/print_in_order.hpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_game2d,node_game3d,node_user toneBlue
class node_grid,node_topology,node_bruckbench,node_bruck,node_alltoallv,node_alltoallv_api,node_halo,node_filesystem toneAmber
class node_array,node_types,node_random toneMint
class node_writer,node_print toneRose
class node_mpi toneIndigo
```

## Components

### Game simulations

- [2D simulation](https://github.com/liyihai-official/mpi-algorithms/blob/main/conway2D.cc): `conway2D.cc`
- [3D simulation](https://github.com/liyihai-official/mpi-algorithms/blob/main/conway3D.cc): `conway3D.cc`

### MPI communication

- [Cartesian grid](https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/topology_Cartesian.hpp): `include/mpi/topology_Cartesian.hpp`
- [Cartesian topology](https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/topology_Cartesian.hpp): `include/mpi/topology_Cartesian.hpp`
- [Bruck benchmark](https://github.com/liyihai-official/mpi-algorithms/blob/main/bruck_Alltoall.cc): `bruck_Alltoall.cc`
- [Bruck all-to-all](https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/bruck.hpp): `include/mpi/bruck.hpp`
- [Alltoallv examples](https://github.com/liyihai-official/mpi-algorithms/blob/main/src/mpi/alltoall_examples.cc): `src/mpi/alltoall_examples.cc`
- [Alltoallv declarations](https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/alltoalll_examples.hpp): `include/mpi/alltoalll_examples.hpp`
- [Halo exchange](https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/topology_Cartesian_exhange.inl): `include/mpi/topology_Cartesian_exhange.inl`

### Array utilities

- [N-D array](https://github.com/liyihai-official/mpi-algorithms/blob/main/include/multiarray.hpp): `include/multiarray.hpp`
- [MPI type mapping](https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/type.hpp): `include/mpi/type.hpp`
- [Array randomizer](https://github.com/liyihai-official/mpi-algorithms/blob/main/include/randin.hpp): `include/randin.hpp`

### Output and display

- [Cartesian binary I/O](https://github.com/liyihai-official/mpi-algorithms/blob/main/src/mpi/io_Cartesian.cc): `src/mpi/io_Cartesian.cc`
- [Ordered MPI printing](https://github.com/liyihai-official/mpi-algorithms/blob/main/include/mpi/print_in_order.hpp): `include/mpi/print_in_order.hpp`

### Other components

- **MPI user**
- **MPI runtime**
- **Output files**

## Connections

- MPI user → 2D simulation: runs
- MPI user → 3D simulation: runs
- MPI user → Bruck benchmark: runs
- 2D simulation → Cartesian grid: constructs
- 3D simulation → Cartesian grid: constructs
- Cartesian grid → Cartesian topology: creates
- Cartesian grid → N-D array: stores
- Cartesian topology → MPI runtime: creates communicator
- 2D simulation → Array randomizer: initializes cells
- 3D simulation → Array randomizer: initializes cells
- 2D simulation → Halo exchange: exchanges halos
- 3D simulation → Halo exchange: exchanges halos
- Halo exchange → MPI runtime: exchanges data
- 2D simulation → N-D array: evolves grid
- 3D simulation → N-D array: evolves grid
- 2D simulation → Cartesian binary I/O: writes snapshots
- 3D simulation → Cartesian binary I/O: writes snapshots
- Cartesian binary I/O → MPI runtime: writes collectively
- Cartesian binary I/O → Output files: writes binary data
- Bruck benchmark → Bruck all-to-all: benchmarks
- Bruck benchmark → MPI runtime: compares collective
- Bruck all-to-all → MPI runtime: sends and receives
- Bruck all-to-all → MPI type mapping: maps element type
- Bruck all-to-all → N-D array: reads and fills
- Alltoallv declarations → Alltoallv examples: declares examples
- Alltoallv examples → MPI runtime: exchanges variable blocks
- Alltoallv examples → MPI type mapping: maps element type
- Alltoallv examples → Ordered MPI printing: prints layouts
- Ordered MPI printing → MPI runtime: gathers text
- Ordered MPI printing → N-D array: reads arrays
