# danielerussica/hpdga-fall23 architecture

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

- Interactive diagram: https://gitdiagram.com/danielerussica/hpdga-fall23
- Repository: https://github.com/danielerussica/hpdga-fall23

## Overview

1. This repository is a contest submission for a GPU-accelerated exact K-Nearest Neighbors implementation using cosine distance. The architecture is intentionally small: one production code path, one or more experimental kernel files, and separate validation/reporting artifacts.

2. The main executable logic lives under `code/`. `code/knn.cpp` is the host-side entry point and is likely the driver that sets up data, chooses the benchmark/settings from `main()`, launches the CUDA implementation, and prints results. This is the boundary between CPU orchestration and GPU compute.

3. The core algorithm implementation is split into `code/yourSolution.cu` and `code/yourSolution.h`. That pair is the submission interface: the header exposes the GPU-facing API, and the `.cu` file contains the CUDA kernels and supporting device/host code. This is the main compute subsystem for the exact KNN search.

4. The repository is built around CUDA and C++, with no external acceleration libraries. The README explicitly forbids cuBLAS/cuGraph and allows either Unified Memory or unmanaged memory, which means memory management is part of the design space and affects how data moves between CPU and GPU.

5. `code/Makefile` is the build boundary for the submission. It likely compiles the driver and CUDA implementation into the contest executable, and it is the main integration point for the code in `code/`.

6. The `other/` directory contains non-submission and experimentation assets. `other/kernels.cu` and `other/old_kernels.cu` suggest iterative kernel development and alternative implementations. Architecturally, this separates stable contest code from previous or exploratory GPU variants.

7. Validation is also isolated in `other/`. `other/testing_knn.cpp` is likely a standalone test harness for correctness and performance checks, while `other/result_checker.py` is a post-processing or comparison script used to verify outputs. This creates a clear testing/verification pipeline separate from the submission binary.

8. The data flow is likely: input dataset and query/point arrays are prepared on the host in `knn.cpp`, transferred or mapped into GPU-accessible memory, processed by kernels in `yourSolution.cu`, and then results are returned to the host for printing and checking. The key architectural concern is efficient movement and reuse of data across that host/device boundary.

9. The repository also contains `report/` with PDF slide and report deliverables. These are not part of runtime architecture, but they document design choices, kernel variants, and performance results, which is important because the contest expects evidence of evaluated alternatives and measured outcomes.

10. Overall, the repo has three clear zones: production CUDA submission code in `code/`, experimentation and correctness tooling in `other/`, and documentation in `report/`. For an architecture diagram, the central box should be the CUDA KNN engine, fed by a CPU driver, with separate validation and report-generation paths around it.

