Skip to content

guyleaf/Parallelized-Ray-Tracing-In-One-Weekend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

115 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parallelized Ray Tracing In One Weekend

The parallelized version for the book, GitHub v3.2.3, Ray Tracing in One Weekend by Peter Shirley.

TL;DR

Optimize and Benchmark Ray Tracing code with CUDA, OpenMP.

Reports

Samples

Sample 10 times per pixel

sampling-10.png

Sample 500 times per pixel

sampling-500.png

Benchmark results

OpenMP

omp_speed_up.png

CUDA

cuda_speed_up.png

Map size (Number of objects)

map_size.png

Environment

Hardware

  • CPU: Intel(R) Xeon(R) Silver 4210 CPU @ 2.20GHz (10 cores 20 threads)
  • GPU: NVIDIA RTX 2080Ti 12GB
  • RAM: DDR4 2666MHz 128GB

Software

  • Host OS: Ubuntu 20.04
  • Container: Docker engine 24.0.6 with rootless mode
  • Guest OS: Ubuntu 22.04
  • Linux kernel: 5.15.0-87-generic
  • OpenMP: 4.5
  • CUDA: 12.3
  • GCC: 11.4.0

How to build?

export CMAKE_BUILD_TYPE="Release"

# build all implementations with the best settings
CUDAFLAGS="-DCUDA_BLOCK_SIZE=8" cmake -B build . && cmake --build build

How to run?

# run serial implementation
./build/serial/InOneWeekend > test.ppm

# run OpenMP implementation
OMP_NUM_THREADS=22 ./build/openmp/OMPInOneWeekend > test.ppm

# run CUDA implementation
./build/cuda/CUDAInOneWeekend > test.ppm

Benchmark

Notice

These scripts are for reference only. If you want to reproduce the result, the OpenMP implementation is much more tricky. You have to change the scheduling method by yourself in openmp/src/main.cc.

Before running

We provide the devcontainer to quickly set up the enviroment (for rootless docker only). If you want to set up by yourself, you can follow the Dockerfine in .devcontainer folder to install.

OpenMP

./scripts/benchmark_omp.sh

CUDA

./scripts/benchmark_omp.sh

Map size

./scripts/benchmark_map_size.sh

About

The optimized Ray Tracing implementation with CUDA, OpenMP.

Topics

Resources

License

Stars

Watchers

Forks

Contributors