Skip to Content
PhotonStack Gallery
Validation

GPU performance and roofline

PSFDTD throughput on an RTX 4090 measured against the device's own memory-bandwidth and FMA limits, with CPU and Meep baselines.

This page reports how fast PSFDTD steps the Yee grid and how close that is to what the hardware allows. The device limits of an NVIDIA GeForce RTX 4090 (DRAM bandwidth, L2 bandwidth, FP32/FP64 FMA rate) are measured first; every PSFDTD operator is then placed on a roofline against those limits. The headline result: the fused Yee + CPML half-steps reach 91.5% to 92.6% of the theoretical DRAM bandwidth, giving 10.16 Gcells/s (FP32) and 5.06 Gcells/s (FP64) on a 3D 256³ grid. A separate CPU baseline on an Apple M3 Max compares PSFDTD with Meep on identical problems.

Setup

Throughput definition. Grid cells (including PML) × time steps / time-stepping wall time. Setup (meshing, sub-pixel smoothing, allocation) is excluded and timed separately.

GPU baseline. NVIDIA GeForce RTX 4090 (cuda:0, sm_89, 128 SMs, driver-reported peak clock 2565 MHz, 25.8 GB memory, 72 MB L2), Windows 11, CUDA 12.9, driver 591.86. CPU reference on the same machine: AMD Ryzen 9 9950X (16 cores / 32 threads). Runs dated 2026-09-29.

CPU / Meep baseline. Apple M3 Max (12 performance + 4 efficiency cores), macOS, Meep 1.33.0-beta (conda-forge; serial nompi build and MPICH build). PSFDTD and Meep run the identical problem: same grid, same dt (Courant 0.5), same number of steps, same monitors. Meep is double precision and parallelized with MPI processes; PSFDTD is reported in FP64 (same precision) and FP32 (default) and uses threads. Run dated 2026-09-27.

Operator benchmark. 3D grid 256×256×256 and 2D grid 4096×4096 (16.8 Mcells each), 10 CPML layers, FP32 and FP64. Bytes per call use a minimal DRAM traffic model (each array element read/written once, stencil neighbours hit cache, CPML counts only the ψ reads/writes); FLOPs are counted statement by statement from the kernel source. "Kernel" time is a CUDA Graph replay (no host launch overhead).

Results

Device limits, RTX 4090: theoretical vs measured

MetricTheoreticalMeasuredMeasured / theoreticalHow
DRAM bandwidth (read)1008 GB/s957 GB/s94.9%read-only stream, arrays ≥ 4× L2
DRAM bandwidth (copy)same896 GB/s88.9%b = a
DRAM bandwidth (triad)same910 GB/s90.3%a = b + s·c
L2 bandwidth (read / copy / triad)not published4882 / 4333 / 5274 GB/s4.8× DRAMall arrays resident in L2
FP32 FMA84.0 TFLOP/s85.1 TFLOP/s101.2%128 lanes/SM × 128 × 2 × clock
FP64 FMA1.31 TFLOP/s1.18 TFLOP/s89.9%2 lanes/SM (1/64 of FP32)

The theoretical compute rate uses the driver-reported peak clock; under load GPU Boost can exceed it, which is why the FP32 measurement is slightly above 100%. Theoretical roofline ridge points: FP32 83 flop/B, FP64 1.30 flop/B.

Operators on the 3D 256³ grid, RTX 4090

OperatorKernel µs (FP32)GB/s (FP32)% of DRAM peak (FP32)flop/B (FP32)Kernel µs (FP64)GB/s (FP64)% of DRAM peak (FP64)flop/B (FP64)
step_h (fused CPML)720.592691.8%0.5351443.892491.6%0.268
step_e (fused CPML)930.493392.6%0.4781868.892992.2%0.239
update_h649.593092.2%0.5001301.592892.1%0.250
update_e864.593292.4%0.4381718.593793.0%0.219
dft (50 frequencies)25.286786.0%0.12524.987686.9%0.124
disperse (up to 2 poles)323.156455.9%0.225549.559959.4%0.130
offdiag_e36.4949.3%1.52842.912812.7%0.917

Yee step (step_h + step_e) on the RTX 4090:

GridFP32FP64
3D 256³10.16 Gcells/s5.06 Gcells/s
2D TM 4096²23.08 Gcells/s11.56 Gcells/s

Roofline of PSFDTD operators on the RTX 4090

Roofline (RTX 4090): every PSFDTD operator plotted by arithmetic intensity against the measured bandwidth and FMA ceilings.

Size sweep: L2-resident to DRAM-bound, RTX 4090

