Ewance
← All challenges Software Engineer

Port a Numerical Kernel from CPU to GPU for a CFD Simulator

Duration
4 weeks
Level
Expert
Type
Code
Team
1 to 5 people

The situation

The subcontractor (3 active aerospace-prime contracts, 6-person sim-tech team) bills by the design iteration; 4.5 hours per iteration caps how many they can run per contract per week.

Your task

Port a Navier-Stokes stencil kernel from CPU + OpenMP to CUDA on an A100, hit >=60 percent peak FP64 throughput, and validate per-cell numerical equivalence within 1e-8.

The brief

What you do

  1. Receive the existing CFD solver (C++17 + OpenMP, around 8,000 lines, the hot kernel is a 7-point stencil sweep over a 512^3 grid), the validation harness, and access to an A100 80GB testbed.
  2. Plan the port: choose between native CUDA, CUDA + cuBLAS for the linear-solve substep, or Kokkos for portability.
  3. Implement the stencil kernel using shared-memory tiling (32x32x4 with halo), maximize occupancy without spilling, fuse the boundary-condition update where useful.
  4. Validate numerical equivalence per cell within 1e-8 against the CPU baseline.
  5. Profile with Nsight Compute: report achieved FP64 throughput, memory-bandwidth utilization, and warp-execution efficiency.

You deliver

The CUDA kernel + harness, the numerical-validation report, an Nsight Compute report (annotated), and a 6-page handover memo for the simulation-tech lead.

What you will practice

  • Port a stencil kernel to CUDA with shared-memory tiling
  • Tune occupancy + register usage without spills
  • Validate per-cell numerical equivalence rigorously
  • Read Nsight Compute output and act on it

A suggested way in

  1. 32x32x4 tiling with halo regions is a strong baseline; tune in 16-wide steps to match warp width
  2. FP64 stencils are usually memory-bound on A100 — target peak bandwidth, not peak FLOPS
  3. Boundary conditions in a separate kernel let occupancy stay high; fusing only helps if both kernels are tiny

Skills you will practice

Gpu programming, Cuda, Parallelism, Performance optimization, Cpp, Benchmarking

How it is assessed

  • Kernel correctness30%

    Per-cell error within 1e-8 across the full grid.

  • GPU performance30%

    Achieves >=60 percent peak FP64 throughput or peak bandwidth.

  • Profiling discipline20%

    Nsight report annotated with bottleneck and next-step targets.

  • Handover memo20%

    Sim-tech lead can deploy and maintain from the memo.

Resources

  • CUDATool

    Target GPU programming model.

  • Nsight ComputeTool

    Kernel-level performance profiler.

  • Nsight SystemsTool

    System-level trace for host+device interaction.

  • KokkosTool

    Optional portability layer for future GPU targets.

  • CMakeTool

    Build system for the mixed C++ + CUDA project.

  • NotionTool

    Author handover memo and validation report.

Sample Ewance certificate of completion, verified by LearnCoin
Sample certificate
Your proof

Finish it. Earn this.

A verified certificate with your name. Anyone can check it.

Time to practice.

Solve this challenge
Related challenges

More like this.