Skip to Content
PhotonStack Gallery
Validation

FDE and EME on the GPU

psmeme's CUDA mode solver and EME against its own CPU backend on an RTX 4090 - same modes to 1e-13, 13x to 41x faster.

psmeme is the PhotonStack full-vector finite-difference eigenmode (FDE) solver and eigenmode-expansion (EME) solver. This page benchmarks its CUDA backend against its CPU backend on a silicon strip waveguide, refined from 0.06 to 2.2 million unknowns, with and without PML, plus a 16-section EME taper. Two things are checked: that the GPU returns the same modes as the CPU (effective index difference and mode overlap), and how much faster it is.

Setup

Mode-solver geometry. Silicon strip waveguide, 500 × 220 nm, n = 3.48, in silica n = 1.444, in a 4 × 3 µm window, at a wavelength of 1.55 µm. The grid is uniform and refined from 200 × 150 to 1200 × 900 cells. 10 modes are requested.

Two variants.

  • strip: no PML, real arithmetic.
  • strip + PML: PML enabled with num_pml = 12 on both transverse axes, complex arithmetic.

Solvers. Both backends run the same shift-invert Krylov-Schur algorithm in FP64. The CPU backend uses a supernodal sparse LU; the CUDA backend performs a multifrontal factorization on the GPU and keeps the Krylov basis in device memory. Every case is solved on the GPU twice: cold (fresh multifrontal plan and device upload) and warm (structure reused from the previous solve, as happens for successive cross sections of an EME device; warm time from 3 repeats).

EME case. A linear taper of 16 cross sections on a 400 × 300 grid, strip width from 400 nm to 1.2 µm, each section 1 µm long, 12 modes per cross section. The CPU backend solves the cross sections concurrently (one per thread, 16 threads); the CUDA backend solves them one after the other on the GPU.

Hardware. NVIDIA GeForce RTX 4090 (24.0 GiB, sm_89); CPU side of the same machine with 32 threads available. Run dated 2026-09-29. One-off CUDA initialization (context, cuBLAS/cuSOLVER load, first solve) took 0.215 s and is not included in the per-case times.

Results

All times are wall-clock seconds on the RTX 4090 machine. "eig" is the eigensolve phase alone.

CaseGridUnknownsCPU total (s)CUDA cold (s)CUDA warm (s)Speedup cold / warmCPU eig (s)CUDA eig (s)eig speedupmax |Δneff|min overlapGPU mem (MiB)
strip200×150596502.970.2310.20112.9× / 14.8×2.750.11324×4.3e-141.0000000000129
strip400×30023930013.80.7020.60719.6× / 22.7×12.60.28145×2.5e-141.0000000000574
strip600×45053895032.81.761.3718.6× / 24.0×29.50.60848×3.7e-141.00000000001414
strip800×60095860062.93.002.4621.0× / 25.6×56.61.0653×1.1e-131.00000000002519
strip1000×7501498250104.14.493.8823.2× / 26.8×93.01.6556×1.7e-131.00000000004529
strip1200×9002157900–6.565.91––2.45–––6176
strip + PML200×1505965022.90.7610.71230.0× / 32.1×22.50.59938×3.0e-131.0000000000242
strip + PML400×300239300275.77.056.7639.1× / 40.8×273.66.2844×6.0e-111.00000000001080
strip + PML800×600958600–23.322.6––20.3–––4762

Rows with "–" in the CPU columns were solved on the GPU only.

EME taper (16 cross sections, 400×300, 12 modes):

CPU (16 threads)CUDASpeedupmax |Δneff|max |ΔS21|
Wall time119.60 s9.44 s12.7×8.1e-142.2e-11

The fundamental-mode transmission of the taper, |S21[0,0]|², is 0.998933.

For reference, the fundamental-mode effective index of the lossless strip returned by the CUDA backend is 2.42151 on the 200×150 grid and 2.45098 on the 400×300 grid.

Four modes of a circular step-index waveguide

Mode-field plot saved by psmeme as modes_cuda.png: four modes of a circular step-index example, with neff 1.451254, 1.451252, 1.441390 and 1.441316. This is a separate small example and not one of the benchmark cases above.

Comparison

The CUDA backend is compared only against psmeme's own CPU backend, on the same machine, grid and algorithm.

  • Accuracy. Wherever both backends ran, the effective indices agree to between 2.5e-14 and 3.0e-13, with one case (strip + PML, 400×300) at 6.0e-11. The minimum mode overlap between CPU and GPU modes is 1.0000000000 in every compared case. For the EME taper the S-matrix element S21 differs by at most 2.2e-11.
  • Speed, lossless strip. Total solve time is 12.9× to 23.2× faster cold and 14.8× to 26.8× faster warm; the eigensolve phase alone is 24× to 56× faster. The speedup grows with problem size.
  • Speed, with PML. 30.0× / 32.1× (cold / warm) at 200×150 and 39.1× / 40.8× at 400×300.
  • EME. 12.7× against a CPU run that already uses 16 threads across cross sections.

Limitations

  • This is a self-consistency and speed benchmark, not an accuracy validation. Agreement between the two backends shows that the GPU reproduces the CPU solver; it says nothing about discretization error. The fundamental neff still changes between the 200×150 and 400×300 grids (2.42151 vs 2.45098), and the benchmark geometry is staircased by cell centres without sub-pixel smoothing. No external solver or analytic reference is used on this page.
  • The largest cases have no CPU reference. strip 1200×900 and strip + PML 800×600 were run on the GPU only, so they have timings but no Δneff or overlap check.
  • PML cases are much more expensive on both backends. With PML the eigensolver needs far more operator applications (for example 3488 on the GPU at 400×300, against 224 without PML), and the 400×300 PML case takes 7.05 s on the GPU against 0.702 s without PML. The backend agreement in that case (6.0e-11) is also looser than in the others.
  • The single-solve CPU baseline is single-threaded in the eigensolve. The CPU backend runs one mode solve on one thread and parallelizes across EME cross sections instead. The per-solve speedups (13× to 41×) are therefore against one CPU core's worth of eigensolve; the EME figure (12.7× against 16 threads) is the fairer whole-device comparison.
  • GPU memory grows to 6176 MiB at 2.2 million unknowns (lossless) and 4762 MiB at 0.96 million unknowns with PML.
  • The CPU model is not recorded in the benchmark report (only "CPU threads: 32"), and the mode-field figure has no accompanying report describing how it was produced.
  • The report gives one wall time per configuration (warm GPU solves use 3 repeats) and no run-to-run spread.

Reproduce

Requires the CUDA toolkit (12.x), CMake ≥ 3.20 and a host compiler.

# the benchmark on this page; writes report.md and report.json to outputs/benchmarks/cuda/
cargo run --release -p eme --features cuda --example cuda_bench

# options (defaults shown)
cargo run --release -p eme --features cuda --example cuda_bench -- \
  --sizes 200,400,600,800,1000,1200 --pml-sizes 200,400,800 \
  --cpu-max 1000 --cpu-max-pml 400 \
  --modes 10 --repeats 3 --eme-nx 400 --eme-sections 16 --eme-modes 12 \
  --out outputs/benchmarks/cuda

# per-stage timing on the device
cargo run --release -p fde --features cuda --example cuda_profile -- 800

# CPU/CUDA comparison tests (skipped automatically without a GPU)
cargo test --release -p fde -p eme --features eme/cuda

For the FDTD side of the GPU story see GPU performance and roofline.

On this page