Automatic earthquake catalogue: STA/LTA picking, space-time voting association, weighted-median L1 grid-search location
/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
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 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. - This sandbox has no GPU.
nvccworks here for compiling. To run on the GPU, use/app/bin/gpu_run [--repeat N] [--quiet] SOURCE.cu INPUT_FILE...: it compiles the file with the flags above on a remote H100 worker, runs it on each input, and prints stdout, exit code and wall-clock time. Grading also runs your code on an H100 worker, one job per GPU at a time. 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 be identical to the CPU program's output (trailing whitespace ignored). Any mismatch, crash or timeout gives reward 0.
- 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 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.