Fused Yee + CPML half-steps, kernel time. Working set = 6 fields + 3 inverse-ε arrays in 3D.

DimnPrecisionWorking set (MB)Kernel Gcells/sWith launch Gcells/sEffective GB/s% of DRAM peak
3D32FP321.16.512.8085985.2%
3D96FP3230.434.8930.723629360.0%
3D128FP3272.017.6517.291747173.3%
3D256FP32576.010.0910.1792391.5%
3D384FP321944.010.4710.4393292.4%
3D96FP6460.810.099.862099208.3%
3D256FP641152.05.095.0793292.4%
3D384FP643888.05.175.2492191.4%
2D2048FP3264.0105.67100.024260422.6%
2D8192FP321024.023.2623.0693292.5%
2D1024FP6432.039.6935.393225319.9%
2D8192FP642048.011.6011.5393092.2%

Throughput and effective bandwidth versus grid size on the RTX 4090

Size sweep (RTX 4090): effective bandwidth exceeds the DRAM peak while the working set fits in the 72 MB L2, then settles at about 92% of DRAM peak.

Whole-engine throughput, RTX 4090 vs CPU on the same machine

psfdtd bench: vacuum + CPML + point source. CPU is the PSFDTD CPU backend on the AMD Ryzen 9 9950X.

Dimn (without PML)CellsPrecisionGPU Mcells/sCPU Mcells/sGPU / CPU
2D10241.09 MFP3245920139233.0×
2D10241.09 MFP6430545103029.6×
2D409616.94 MFP3222674132117.2×
2D409616.94 MFP641145963018.2×
3D640.59 MFP321809289220.3×
3D640.59 MFP64798646417.2×
3D1283.24 MFP32837957814.5×
3D1283.24 MFP64462122620.5×
3D1929.53 MFP32901047419.0×
3D1929.53 MFP64492724120.4×
3D25621.02 MFP32941349319.1×
3D25621.02 MFP64507124520.7×
3D36054.87 MFP32978747620.6×
3D36054.87 MFP64520723322.3×

The benchmark-suite cases (identical problems to the Meep comparison below), RTX 4090 against the best PSFDTD CPU thread count on the Ryzen 9 9950X, in Mcells/s:

CaseCells × stepsCPU best FP64cuda:0 FP64SpeedupCPU best FP32cuda:0 FP32Speedup
vac3d_n640.26 M × 200499 (16T)543510.9×1317 (16T)94077.1×
vac3d_n1282.10 M × 200279 (16T)454716.3×678 (16T)1268218.7×
vac3d_n1927.08 M × 100250 (16T)489319.6×515 (16T)931818.1×
vac2d_n10241.05 M × 4001779 (16T)2872416.1×3401 (16T)4620513.6×
vac2d_n20484.19 M × 200773 (16T)1135614.7×2147 (16T)7836236.5×
work3d_n128 (sphere + dipole + 6×50-frequency flux box)2.10 M × 200214 (16T)373517.4×392 (32T)763019.5×

Throughput of PSFDTD CPU and CUDA backends on the RTX 4090 machine

Benchmark-suite throughput on the RTX 4090 / Ryzen 9 9950X machine, CPU threads against cuda:0.

CPU baseline against Meep, Apple M3 Max

Local Meep 1.33.0-beta runs on the same machine, same grid, time step and step count. Throughput in Mcells/s.

CaseCells × stepsMeep 1 procMeep bestPSFDTD 1 thread FP64 / FP32PSFDTD best FP32 (threads)vs Meep 1 proc (same precision, 1 core)vs Meep best (best config)
vac3d_n640.26 M × 2005067 (np=4)160 / 2601783 (12T)3.2×26.6×
vac3d_n1282.10 M × 20083123 (np=4)195 / 3231361 (12T)2.3×11.1×
vac3d_n1927.08 M × 10080101 (np=4)207 / 3711557 (12T)2.6×15.4×
vac2d_n10241.05 M × 4008402409 (np=4)973 / 18158688 (12T)1.2×3.6×
vac2d_n20484.19 M × 2008071339 (np=2)833 / 18104509 (4T)1.0×3.4×
work3d_n1282.10 M × 20071111 (np=4)154 / 238838 (12T)2.2×7.5×

Setup time for the 3D sphere case on the M3 Max: PSFDTD 0.05 s, Meep 7.6 s (Meep uses adaptive cubature for sub-pixel smoothing).

Throughput of PSFDTD and Meep on the Apple M3 Max

Benchmark-suite throughput on the Apple M3 Max: Meep (1, 2, 4 MPI processes) against PSFDTD threads in FP64 and FP32.

