Irregular-cadence transit search with box scores
/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 observing survey has an irregular sequence of integer timestamps and noisy brightness measurements. The program generates the survey deterministically, removes a local nine-observation trend, folds the residuals at many trial periods, and searches for short box-shaped dimming windows. It reports the strongest three (period, phase-bin, width, score) candidates and a checksum of every scanned box score.
For observation i, the timestamp is 3i + 7 floor(i/31) + jitter_i with a counter-hash jitter in {0,1,2}. Flux contains a periodic six-time-unit dip at a seed-derived period, a slow baseline and counter-hash noise. The local trend at i is the integer mean of observations max(0,i-4)..min(N-1,i+4); residual flux is observed flux minus that mean. No floating-point operations decide results.
Trial periods are integers 40..39+P. For a trial period period, phase bin of observation i is floor((timestamp_i mod period)*B/period). Each bin stores sum of residual flux and observation count. For every cyclic starting phase and width 1..4, sum the corresponding bins and calculate score=max(0, (-sum)*(B-width)-count). Ties rank by smaller period, then smaller phase, then smaller width. A 64-bit mixed checksum covers all scores, preventing a solution from only guessing the seed-derived period.
The main migration challenge is reusing a large, irregularly sampled time series across many period-specific phase histograms with contested bins. Existing radio dedispersion tasks accumulate along frequency-dependent delay paths; this task folds time modulo changing periods and scans cyclic box windows.
Input format
One line: N P B SEED. 1 <= N <= 9000000, 1 <= P <= 3072, 8 <= B <= 128, SEED is an unsigned 64-bit decimal integer.
Output format
One line: hash=HHHHHHHHHHHHHHHH top=period:phase:width:score,period:phase:width:score,period:phase:width:score. The hash uses 16 lowercase hexadecimal digits. If fewer than three periods exist, output that many candidates. Exact byte comparison is used.
Hidden inputs
Correctness tests include one and two observations, non-power-of-two lengths, small bin counts, and different seeds. At timing scale 1.0 there are nine million observations, 3072 trial periods, and 64 bins. Smaller timing scales change only the number of periods. The CPU output must be independent of OpenMP thread count.
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. - Grading runs on one H100 in a fresh container without network. 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: At scale 1.0, 3072 trial periods are scanned over nine million irregular observations with 64 phase bins and four box widths, requiring about 27.6 billion phase assignments. 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.