3D integer reverse-time migration with exact snapshot-free time reversal
/app/cpu/main.cpp is the source of a multicore CPU program (C++17, OpenMP).
The program takes one input-file path (PROGRAM INPUT_FILE) and writes its result to stdout.
What the program computes
A complete, all-integer 3D reverse-time-migration (RTM) job on a synthetic survey. The CPU source is the specification; all arithmetic is integer (64-bit intermediates, arithmetic right shifts on signed values are floor shifts, integer division truncates toward zero).
- Models. A true velocity model (m/s) on an
NX x NY x NZgrid (x fastest, z = depth, z = 0 at the top) is built from a linear gradient, four interfaces with small dips and a ripple (one of them a velocity decrease), and a salt ellipsoid at 4300 m/s, clamped to [1500, 4500]; all geometry comes from SplitMix64 hashes of the seed. A migration model is the true model box-smoothed with a 9-cell edge-clamped box filter along x, then y, then z (integer mean after every pass). Both become leapfrog coefficientsq = v*v*11585 >> 26. - Wave propagation. Wavefields are int32 arrays with a 2-cell halo. One step is
out = 2*cur - out + ((q * lap(cur) + 2^17) >> 18)with the 4th-order 13-point Laplacianlap = -90 c + 16 (6 nearest) - (6 second-nearest). Halo cells beyond the x/y/bottom faces are 0; the top halo is an antisymmetric mirror (free surface:u(-1) = -u(0),u(-2) = -u(1)). Cells withinNBof the x, y or bottom faces are damped:out = (out * g(d)) >> 15,g(d) = 32768 - d*d*3900/(NB*NB)withdthe penetration depth. The source wavelet (a 12-step half-width integer bump) is added at the source cell (depth z = 2). - Per shot. Model observed data in the true model and direct-wave data in the migration
model (receivers on z = 1 every
RSTRcells over the interior), recording every step. During the migration-model run the values of the 2-cell ring between the undamped region and its 2-cell-shrunk interior are saved for every step. Residual = observed - direct, zero before a per-receiver mute time (integer square root of the source offset), 16-sample linear taper, time gain from 1x to 2x. - Backward phase. The source wavefield is run backwards exactly: on the interior,
u(n-1) = 2 u(n) - u(n+1) + F(u(n)) + w(n)(the same arithmetic as the forward step) and the ring is restored from storage, so the reconstructed field is bit-identical to the forward one. Simultaneously the receiver wavefield is propagated in the migration model with the residual injected at the receivers, time reversed. EveryIMGE-th step the image gets(S*R) >> 10and the illumination(S*S) >> 10on the interior below z = 4. - Stack and analysis. Per shot,
image*4096 / (illum + (max illum >> 10) + 1)is added to the stack. The stack is filtered with a 7-point Laplacian; the program prints hashes, maxima, sign counts, a depth profile of |filtered| in 8 bands and the depth of the maximum filtered value on 12 hashed columns (first maximum wins).
Input format
NX NY NZ NB NT NSHOT RSTR IMGE
SEED
4 <= NB <= 40, NX - 2*NB >= 12, NY - 2*NB >= 12, NZ - NB >= 12, NT >= 1,
NSHOT >= 0, RSTR >= 1, IMGE >= 1, SEED a 64-bit unsigned integer.
Output format
One model line, one shot line per shot, stack and laplace lines, then (if the filtered
region is non-empty) a profile line and 12 pick lines, all integers / 16-digit hex hashes
exactly as printed by the CPU program. Output must match byte for byte.
Hidden inputs
Correctness inputs (about 12 files) use grids from 24 x 24 x 22 to about 52 x 50 x 40 with
NB 4..10, NT in {1, 2} and 40..220, NSHOT 0..3, RSTR 1..50 (including a single receiver
and a receiver on every interior surface cell) and IMGE 1..7. The timing input has
NX, NY in [150, 166], NZ in [108, 118], NB = 16, NT = 9*NZ + [0, 20], 3 shots,
RSTR = 4, IMGE = 2. Storing every source snapshot of one timing shot would take about
12 GB (and would cost as much memory traffic as the reverse step); the ring store takes about 0.5 GB. Results are integers and must be exact.
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.
This sandbox is for source generation only. Write /app/gpu/main.cu; compilation,
execution and verification are performed later in a separate verifier environment.
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.
- 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 158 x 158 x 113 cells with a 16-cell sponge, about 1,030 time steps and 3 shots recorded by a receiver every 4th cell on the surface (about 4e10 cell updates in total). 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 public input examples for understanding the input format.