Main entry points: [`code/yourSolution.cu`](https://github.com/danielerussica/hpdga-fall23/blob/main/code/yourSolution.cu) (CUDA engine), [`code/knn.cpp`](https://github.com/danielerussica/hpdga-fall23/blob/main/code/knn.cpp) (KNN driver), [`other/testing_knn.cpp`](https://github.com/danielerussica/hpdga-fall23/blob/main/other/testing_knn.cpp) (Test harness), [`code/Makefile`](https://github.com/danielerussica/hpdga-fall23/tree/main/code/Makefile) (Makefile)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_code["Submission code"]
  node_code_makefile["Makefile<br/>build"]
  node_code_knn["KNN driver<br/>host driver<br/>[knn.cpp]"]
  node_code_iface_h["Solution API<br/>cuda header<br/>[yourSolution.h]"]
  node_code_solution_cu{{"CUDA engine<br/>gpu compute<br/>[yourSolution.cu]"}}
  node_code_mem(("Memory path<br/>host-device data"))
end

subgraph group_other["Experimentation and validation"]
  node_other_kernels{{"Alt kernels<br/>experiment kernel<br/>[kernels.cu]"}}
  node_other_old_kernels{{"Old kernels<br/>legacy kernel<br/>[old_kernels.cu]"}}
  node_other_testing["Test harness<br/>validation driver<br/>[testing_knn.cpp]"]
  node_other_checker["Result checker<br/>verification script<br/>[result_checker.py]"]
  node_other_outputs["Validation outputs<br/>checked results"]
end

subgraph group_report["Report artifacts"]
  node_report_slides["Slides<br/>presentation"]
  node_report_paper["Report<br/>writeup"]
end

node_code_makefile -->|"builds"| node_code_knn
node_code_makefile -->|"builds"| node_code_solution_cu
node_code_knn -->|"uses"| node_code_iface_h
node_code_knn -->|"launches"| node_code_solution_cu
node_code_knn -->|"orchestrates"| node_code_mem
node_code_iface_h -->|"declares"| node_code_solution_cu
node_code_solution_cu -->|"moves data"| node_code_mem
node_code_solution_cu -.->|"compares with"| node_other_kernels
node_code_solution_cu -.->|"evolved from"| node_other_old_kernels
node_other_testing -->|"tests"| node_code_solution_cu
node_other_testing -->|"feeds"| node_other_checker
node_other_checker -->|"verifies"| node_other_outputs
node_code_knn -.->|"mirrors"| node_other_testing
node_report_slides -.->|"documents"| node_code_solution_cu
node_report_paper -.->|"documents"| node_code_knn
node_report_paper -.->|"documents"| node_other_kernels

click node_code_makefile "https://github.com/danielerussica/hpdga-fall23/tree/main/code/Makefile"
click node_code_knn "https://github.com/danielerussica/hpdga-fall23/blob/main/code/knn.cpp"
click node_code_iface_h "https://github.com/danielerussica/hpdga-fall23/blob/main/code/yourSolution.h"
click node_code_solution_cu "https://github.com/danielerussica/hpdga-fall23/blob/main/code/yourSolution.cu"
click node_other_kernels "https://github.com/danielerussica/hpdga-fall23/blob/main/other/kernels.cu"
click node_other_old_kernels "https://github.com/danielerussica/hpdga-fall23/blob/main/other/old_kernels.cu"
click node_other_testing "https://github.com/danielerussica/hpdga-fall23/blob/main/other/testing_knn.cpp"
click node_other_checker "https://github.com/danielerussica/hpdga-fall23/blob/main/other/result_checker.py"
click node_report_slides "https://github.com/danielerussica/hpdga-fall23/blob/main/report/hpdga-fall23-slides-DanieleRussica-LeonardoTisato.pdf"
click node_report_paper "https://github.com/danielerussica/hpdga-fall23/blob/main/report/hpdga_fall23_report_DanieleRussica_LeonardoTisato.pdf"

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_code_makefile,node_code_knn,node_code_iface_h,node_code_solution_cu,node_code_mem toneBlue
class node_other_kernels,node_other_old_kernels,node_other_testing,node_other_checker,node_other_outputs toneAmber
class node_report_slides,node_report_paper toneMint
```

## Components

### Submission code

Primary contest implementation and build boundary.

- [Makefile](https://github.com/danielerussica/hpdga-fall23/tree/main/code/Makefile): build · Build entry for the contest submission. · `code/Makefile`
- [KNN driver](https://github.com/danielerussica/hpdga-fall23/blob/main/code/knn.cpp): host driver · CPU-side entry point that prepares the benchmark and launches the CUDA solution. · `code/knn.cpp`
- [Solution API](https://github.com/danielerussica/hpdga-fall23/blob/main/code/yourSolution.h): cuda header · Submission-facing interface for the GPU implementation. · `code/yourSolution.h`
- [CUDA engine](https://github.com/danielerussica/hpdga-fall23/blob/main/code/yourSolution.cu): gpu compute · Core exact KNN implementation with kernels and supporting device/host code. · `code/yourSolution.cu`
- **Memory path**: host-device data · Data placement and transfer strategy across CPU and GPU memory.

### Experimentation and validation

Alternative kernels, testing harness, and result checking.

- [Alt kernels](https://github.com/danielerussica/hpdga-fall23/blob/main/other/kernels.cu): experiment kernel · Experimental kernel implementations used during development. · `other/kernels.cu`
- [Old kernels](https://github.com/danielerussica/hpdga-fall23/blob/main/other/old_kernels.cu): legacy kernel · Earlier kernel variants kept for comparison or reference. · `other/old_kernels.cu`
- [Test harness](https://github.com/danielerussica/hpdga-fall23/blob/main/other/testing_knn.cpp): validation driver · Standalone correctness and performance test program. · `other/testing_knn.cpp`
- [Result checker](https://github.com/danielerussica/hpdga-fall23/blob/main/other/result_checker.py): verification script · Script for comparing and validating generated outputs. · `other/result_checker.py`
- **Validation outputs**: checked results · Checked outputs and benchmark comparisons produced by the validation flow.

### Report artifacts

Slides and written report documenting design and results.

- [Slides](https://github.com/danielerussica/hpdga-fall23/blob/main/report/hpdga-fall23-slides-DanieleRussica-LeonardoTisato.pdf): presentation · Project slide deck summarizing approach and results. · `report/hpdga-fall23-slides-DanieleRussica-LeonardoTisato.pdf`
- [Report](https://github.com/danielerussica/hpdga-fall23/blob/main/report/hpdga_fall23_report_DanieleRussica_LeonardoTisato.pdf): writeup · Written report with design decisions and performance discussion. · `report/hpdga_fall23_report_DanieleRussica_LeonardoTisato.pdf`

## Connections

- Makefile → KNN driver: builds · Compiles the driver and submission implementation.
- Makefile → CUDA engine: builds · Builds the CUDA compute implementation.
- KNN driver → Solution API: uses · Includes the submission API.
- KNN driver → CUDA engine: launches · Invokes the exact KNN implementation.
- KNN driver → Memory path: orchestrates · Prepares data movement and execution state.
- Solution API → CUDA engine: declares · Defines the GPU-facing interface used by the driver.
- CUDA engine → Memory path: moves data · Relies on managed or explicit host-device memory flow.
- CUDA engine → Alt kernels: compares with · Alternative kernel variants inform the main implementation.
- CUDA engine → Old kernels: evolved from · Legacy kernel code represents prior iterations.
- Test harness → CUDA engine: tests · Exercises the submission implementation for correctness and speed.
- Test harness → Result checker: feeds · Produces outputs consumed by the checker.
- Result checker → Validation outputs: verifies · Compares results and records validation output.
- KNN driver → Test harness: mirrors · Standalone harness reflects the main execution flow.
- Slides → CUDA engine: documents · Summarizes kernel design and performance.
- Report → KNN driver: documents · Describes the host-side orchestration and benchmark setup.
- Report → Alt kernels: documents · Covers alternative kernel exploration.
