All projects

2024 · Performance / Systems Engineer

Fluid Solver Optimization (CPU, OpenMP, CUDA)

Reduced runtime 30.85s3.69s30.85\,\mathrm{s} \to 3.69\,\mathrm{s} (8.36×8.36\times) on CPU; best OpenMP 10.77×\approx 10.77\times at 1624\approx 16\text{–}24 threads; CUDA kernels reached 90.16GiB/s\approx 90.16\,\mathrm{GiB/s}.

Results

  • CPU30.85s3.69s30.85\,\mathrm{s} \to 3.69\,\mathrm{s} (8.36×8.36\times) via loop reordering + cache tiling + compiler/ILP optimizations.
  • OpenMPpeak performance around 162416\text{–}24 threads (1.38s\approx 1.38\,\mathrm{s}, 10.77×\approx 10.77\times); analyzed plateau from contention/sync effects.
  • CUDAlin_solve kernel dominated (89.6%\approx 89.6\%); achieved 90.16GiB/s\approx 90.16\,\mathrm{GiB/s} and minimized transfer overhead with persistent device allocations.

Overview

Optimized a 3D Stable Fluids solver: (1) CPU locality + ILP (loop reordering, tiling, division to mult), (2) shared-memory parallelism with OpenMP (collapse, reductions, static scheduling; Red/Black Gauss-Seidel), (3) GPU acceleration with CUDA (persistent device memory, kernelized solver steps, Nsight-guided tuning).

Profiled bottlenecks and scalability with perf/gprof and Nsight.

My work

  • Identified hotspots with gprof/perf (lin_solve as primary target) and set up repeatable benchmarks across grid sizes.
  • Implemented CPU-side locality/ILP improvements (loop order, tiling, hoisted reciprocals) and validated speedups.
  • Parallelized solver loops with OpenMP (parallel for + collapse; reductions for convergence metrics) and evaluated strong scaling.
  • Implemented CUDA kernels for solver steps (including Red/Black Gauss-Seidel updates) and tuned block geometry for coalescing (e.g., 32×4×132 \times 4 \times 1).
  • Used Nsight Systems/Compute to attribute time, verify memory behavior, and document trade-offs (kernel launch + sync constraints).

Technologies

  • C/C++
  • OpenMP
  • CUDA
  • Linux
  • perf
  • gprof
  • Nsight Systems
  • Nsight Compute

Source material