Fixed-point dissipative particle dynamics with symmetric per-pair RNG
/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 is a fixed-point dissipative particle dynamics (DPD) fluid. N particles
live in a periodic cube of side 2^(LOGG+12) (cell size 2^12, so G = 2^LOGG cells per
axis) with signed 64-bit integer velocities. Initial positions are uniform in the box;
velocities are uniform in [-v0, v0] with v0 = 2^(12-VSH); each particle has one of 4
species. Three length-1024 distance-bucket weight tables wC, wD, wR and a symmetric
4x4 interaction matrix aij are built deterministically from seed.
A cutoff cell list (cutoff d2 < 2^24) is rebuilt each step using minimum-image
displacements. For each neighbour pair (i, j) with bucket k = d2 >> 14:
- draw a symmetric random value
xifrom a counter-based hash keyed by(seed, step, min(i,j), max(i,j))(soiandjget the samexi); - conservative
fC = aij[si][sj] * wC[k]; - dissipative
fD = -(GAMMA*wD[k]) * (dot / 2^12)wheredot = d . dvis the dot product of the displacement and relative velocity; - random
fR = (SIGMA*wR[k]) * xi; - the pair scalar is
fs = fC + fD + fR, and the impulse added to atomiis(fs * d) / FDIVper component (FDIV = 2^FSH).
Then v += force (the sum of per-pair impulses) and x += v (wrapping). Because fs and
xi are symmetric while the displacement/relative-velocity flip sign, and integer division
truncates toward zero, the impulses on i and j are exact negatives: total momentum is
conserved exactly (velocities are 64-bit and nothing is clamped). Per printed step the
program reports total momentum (an invariant) and ksum = sum of v^2 (a kinetic checksum
that evolves as the thermostat balances dissipation and noise). After T steps it reports a
position hash, a velocity hash, total momentum, and six components of four sampled particles.
Input format
One simulation on a single line:
N LOGG T EVERY GAMMA SIGMA FSH VSH seed
N >= 1; LOGG in [2, 19]; T >= 0 steps printing every EVERY; GAMMA >= 0;
SIGMA >= 0; FSH (impulse shift, typically [28, 34]); VSH in [1, 11]; seed
unsigned 64-bit.
Output format
dpd N <N> box 2^<PB> grid <G>^3 steps <T>
step <t> mom <mx> <my> <mz> ksum <K> (for each printed step)
position_hash <hex16> velocity_hash <hex16>
momentum <px> <py> <pz>
particle <i> x <x> <y> <z> v <vx> <vy> <vz> (4 lines)
Momentum components are signed; ksum and the hashes are unsigned 64-bit (mod 2^64).
Hidden inputs
Correctness inputs cover N = 1 (no neighbours), N = 2, T = 0, weaker and stronger
force settings, finer grids, and random configurations with N in [1500, 12000], LOGG
in [3, 6], T in [1, 8], GAMMA in [2, 8], SIGMA in [4, 16], FSH in [30, 33],
VSH in [2, 4]. The timing input uses N = 600,000, LOGG = 5, T about 78,
GAMMA = 4, SIGMA = 8, FSH = 31, VSH = 2.
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 one DPD simulation of N = 600,000 particles in a 32^3 cell grid (cells hold ~18 particles) run for about 78 steps (printing every ~3 steps), each step summing all pair forces with a symmetric per-pair random draw. 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.