Site Tools


fdtd-cuda

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
fdtd-cuda [October 23, 2026 at 15:58] – removed Ivan Janevskifdtd-cuda [October 23, 2026 at 17:47] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +# FDTD CUDA (Project)
 +
 +**[FDTD CUDA](https://github.com/yanevskiv/fdtd-cuda)** is a project I built in order to practice HPC on the GPU. It's a C++20 library for 2D electromagnetic wave simulation using the finite-difference time-domain (FDTD) method. It's the sister project of [[fdtd-openmp|FDTD OpenMP]], which simulates electromagnetic waves in one dimension using C and OpenMP.
 +
 +The simulation updates the electric and magnetic fields on a **Yee grid**. It uses the TMz formulation, with one electric field component (Ez) and two magnetic field components (Hx and Hy). Sources introduce waves into the grid, probes record field values at selected points, and snapshots can be plotted or animated. A **perfectly matched layer (PML)** absorbs outgoing waves to reduce reflections at the edges of the simulation.
 +
 +The same simulation can run on a serial backend, an [[openmp|OpenMP]] backend, or a [[cuda|CUDA]] backend. The serial implementation serves as a reference for checking the parallel implementations. Both parallel backends have four optimization levels, each adding an optimization to the previous one. This lets me compare how changes such as SIMD, CUDA graphs, and shared memory affect performance while checking that the simulation still produces the expected results.
 +
 +The project includes a command-line simulation driver, benchmarks, and scripts for plotting and profiling. For example, the following command runs a 256 by 256 grid for 400 steps on the GPU, with an absorbing boundary, a Gaussian pulse, and a probe:
 +
 +```bash
 +$ build/out/debug/fdtd \
 +    --nx 256 \
 +    --ny 256 \
 +    --steps 400 \
 +    --boundary pml \
 +    --backend cuda \
 +    --pulse 96,128 \
 +    --probe 128,200 \
 +    --output out
 +```
 +
 +## Concepts
 +
 +- [[fdtd-cuda-fdtd|FDTD]]
 +  - [[fdtd-cuda-yee-grid|Yee grid]]
 +  - [[fdtd-cuda-tmz-formulation|TMz formulation]]
 +  - [[fdtd-cuda-time-stepping|Time stepping]]
 +  - [[fdtd-cuda-cfl-stability-condition|CFL stability condition]]
 +  - [[fdtd-cuda-update-coefficients|Update coefficients]]
 +- [[fdtd-cuda-boundary-conditions|Boundary conditions]]
 +  - [[fdtd-cuda-pec|Perfect electric conductor (PEC)]]
 +  - [[fdtd-cuda-pmc|Perfect magnetic conductor (PMC)]]
 +  - [[fdtd-cuda-pml|Perfectly matched layer (PML)]]
 +- [[fdtd-cuda-sources|Sources]]
 +  - [[fdtd-cuda-gaussian-pulse|Gaussian pulse]]
 +- [[fdtd-cuda-probes|Probes]]
 +- [[fdtd-cuda-snapshots|Snapshots]]
 +- [[fdtd-cuda-simulation-backends|Simulation backends]]
 +  - [[fdtd-cuda-serial-backend|Serial backend]]
 +  - [[fdtd-cuda-openmp-backend|OpenMP backend]]
 +    - [[fdtd-cuda-loop-parallelization|Loop parallelization]]
 +    - [[fdtd-cuda-simd|SIMD]]
 +    - [[fdtd-cuda-thread-affinity|Thread affinity]]
 +  - [[fdtd-cuda-cuda-backend|CUDA backend]]
 +    - [[fdtd-cuda-thread-blocks|Thread blocks]]
 +    - [[fdtd-cuda-cuda-graphs|CUDA graphs]]
 +    - [[fdtd-cuda-shared-memory|Shared memory]]
 +    - [[fdtd-cuda-tiling|Tiling]]
 +    - [[fdtd-cuda-asynchronous-transfers|Asynchronous transfers]]
 +- [[fdtd-cuda-numerical-validation|Numerical validation]]
 +  - [[fdtd-cuda-floating-point-tolerance|Floating-point tolerance]]
 +  - [[fdtd-cuda-bitwise-reproducibility|Bitwise reproducibility]]
 +- [[fdtd-cuda-performance-analysis|Performance analysis]]
 +  - [[fdtd-cuda-benchmarking|Benchmarking]]
 +  - [[fdtd-cuda-profiling|Profiling]]
 +  - [[fdtd-cuda-memory-bandwidth|Memory bandwidth]]
  
fdtd-cuda.md · Last modified: by 127.0.0.1