Four coupled integer species with per-species stencils
/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
Four integer species a, b, c, d (each in [0, 4095], stored as an array of 4 x int16 per
cell) live on a W x H grid that is periodic in x and mirrored in y: row -1 reads row 0,
row -2 reads row 1, row H reads row H-1, row H+1 reads row H-2 (clamped into range
for grids shorter than 2 rows). Initial values, a 64x64 reaction table with entries in
[-AMP, AMP] and a feed map (one value in [0, 15] per 16x16 block) come from seed.
Each of T steps updates all cells synchronously from the previous state:
la = 4 von Neumann neighbours of a - 4a
lb = 8 Moore neighbours of b - 8b
lc = c at distance 1 and 2 along both axes (8 cells) - 8c
ra = LUT[a >> 6][b >> 6]
a' = a + (la >> 3) + ra - ((a*c) >> 13) + (d >> 5)
b' = b + (lb >> 4) - ra + ((a*a) >> 14) - ((b*d) >> 14) + feed(x>>4, y>>4)
c' = c + ((3*lc) >> 5) + ((b*(4095-c)) >> 15) - (c >> 6)
d' = d + ((c-d) >> 4) + (a > 3000 ? 3 : 0) - (b > 3500 ? 5 : 0)
All shifts are arithmetic on 32-bit ints; every result is clamped to [0, 4095].
Input format
W H T
AMP
SEED
Output format
Let ck = max(1, T / 8). After step s (1-based) whenever s % ck == 0 or s == T:
step s a HASH SUM b HASH SUM c HASH SUM d HASH SUM
then final T ... in the same format (also when T = 0), then samples followed by the final
a,b,c,d of six hash-chosen cells. The hash of species k (0..3) is the sum over cells
i = y*W + x of mix64((i << 34) ^ (k << 32) ^ value) modulo 2^64, printed as 16 hex digits.
Hidden inputs
1 <= W, H <= 4096, 0 <= T <= 5000, 1 <= AMP <= 48, any 64-bit seed. Correctness inputs
include 1x1 and 2x2 grids, single rows and columns (where the radius-2 wrap and mirror fold
back onto the same cells), T = 0, tiny grids with many steps and a 4096-wide strip. The timing
input uses sides in [2816, 3328] and about 2600 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 main computation must execute on the GPU. Renaming CPU code to .cu, running a
CPU fallback, or launching a dummy kernel while computing the answer on the CPU does not satisfy this task.
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. - GPU verification uses the backend selected for this run: an H100 attached to the separate verifier, or a remote H100 worker. Hidden inputs use a fresh random seed.
- For public GPU experiments, use
/app/bin/gpu_run [--backend auto|local|remote] [--repeat N] [--quiet] SOURCE.cu INPUT_FILE.... The default usesGPU_RUNNER_URLwhen configured, otherwise a GPU attached to this sandbox. Sandbox GPU access is configured independently from verification; a CPU-only sandbox needs a runner URL. - Correctness: every hidden input (small edge cases plus the timing input) must pass. Your output must be identical to the CPU program's output (trailing whitespace ignored). Any mismatch, crash or timeout gives reward 0.
- GPU execution: a separate, untimed CUPTI check must observe completed GPU kernel activity on the hidden timing input. A CPU-only submission receives reward 0 even if its output is correct.
- Speed: The timing input is a grid of about 3072 x 3072 cells (each side drawn from [2816, 3328]) stepped about 2600 times (drawn from [2200, 3000]). 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.