# danielesavino/collalgo architecture

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

- Interactive diagram: https://gitdiagram.com/danielesavino/collalgo
- Repository: https://github.com/danielesavino/collalgo

## Overview

CollAlgo is an MPI collective-algorithm library: an application calls its BiNE collective APIs to exchange or reduce data across ranks. The principal workflow covers gather/scatter, broadcast, and reduction; the repository also implements allgather and alltoall. Shared negabinary rank-mapping supports the algorithms, while reduction can dispatch to CUDA for device buffers. README documents profiling integration, though the vendor library is not present in the supplied tree. Relationships below follow excerpts or README statements; unsampled CUDA and broadcast internals are represented only where documented.

Main entry points: [`src/reduce.c`](https://github.com/danielesavino/collalgo/blob/main/src/reduce.c) (Reduce), [`include/CollAlgo/bine.h`](https://github.com/danielesavino/collalgo/blob/main/include/CollAlgo/bine.h) (Rank mapping), [`include/CollAlgo/utils.h`](https://github.com/danielesavino/collalgo/blob/main/include/CollAlgo/utils.h) (MPI utilities), [`src/gather.c`](https://github.com/danielesavino/collalgo/blob/main/src/gather.c) (Gather)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collectives["MPI collectives"]
  node_gather["Gather<br/>[gather.c]"]
  node_scatter["Scatter<br/>[scatter.c]"]
  node_broadcast["Broadcast<br/>[bcast.c]"]
  node_reduce["Reduce<br/>[reduce.c]"]
  node_allgather["Allgather<br/>[allgather.c]"]
  node_alltoall["Alltoall<br/>[alltoall.c]"]
end

subgraph group_algorithm["BiNE internals"]
  node_mapping["Rank mapping<br/>[bine.h]"]
  node_utilities["MPI utilities<br/>[utils.h]"]
end

subgraph group_cuda["CUDA reduction"]
  node_cuda_kernel["CUDA reduce kernel<br/>[reduce.cu]"]
  node_cuda_utils["Device detection<br/>[utils.cu]"]
end

subgraph group_observability["Profiling"]
  node_collbench["CollBench"]
end

node_app(("MPI application"))

node_app -->|"calls"| node_gather
node_app -->|"calls"| node_scatter
node_app -->|"calls"| node_broadcast
node_app -->|"calls"| node_reduce
node_app -->|"calls"| node_allgather
node_app -->|"calls"| node_alltoall
node_gather -->|"uses mapping"| node_mapping
node_scatter -->|"uses mapping"| node_mapping
node_broadcast -->|"uses mapping"| node_mapping
node_reduce -->|"uses mapping"| node_mapping
node_allgather -->|"uses mapping"| node_mapping
node_alltoall -->|"uses mapping"| node_mapping
node_gather -->|"uses helpers"| node_utilities
node_scatter -->|"uses helpers"| node_utilities
node_reduce -->|"uses helpers"| node_utilities
node_allgather -->|"uses helpers"| node_utilities
node_alltoall -->|"uses helpers"| node_utilities
node_reduce -->|"detects buffers"| node_cuda_utils
node_reduce -->|"dispatches"| node_cuda_kernel
node_gather -->|"profiles"| node_collbench
node_scatter -->|"profiles"| node_collbench
node_reduce -->|"profiles"| node_collbench
node_broadcast -.->|"profiles"| node_collbench

click node_gather "https://github.com/danielesavino/collalgo/blob/main/src/gather.c"
click node_scatter "https://github.com/danielesavino/collalgo/blob/main/src/scatter.c"
click node_broadcast "https://github.com/danielesavino/collalgo/blob/main/src/bcast.c"
click node_reduce "https://github.com/danielesavino/collalgo/blob/main/src/reduce.c"
click node_allgather "https://github.com/danielesavino/collalgo/blob/main/src/allgather.c"
click node_alltoall "https://github.com/danielesavino/collalgo/blob/main/src/alltoall.c"
click node_mapping "https://github.com/danielesavino/collalgo/blob/main/include/CollAlgo/bine.h"
click node_utilities "https://github.com/danielesavino/collalgo/blob/main/include/CollAlgo/utils.h"
click node_cuda_kernel "https://github.com/danielesavino/collalgo/blob/main/src/cuda/reduce.cu"
click node_cuda_utils "https://github.com/danielesavino/collalgo/blob/main/src/cuda/utils.cu"

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_gather,node_scatter,node_broadcast,node_reduce,node_allgather,node_alltoall toneBlue
class node_mapping,node_utilities toneAmber
class node_cuda_kernel,node_cuda_utils toneMint
class node_collbench toneRose
class node_app toneIndigo
```

## Components

### MPI collectives

- [Gather](https://github.com/danielesavino/collalgo/blob/main/src/gather.c): `src/gather.c`
- [Scatter](https://github.com/danielesavino/collalgo/blob/main/src/scatter.c): `src/scatter.c`
- [Broadcast](https://github.com/danielesavino/collalgo/blob/main/src/bcast.c): `src/bcast.c`
- [Reduce](https://github.com/danielesavino/collalgo/blob/main/src/reduce.c): `src/reduce.c`
- [Allgather](https://github.com/danielesavino/collalgo/blob/main/src/allgather.c): `src/allgather.c`
- [Alltoall](https://github.com/danielesavino/collalgo/blob/main/src/alltoall.c): `src/alltoall.c`

### BiNE internals

- [Rank mapping](https://github.com/danielesavino/collalgo/blob/main/include/CollAlgo/bine.h): `include/CollAlgo/bine.h`
- [MPI utilities](https://github.com/danielesavino/collalgo/blob/main/include/CollAlgo/utils.h): `include/CollAlgo/utils.h`

### CUDA reduction

- [CUDA reduce kernel](https://github.com/danielesavino/collalgo/blob/main/src/cuda/reduce.cu): `src/cuda/reduce.cu`
- [Device detection](https://github.com/danielesavino/collalgo/blob/main/src/cuda/utils.cu): `src/cuda/utils.cu`

### Profiling

- **CollBench**

### Other components

- **MPI application**

## Connections

- MPI application → Gather: calls (evidence: `README.MD`)
- MPI application → Scatter: calls (evidence: `README.MD`)
- MPI application → Broadcast: calls (evidence: `README.MD`)
- MPI application → Reduce: calls (evidence: `README.MD`)
- MPI application → Allgather: calls (evidence: `README.MD`)
- MPI application → Alltoall: calls (evidence: `README.MD`)
- Gather → Rank mapping: uses mapping (evidence: `src/gather.c`)
- Scatter → Rank mapping: uses mapping (evidence: `src/scatter.c`)
- Broadcast → Rank mapping: uses mapping (evidence: `src/bcast.c`)
- Reduce → Rank mapping: uses mapping (evidence: `src/reduce.c`)
- Allgather → Rank mapping: uses mapping (evidence: `src/allgather.c`)
- Alltoall → Rank mapping: uses mapping (evidence: `src/alltoall.c`)
- Gather → MPI utilities: uses helpers (evidence: `src/gather.c`)
- Scatter → MPI utilities: uses helpers (evidence: `src/scatter.c`)
- Reduce → MPI utilities: uses helpers (evidence: `src/reduce.c`)
- Allgather → MPI utilities: uses helpers (evidence: `src/allgather.c`)
- Alltoall → MPI utilities: uses helpers (evidence: `src/alltoall.c`)
- Reduce → Device detection: detects buffers (evidence: `README.MD`)
- Reduce → CUDA reduce kernel: dispatches (evidence: `src/reduce.c`)
- Gather → CollBench: profiles (evidence: `src/gather.c`)
- Scatter → CollBench: profiles (evidence: `src/scatter.c`)
- Reduce → CollBench: profiles (evidence: `README.MD`)
- Broadcast → CollBench: profiles (evidence: `README.MD`)
