Multichannel CIC decimation with compensation FIR and peak detection
/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
A multichannel recording is synthesised from the seed and every channel c goes through:
- Signal
x[n],0 <= n < L: hashed noise in[-512, 511], plus a per-channel triangle tone (>> 3of a wave in[-16384, 16384]), plus bursts of +6000 on hashed 512-sample blocks (seesample()). - CIC decimator:
Nintegrator stages in 64-bit wrap-around arithmetic; after everyR-th input sample (n % R == R-1) the last integrator value goes throughNcomb stagesy - y_delayedwith differential delayM(zero initial state). The decimated signal isv[m] = (int64)comb >> (N * ceil(log2(R*M)))(arithmetic shift),m < Ld = floor(L / R). - Compensation FIR:
e[m] = (sum_{j<17} TAPS[j] * v[m-j]) >> 7withv[<0] = 0and the 17 integer taps in the source. - Peaks:
mis a peak whenP <= m < Ld - P,e[m] > e[m-j]ande[m] >= e[m+j]forj = 1..P, ande[m] - min(e[m-P..m+P]) >= THR.
Input format
One line: C L N R M P THR SEED with 1 <= C <= 16384, 0 <= L <= 2^31 - 1,
1 <= N <= 6, 1 <= R <= 32, 1 <= M <= 4, 1 <= P <= 8, 0 <= THR <= 10^6,
SEED unsigned 64-bit.
Output format
channels C decimated Ld shift SHIFT
peaks NPEAKS sum SUM energy ENERGY hash HASH chash CHASH
max VALUE at CHANNEL INDEX (or "max none" when Ld == 0)
top c:count c:count ... (up to 8 channels, most peaks first, ties by smaller c)
SUM is the signed sum of all e, ENERGY the sum of e^2 mod 2^64, HASH the sum over
peaks of mix64(((c << 40) | m) ^ ((uint32)e[m] << 20)), and CHASH the sum over channels of
mix64((c << 32) ^ peaks_c ^ (energy_c * 0x9E3779B97F4A7C15)), all mod 2^64. max reports the
largest e and its first position (smallest channel, then smallest m).
Hidden inputs
Correctness inputs include L = 0, L < R (no decimated samples), R = 1, N = 1 and
N = 6, M = 4, P = 1 and P = 8, THR = 0, a single channel, 16384 channels, and random
parameters within the ranges above. The timing input has 7000 to 8192 channels of 5,000,000
samples each, N in [3, 5], R in {8, 16, 32}, M in {1, 2}, P in [2, 6] and
THR in [50, 1500].
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: The timing input has 7000 to 8192 channels of 5,000,000 samples each (about 38 gigasamples), N in [3, 5], R in {8, 16, 32}, M in {1, 2}. 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.