Incoherent dedispersion over 1000 DM trials with channel flagging and boxcar search
/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 radio-astronomy single-pulse search on a synthetic filterbank.
- Filterbank.
NCHANfrequency channels, channelcatF_c = FTOP - c*CHBWkHz. Each channel holdsNIN = NOUT + MAXDELAYuint8 samples built from the seed: a per-channel bandpass level, 4-byte hash noise, square-wave RFI in about 3% of the channels,NPULSEdispersed pulses with triangular profiles, and a few broadband bursts. All additions saturate at 255 (see the generation loop in the source; every sample is a counter-based hash, so any element can be produced independently). - Delays.
R_c = floor(2^20 (FTOP^2 - F_c^2) / F_c^2)anddelay(c, d) = floor(d * KDM * R_c / 2^20)samples for DM triald = 0 .. NDM-1;MAXDELAY = delay(NCHAN-1, NDM-1). - Channel flagging.
mean_c= integer mean of the firstmin(NIN, 8192)samples of the channel;med= the sorted means at indexNCHAN/2; channelcis flagged (ignored below) whenmean_c > med + 12. - Dedispersion. For every DM trial
dand output samplet < NOUT:s[d][t] = sum over unflagged c of x[c][t + delay(c, d)](int32). - Per-DM statistics. Sum, maximum and first argmax of
s[d], and a hash of all its values. Boxcar search:m = floor(sum / NOUT); for widthswin{1,2,4,8,16,32}(onlyw <= NOUT) andt + w <= NOUT:B = sum_{k<w} s[d][t+k] - w*m,score = trunc(32*B / SQ_w)withSQ = {32,45,64,90,128,181}. The best of a DM is the highest score, ties to the smaller width, then the smallert.
Input format
One line: NCHAN NOUT NDM FTOP CHBW KDM NPULSE SEED (integers, SEED unsigned 64-bit).
Output format
dedisp nchan NCHAN flagged NFLAGGED nin NIN maxdelay MAXDELAY
series sum S hash H
dmstats hash HD
dm d max M argmax A best SCORE w W t T (d = 0, step, 2*step, ... with step = max(1, NDM/16), plus NDM-1)
cand k dm d score SCORE w W t T (k = 0 .. min(16, NDM)-1)
S is the sum of all s[d][t]; H = sum mod 2^64 of
mix64((d*NOUT + t) * 0x9E3779B97F4A7C15 + s[d][t]); HD combines every DM's maximum, argmax
and best boxcar as in the source. cand lines list the DMs ordered by best score (descending),
ties to the smaller DM.
Hidden inputs
1 <= NCHAN <= 4096,1 <= NOUT <= 2^20,1 <= NDM <= 2048,300000 <= FTOP <= 2000000,CHBW >= 1withF_bottom = FTOP - (NCHAN-1)*CHBW > FTOP/2,0 <= KDM <= 1024,0 <= NPULSE <= 64,MAXDELAY <= 80000,NCHAN * NIN <= 1.3e9bytes andNDM * NOUT <= 6e8.- Correctness inputs include a single channel / sample / DM,
NOUTbelow 32 (some boxcar widths absent),KDM = 0(no dispersion), 4096 channels, 2048 DM trials,NOUT = 2^20, no pulses and 64 pulses, and random mid-size cases. - The timing input has 1792-2048 channels, 896-1024 DM trials, about 5e5 output samples and a maximum delay of 40000-70000 samples (about 1e12 channel additions).
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 writing the source only: it has g++ and the CPU program, but no CUDA
compiler and no GPU. Compilation, execution and verification happen later on an H100 in a
separate verifier, and a port that does not compile is rejected, so check your logic against
the CPU program before you finish (for example by emulating your kernels on the host).
How your port is verified
- 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. - Verification runs on one H100 in a fresh container without network. Hidden inputs are generated with a fresh random seed at verification time.
- Correctness: every hidden input (small edge cases plus a large timing input) must pass. Your output must be identical to the CPU program's output (trailing whitespace ignored). Any mismatch, crash or timeout is rejected.
- GPU execution is checked: a port that computes its answer on the CPU is rejected even when its output is correct.
- Speed: The timing input has 1792-2048 channels, 896-1024 DM trials, about 5e5 output samples and maximum delays of 40000-70000 samples (about 1e12 channel additions over a ~1.2 GB filterbank).
/app/inputs/timing_example.inhas the shape and size of the hidden timing input. Your port is timed against a reference GPU port on it; the faster your port, the higher its score. /app/inputs/holds public input examples for understanding the input format.