# koaie/apt-cuda-cw architecture

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

- Interactive diagram: https://gitdiagram.com/koaie/apt-cuda-cw
- Repository: https://github.com/koaie/apt-cuda-cw

## Overview

This coursework repository benchmarks CPU and single-GPU implementations of floating-point histograms, with parallel C and Fortran versions. The principal workflow is to load bin edges and data, compute CPU and GPU histograms, compare results, time runs, and write histogram output. The sampled C sources establish the CPU algorithm and file I/O; the README documents the benchmark and GPU workflow, but the benchmark and GPU implementation bodies were not sampled, so their internal calls and data transfers are not expanded.

Main entry points: [`c/bench.cu`](https://github.com/koaie/apt-cuda-cw/blob/test/c/bench.cu) (C benchmark), [`fortran/bench.cuf`](https://github.com/koaie/apt-cuda-cw/blob/test/fortran/bench.cuf) (Fortran benchmark), [`c/hist_gpu.cu`](https://github.com/koaie/apt-cuda-cw/blob/test/c/hist_gpu.cu) (C GPU histogram), [`fortran/hist_gpu.cuf`](https://github.com/koaie/apt-cuda-cw/blob/test/fortran/hist_gpu.cuf) (Fortran GPU histogram)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input and output"]
  node_data_files["Data and bins"]
  node_c_io["C file I/O<br/>[io.c]"]
  node_fortran_io["Fortran file I/O<br/>[io.f95]"]
  node_hist_output["Histogram output"]
end

subgraph group_compute["Histogram implementations"]
  node_c_cpu["C CPU histogram<br/>[hist_cpu.c]"]
  node_c_gpu["C GPU histogram<br/>[hist_gpu.cu]"]
  node_fortran_cpu["Fortran CPU histogram<br/>[hist_cpu.f95]"]
  node_fortran_gpu["Fortran GPU histogram<br/>[hist_gpu.cuf]"]
end

subgraph group_benchmark["Benchmark workflow"]
  node_c_bench["C benchmark<br/>[bench.cu]"]
  node_fortran_bench["Fortran benchmark<br/>[bench.cuf]"]
end

node_user(("User"))
node_gpu{{"NVIDIA GPU"}}

node_user -->|"runs"| node_c_bench
node_user -->|"runs"| node_fortran_bench
node_data_files -->|"reads"| node_c_io
node_data_files -->|"reads"| node_fortran_io
node_c_bench -->|"uses I/O"| node_c_io
node_c_bench -->|"computes CPU"| node_c_cpu
node_c_bench -->|"computes GPU"| node_c_gpu
node_c_gpu -->|"executes on"| node_gpu
node_c_bench -->|"writes result"| node_hist_output
node_fortran_bench -->|"uses I/O"| node_fortran_io
node_fortran_bench -->|"computes CPU"| node_fortran_cpu
node_fortran_bench -->|"computes GPU"| node_fortran_gpu
node_fortran_gpu -->|"executes on"| node_gpu
node_fortran_bench -->|"writes result"| node_hist_output

click node_c_io "https://github.com/koaie/apt-cuda-cw/blob/test/c/io.c"
click node_c_cpu "https://github.com/koaie/apt-cuda-cw/blob/test/c/hist_cpu.c"
click node_c_gpu "https://github.com/koaie/apt-cuda-cw/blob/test/c/hist_gpu.cu"
click node_c_bench "https://github.com/koaie/apt-cuda-cw/blob/test/c/bench.cu"
click node_fortran_cpu "https://github.com/koaie/apt-cuda-cw/blob/test/fortran/hist_cpu.f95"
click node_fortran_gpu "https://github.com/koaie/apt-cuda-cw/blob/test/fortran/hist_gpu.cuf"
click node_fortran_io "https://github.com/koaie/apt-cuda-cw/blob/test/fortran/io.f95"
click node_fortran_bench "https://github.com/koaie/apt-cuda-cw/blob/test/fortran/bench.cuf"

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_data_files,node_c_io,node_fortran_io,node_hist_output,node_user toneBlue
class node_c_cpu,node_c_gpu,node_fortran_cpu,node_fortran_gpu toneAmber
class node_c_bench,node_fortran_bench toneMint
class node_gpu toneIndigo
```

## Components

### Input and output

- **Data and bins**
- [C file I/O](https://github.com/koaie/apt-cuda-cw/blob/test/c/io.c): `c/io.c`
- [Fortran file I/O](https://github.com/koaie/apt-cuda-cw/blob/test/fortran/io.f95): `fortran/io.f95`
- **Histogram output**

### Histogram implementations

- [C CPU histogram](https://github.com/koaie/apt-cuda-cw/blob/test/c/hist_cpu.c): `c/hist_cpu.c`
- [C GPU histogram](https://github.com/koaie/apt-cuda-cw/blob/test/c/hist_gpu.cu): `c/hist_gpu.cu`
- [Fortran CPU histogram](https://github.com/koaie/apt-cuda-cw/blob/test/fortran/hist_cpu.f95): `fortran/hist_cpu.f95`
- [Fortran GPU histogram](https://github.com/koaie/apt-cuda-cw/blob/test/fortran/hist_gpu.cuf): `fortran/hist_gpu.cuf`

### Benchmark workflow

- [C benchmark](https://github.com/koaie/apt-cuda-cw/blob/test/c/bench.cu): `c/bench.cu`
- [Fortran benchmark](https://github.com/koaie/apt-cuda-cw/blob/test/fortran/bench.cuf): `fortran/bench.cuf`

### Other components

- **User**
- **NVIDIA GPU**

## Connections

- User → C benchmark: runs
- User → Fortran benchmark: runs
- Data and bins → C file I/O: reads
- Data and bins → Fortran file I/O: reads
- C benchmark → C file I/O: uses I/O
- C benchmark → C CPU histogram: computes CPU
- C benchmark → C GPU histogram: computes GPU
- C GPU histogram → NVIDIA GPU: executes on
- C benchmark → Histogram output: writes result
- Fortran benchmark → Fortran file I/O: uses I/O
- Fortran benchmark → Fortran CPU histogram: computes CPU
- Fortran benchmark → Fortran GPU histogram: computes GPU
- Fortran GPU histogram → NVIDIA GPU: executes on
- Fortran benchmark → Histogram output: writes result
