Automatic earthquake catalogue: STA/LTA picking, space-time voting association, weighted-median L1 grid-search location
/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
An automatic earthquake-catalogue pipeline on a synthetic dense network. Everything is integer; the CPU source is the specification (SplitMix64 hashes of the seed generate all data).
- Records.
NSstations at hashed surface positions in a 120 x 120 km region (station delay -20..20 ticks, noise level 40..120). Each record hasDURsamples (1 tick = 10 ms): triangular noise, 12-sample glitches every 20,000 samples on average, and the P arrival of every hidden event (NEVevents at hashed positions, depths 2-25 km, origin times and magnitudes x10). Travel time in ticks from distanceD(m, integer square root) and source depthz(m):tt = sd + D*1600/(80000+z); arrivals get a hashed jitter of -3..3 ticks and a 64-sample integer wavelet scaled by magnitude and distance. - Picking. Characteristic function
CF[n] = |x[n]| + |x[n]-x[n-1]|, prefix sums, STA of 40 samples, LTA of 800 samples ending 10 samples before the STA window. Trigger on when STA/LTA >= 4 (and 50 samples after the previous trigger ended), off when < 1.5, after 400 samples or at the end of the record. The pick is the first sample in the 40 samples before the trigger whose 4-sample CF sum exceeds 12x the mean LTA level (else the trigger sample); weight 1..4 from the maximum ratio during the trigger, amplitude = max |x| over 64 samples. - Association. Coarse nodes 24 x 24 x 5 (5 km spacing, depths 3..23 km). Every pick adds its
weight to the 1-second origin-time bin
(t - tt(node, station)) / 100of every node. For each bin the best node maximizes the two-bin score (ties: smallest node); bins with score >= 20 that are strict maxima against the 3 earlier bins and not exceeded by the 3 later bins are candidates, processed by decreasing score (ties: earlier bin). A candidate takes, per station, the unused pick closest to the predicted arrival within 120 ticks (ties: earlier pick); with= 6 picks it becomes an event and its picks are consumed.
- Location. Fine grid
FXY x FXY x FZcentred on the event's coarse node (250 m spacing, depth0..30000m inFZ-1steps). Per node: residualsr = t_pick - tt, origin timet0 = min{v : sum of weights of r <= v >= ceil(W/2)}(lower weighted median), misfitsum w * min(|r - t0|, 100). Best node = minimum misfit (ties: smallest node index(iz*FXY + iy)*FXY + ix). Confidence region: nodes with misfit <= best + K (count and index bounding box). Magnitude: lower median of per-pick integer log2-amplitude estimates. - Catalogue. Events sorted by origin time (stable), greedily matched to the hidden events (|dt| <= 300 ticks, epicentral distance <= 20 km, smallest |dt|), error sums and a hash.
Input format
One line: NS DUR NEV FXY FZ SEED with 1 <= NS <= 256, 1 <= DUR <= 400000,
0 <= NEV <= 700, 1 <= FXY <= 61, 2 <= FZ <= 31, SEED a 64-bit unsigned integer.
Output format
Summary lines (records, picks, association, truth, errors, catalogue) and one ev
line for each of the first 40 catalogue events, exactly as printed by the CPU program.
Hidden inputs
Correctness inputs (12 files): networks of 1..256 stations, DUR from 600 (shorter than the
LTA window, so no picks) to 60,000, NEV 0..50, search grids from 1 x 1 x 2 to 21 x 21 x 11.
The timing input has NS in [152, 168], DUR = 360000, NEV in [580, 620], FXY = 61,
FZ = 31. Output is 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 has about 160 stations, 360,000 samples per station (one hour at 100 Hz), about 600 hidden events and a 61 x 61 x 31 location grid per associated event. 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.