This project converts normalized triangle meshes in .off format into voxel grids and compares five implementations of the same voxelization algorithm:
- sequential
- OpenMP
- POSIX threads
- MPI
- CUDA
The benchmark workflow measures kernel runtime, verifies every backend against the sequential reference, and exports report-ready summary tables.
.
├── data/ Input meshes
├── src/
│ ├── common/ Shared parser, SAT test, voxel grid, timing, CSV helpers
│ ├── sequential/ Sequential baseline
│ ├── openmp/ OpenMP implementation
│ ├── pthreads/ Pthreads implementation
│ ├── mpi/ MPI implementation
│ └── cuda/ CUDA implementation
├── scripts/
│ ├── bench.py Full benchmark runner
│ ├── bench.sh Shell wrapper for bench.py
│ └── summarize.py Aggregation and report export
├── results/ Timestamped benchmark sessions and summaries
├── report/ Report assets
└── Makefile Top-level build
gccmakempiccandmpirunfor the MPI target- CUDA toolkit with
nvccfor the CUDA target - Python 3
Notes:
make allbuilds CPU targets unconditionally and builds CUDA only ifnvccis available.- The default CUDA architecture is
sm_89. Override it if needed:
make CUDA_ARCH=sm_75 allBuild everything:
make allUseful individual targets:
make sequential
make openmp
make pthreads
make mpi
make cuda
make verify
make testClean generated binaries, object files, benchmark sessions, and summaries:
make cleanAll binaries are written to bin/.
Sequential:
bin/voxelize_seq -i data/airplane_0001.off -r 64 -o results/seq.voxel -c results/sequential.csvOpenMP:
bin/voxelize_omp -i data/airplane_0001.off -r 64 -t 4 -o results/omp.voxel -c results/openmp.csvPthreads:
bin/voxelize_pth -i data/airplane_0001.off -r 64 -t 4 -o results/pth.voxel -c results/pthreads.csvMPI:
mpirun -np 4 bin/voxelize_mpi -i data/airplane_0001.off -r 64 -o results/mpi.voxel -c results/mpi.csvCUDA:
bin/voxelize_cuda -i data/airplane_0001.off -r 64 -b 128 -o results/cuda.voxel -c results/cuda.csvVerify a backend output against the sequential output:
bin/verify results/seq.voxel results/omp.voxelThe benchmark runner uses:
- Meshes: 9 input meshes from
data/ - Resolutions:
32,64,128 - Repeats:
3 - OpenMP threads:
1,4,8 - Pthreads threads:
1,4,8 - MPI processes:
1,4,8 - CUDA block sizes:
64,128,256
Each benchmark run:
- creates a fresh timestamped session under
results/run_* - writes one CSV per backend into that session
- writes voxel outputs for each run/configuration
- verifies every non-sequential output against the sequential reference
Since the project uses both CPU backends (Sequential, OpenMP, Pthreads, MPI) and a GPU backend (CUDA), follow this hybrid workflow to generate the final report data.
On your local machine (Mac/Linux):
make clean
make all
# Run only CPU backends to avoid CUDA/MPI issues locally
python3 scripts/bench.py --backends sequential openmp pthreads mpiThis will create a session folder like results/run_20260428_120000/. Keep note of this folder name.
- Upload
CUDA_Colab.ipynbto Google Colab. - Set Runtime to T4 GPU.
- Run all cells. The notebook is configured to run
python3 scripts/bench.py --backends cuda. - The notebook will automatically prompt you to download
cuda.csvonce finished.
- Locate the
cuda.csvyou downloaded from Colab. - Drag/Move
cuda.csvinto your local session folder (e.g.,results/run_20260428_120000/). - Run the summarizer locally:
python3 scripts/summarize.py --fresh-onlyThe final report tables will be generated in results/summary/.
Default summary to stdout plus generated artifacts:
python3 scripts/summarize.pySummarize only the newest benchmark session and emit report-ready files:
python3 scripts/summarize.py --fresh-only --format csv --per-resolutionSummarize explicit CSVs instead of auto-selecting a session:
python3 scripts/summarize.py --input results/run_20260427_173810/*.csvWrite summary outputs somewhere else:
python3 scripts/summarize.py --fresh-only --output-dir /tmp/voxel-summaryGenerated files under results/summary/ include:
overall.csvbest_per_backend.csvbackend_best_configs.csvruntime_table.csvspeedup_table.csvruntime_by_resolution.csvruntime_by_resolution.mdspeedup_by_resolution.csvspeedup_by_resolution.mdcuda_blocksize_comparison.csvcuda_blocksize_comparison.mdscalability.csvscalability_notes.md
Some of these tables were directly pasted into the report, while others were not to keep report size small.
- The sequential baseline is the source of truth for correctness checks.
- All benchmark CSVs use the schema:
impl,config,mesh_file,num_triangles,grid_res,elapsed_ms
- CUDA timing records kernel time only.
- The CUDA path precomputes per-face voxel bounds on the host and uploads them to the kernel to reduce repeated per-face min/max work in device code.
- If CUDA does not build, confirm that
nvccexists and thatCUDA_ARCHmatches your GPU. - If MPI fails to launch, verify that
mpirunworks on your machine outside restricted sandboxes. - If you want a completely fresh benchmark dataset, run
make cleanbeforepython3 scripts/bench.py.
The local git repository is configured to use:
https://github.com/simenzzz/Parallel-Project
To run the CUDA optimizations on Google Colab:
- Open Google Colab.
- Select File > Upload notebook and upload
CUDA_Colab.ipynb. - Set runtime to GPU (Runtime > Change runtime type > T4 GPU).
- Run the cells.
- Download Results: The notebook will automatically trigger a download for
cuda.csv. - Merge: Copy this
cuda.csvinto your latest localresults/run_*folder to include GPU data in your final summary.