Batched 1D compressible-Euler WENO5 finite volume with an invented EOS
/app/cpu/main.cpp is a multicore CPU program (C++17, OpenMP). It is built as
/app/bin/cpu_baseline with g++ -O3 -march=native -fopenmp -std=c++17 and run as
cpu_baseline INPUT_FILE
It reads one input file and writes its result to stdout.
What the program computes
The program advances a batch of independent 1D compressible-Euler systems with a
5th-order WENO finite-volume scheme for a fixed number of SSP-RK3 steps with a fixed
time step. Each system is a periodic domain [0,1) of NX cells with conserved state
(rho, rho*u, E).
Equation of state (invented). Pressure is an ideal thermal part plus a polytropic cold-pressure correction:
p = (GAMMA-1)*(E - 0.5*rho*u^2) + BETA*rho^GSTIFF
with GAMMA = 1.4, BETA = 0.4, GSTIFF = 2. The wave-speed estimate used by the flux
is a = |u| + sqrt(GAMMA*p/rho + BETA*GSTIFF*rho^(GSTIFF-1)).
Reconstruction. Primitive variables (rho, u, p) are reconstructed to both sides of
every interface with WENO5-JS (Jiang-Shu smoothness indicators, linear weights
0.1, 0.6, 0.3, eps = 1e-6). Tiny positivity floors (1e-9) are applied to
reconstructed density and pressure.
Flux. A local Lax-Friedrichs (Rusanov) interface flux uses the Euler flux
F = (rho*u, rho*u^2 + p, u*(E+p)) and alpha = max(a_L, a_R).
Time integration. SSP-RK3 with fixed dt = 0.08*dx, for NSTEP steps. Each stage
computes the flux divergence with periodic boundaries.
Initial condition. Each system gets its own smooth periodic field: rho, u, p
are sums of 4 Fourier modes with hashed amplitudes (decaying in mode number) and phases
from a SplitMix64 counter hash of the seed, around rho = 1, u = 0, p = 1. The
evolution stays smooth (pre-shock) over the fixed step count, so cell sampling is not
chaotic. All reductions use a fixed order (thread-count independent).
Input format
NSYS NX NSTEP seed
One line: number of systems NSYS >= 1, cells per system NX >= 8, step count
NSTEP >= 1, and a 64-bit seed.
Output format
nsys <NSYS> nx <NX> nstep <NSTEP>
sum_rho <total mass> sum_mom <total momentum> sum_E <total energy>
l2_rho <L2 norm of rho> l2_mom <L2 norm of mom> l2_E <L2 norm of E>
cell <s> <i> <rho> <mom> <E> (6 sampled cells)
Floating-point fields use %.10e. Comparison is numeric with rtol = 1e-5,
atol = 1e-7.
Hidden inputs
Correctness inputs (10 files) include a single tiny system (NX = 8), small batches with
NX in [16, 512] and NSTEP in [4, 300], a single large system (NX = 1536), and a
64-system batch. The timing input is 256 systems of 1536 cells advanced 1400
steps.
Your task
Port this program to CUDA in /app/gpu/main.cu: same command line (PROGRAM INPUT_FILE),
same output on stdout. Then make it as fast as you can on the GPU while keeping the output correct.
The CPU source is the specification: when this text and the code disagree, the code wins.
How you are scored
- Only
/app/gpu/main.cuis collected. It is compiled withnvcc -O3 -arch=sm_90 -std=c++17 -o port /app/gpu/main.cu; no extra libraries are linked. The CUDA runtime and the header-only libraries that ship with the CUDA toolkit (CUB, Thrust, libcu++) are allowed. - Your source must not contain any of:
system(,popen(,fork(,exec*,dlopen(,getenv(,#include <filesystem>,/tests/,/proc/. The program may read only the input file it is given. - Grading runs on one H100 in a fresh container without network. Inputs are generated with a new random seed at grading time, so they cannot be known in advance.
- Correctness: every hidden input (small edge cases plus the timing input) must pass.
Your output must have the same tokens as the CPU program's output. Numeric tokens may differ by at most
atol + rtol*|expected|with rtol = 1e-05 and atol = 1e-07; every other token must be identical. Any mismatch, crash or timeout gives reward 0. - Speed: The timing input is a batch of 256 independent systems of 1536 cells each, advanced 1400 SSP-RK3 steps with WENO5 reconstruction (about 0.55 billion cell-steps, each stage doing six WENO5 reconstructions). Your port and our GPU reference are each run on it
once to warm up and then 5 times, interleaved; the time is the wall clock of the whole process
(including CUDA initialisation, input parsing and output). When correct,
reward = min(2, t_reference / t_yours)using the medians. /app/inputs/holds a few public inputs./app/bin/run_public.shcompiles your port with the flags above and compares it against the CPU baseline on each of them.