How danielerussica/hpdga-fall23 works
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: yourSolution.cu CUDA engine · knn.cpp KNN driver · testing_knn.cpp Test harness · Makefile Makefile
Components 12
Submission code
Primary contest implementation and build boundary.
- Makefile · Build entry for the contest submission.
code/Makefile - KNN driver · CPU-side entry point that prepares the benchmark and launches the CUDA solution.
code/knn.cpp - Solution API · Submission-facing interface for the GPU implementation.
code/yourSolution.h - CUDA engine · Core exact KNN implementation with kernels and supporting device/host code.
code/yourSolution.cu - Memory path · Data placement and transfer strategy across CPU and GPU memory.
Experimentation and validation
Alternative kernels, testing harness, and result checking.
- Alt kernels · Experimental kernel implementations used during development.
other/kernels.cu - Old kernels · Earlier kernel variants kept for comparison or reference.
other/old_kernels.cu - Test harness · Standalone correctness and performance test program.
other/testing_knn.cpp - Result checker · Script for comparing and validating generated outputs.
other/result_checker.py - Validation outputs · Checked outputs and benchmark comparisons produced by the validation flow.
Report artifacts
Slides and written report documenting design and results.
Connections 16
- 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.