Comparison

  • Against the hardware limit (RTX 4090). On large grids step_h / step_e reach 91.5% to 92.6% of the theoretical DRAM bandwidth (average 928 GB/s), comparable with the measured STREAM read 957 GB/s and triad 910 GB/s. Arithmetic intensity is 0.30 to 0.54 flop/B (FP32) and 0.15 to 0.27 flop/B (FP64), far below the ridge points, so the Yee update is bandwidth-bound: FP32 uses ≤ 0.6% of peak compute, FP64 10.7% to 18.8%.
  • FP64 costs exactly its bytes. Throughput halves: 3D 256³ 10.16 → 5.06 Gcells/s, 2D 4096² 23.08 → 11.56 Gcells/s.
  • Fused CPML. A two-pass implementation (main update, then a full-grid CPML correction) gives 8.3 Gcells/s on 256³; the fused version 10.2 (+23%).
  • Against the CPU backend on the same machine (Ryzen 9 9950X). On large 3D grids (more than 5 Mcells) the whole engine reaches 9.0 to 9.8 Gcells/s in FP32 and 4.9 to 5.2 Gcells/s in FP64, which is 19× to 22× the same-precision CPU backend.
  • Against the M3 Max CPU baseline. The same large-3D GPU figures are 5× to 7× the best PSFDTD FP32 throughput on the M3 Max (1.4 to 1.8 Gcells/s).
  • Against Meep (local Meep 1.33.0-beta, Apple M3 Max, CPU only). Same precision on one core: 2.2× to 3.2× in 3D, 1.0× to 1.2× in 2D. Best PSFDTD configuration against best Meep configuration: 7.5× to 26.6× in 3D, 3.4× to 3.6× in 2D.

There is no Meep run on the RTX 4090 machine and no GPU-vs-Meep measurement on common hardware.

Limitations

  • Small grids are limited by host launch overhead. Smallest 3D case n=32 (FP32): kernel 6.5 Gcells/s, but only 2.8 with per-call launches. In the sweep, 9 sizes have host time more than 30% longer than kernel time. Each launch costs about 5 µs under Windows/WDDM.
  • Kernel-level numbers are not whole-engine numbers. The 10.16 Gcells/s figure is a CUDA Graph replay of the two half-steps; the whole engine on the same 3D 256 problem reaches 9413 Mcells/s (FP32).
  • Sparse and monitor operators are well below the bandwidth limit. Dispersive ADE 55.9% to 60.9% of DRAM peak; the off-diagonal smoothing terms only 9.3% to 12.7% (latency-bound neighbour accesses, but present only on interfaces, 59 to 72 µs in the time loop). On the M3 Max, a monitor-heavy case (300 DFT flux points × 50 frequencies updated every step) loses about 40% throughput.
  • 2D single-core FP64 is only on par with Meep (1.0× to 1.2× on the M3 Max).
  • M3 Max measurements carry noise. The machine had desktop load during measurement (about 1 to 1.5 cores), so the 12- and 16-thread numbers are noisy. 16 threads is usually slower than 12 on that machine (efficiency cores).
  • Meep's multi-process baseline is restricted to np = 1, 2, 4. The conda-forge MPICH Meep on that Mac slows down sharply for np ≥ 6 (np=8 gives only 3.6 Mcells/s on 64³). The source attributes this to the local MPI/scheduler environment and not to Meep itself; it should be re-measured on a Linux cluster.
  • The reason for the single-core advantage over Meep is not profiled. The source report offers a conjecture (direct E/H update without a D field, vectorized row kernels) and states that Meep has not been profiled item by item.
  • Odd points in the benchmark-suite table. Some entries are far above the DRAM-bound rate, consistent with the L2-resident regime of the size sweep (for example vac2d_n2048 FP32 at 78362 Mcells/s, 36.5×), and on the Ryzen 32 threads is often slower than 16. These short runs (100 to 400 steps) should not be read as steady-state large-grid throughput.
  • Both baseline reports record the commit as uncommitted.

Reproduce

GPU roofline and device limits (RTX 4090 baseline):

cargo build --release --features psfdtd-cli/cuda
python -m bench.gpu_roofline --out bench/results/gpu-roofline    # devbench + opbench + size sweep + whole engine
./target/release/psfdtd devbench -d cuda:0                        # device limits (STREAM, FMA)
./target/release/psfdtd opbench -d cuda:0 --dims 3 -n 256 --precision double

CPU / Meep benchmark suite (M3 Max baseline):

python -m bench.run performance --threads 1,4,12,16 --meep-np 1,2,4

See also the correctness suite, which verifies that the GPU backend reproduces the CPU backend to rounding.

On this page