Skip to content

ayaachi-jha/ray-tracing

Repository files navigation

Project 2

Instructions to Run:

Sequential

  1. Build main.c using gcc -O3 -flto -funroll-loops -ffast-math -march=native main.c -o main -lm

  2. Run ./main N L[0] L[1] L[2] Wy Wmax C[0] C[1] C[2] R Nrays

Ex run with defaults: ./main 1000 4 4 -1 2 2 0 12 0 6 1000000000

Replace main.c with mainFloat.c for the float implementation instead of double.

OMP

  1. Build mainOMP.c using gcc -O3 -flto -funroll-loops -ffast-math -march=native mainOMP.c -o mainOMP -fopenmp -lm

  2. Run ./mainOMP N L[0] L[1] L[2] Wy Wmax C[0] C[1] C[2] R Nrays NumThreads

Ex run with defaults (32 threads): ./mainOMP 1000 4 4 -1 2 2 0 12 0 6 1000000000 32

Replace mainOMP.c with mainOMPFloat.c for the float implementation instead of double.

CUDA

  1. Build mainCuda.cu using nvcc -arch=compute_70 -O3 mainCuda.cu -o mainCuda for V100.

Change -arch according to the GPU you are using.

  1. Run on the cluster using ./mainCuda Nrays N Blocks ThreadsPerBlock

Ex run (V100): srun --account=mpcs51087 --partition=gpu --gres=gpu:1 --time=00:00:10 --constraint=v100 ./mainCuda 1000000000 1000 320 1024

Replace mainCuda.cu with mainCudaFloat.cu for the float implementation instead of double.

CUDA with Open MPI

  1. Build mainCudaMPI.cu using nvcc -arch=compute_75 -I$(mpicxx --showme:incdirs) -L$(mpicxx --showme:libdirs) -lmpi -lmpi_cxx mainCudaMPI.cu -o mainCudaMPI.

Change -arch according to the GPU you are using.

  1. Run on the cluster using ./mainCudaMPI Nrays N Blocks ThreadsPerBlock

Ex run (V100): mpirun -np 2 ./mainCudaMPI 1000000000 1000 320 1024

Replace mainCudaMPI.c with mainCudaMPIFloat.c for the float implementation instead of double.

Plotting without MPI

  1. Install the requirements.txt using pip install -r requirements.txt

  2. Run python plotRayTracing.py output.bin <GridSize>. Ex: python plotRayTracing.py output.bin 1000 for 1000 x 1000 grid.

Plotting with MPI

  1. Install requirements.txt

  2. Run python plotRayTracingMPI.py output_0.bin output_1.bin <GridSize> Ex: python plotRayTracingMPI.py output_0.bin output_1.bin 1000 for 1000 x 1000 grid.

Performance

alt text

Rendered Image

alt text

About

Ray-Tracing on multi-GPU for rendering a sphere with 1 billion rays.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published