Batched mixed-radix STFT spectral features
/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
Short-time spectral features of S synthetic signals.
- Signals. Signal
shasLENsamplesx_s[t]: three linear chirps with amplitude modulation plus hashed uniform noise. Its parameters come frommake_sig(SEED, s), the sample formula issample(...)in the CPU source (mix64is the SplitMix64 finaliser,unit(h) = (h >> 11) / 2^53). Every sample can be computed independently. - Frames.
F = (LEN - NFFT) / HOP + 1frames per signal; framefholds samplesf*HOP .. f*HOP + NFFT - 1, multiplied by the windoww(t) = sin(pi (t+0.5)/NFFT)^WP * (1 + WG cos(4 pi (t+0.5)/NFFT)). - Spectrum. Complex DFT of length
NFFT(NFFT = 2^a 3^b 5^c); powerP_k = |X_k|^2for binsk = 0 .. NFFT/2(nbin = NFFT/2 + 1bins). - Per-frame features (with
E = sum_k P_k,eps = 1e-10 * E / nbin):log E; centroidC = sum k P_k / E; spreadsqrt(sum (k - C)^2 P_k / E); flatnessexp(mean_k log(P_k + eps)) / (E/nbin + eps); flux (framesf >= 1)sum_k (sqrt(P_k) - sqrt(P_k^{prev}))^2 / E; for each ofNBbandslog(sum_k W_bk P_k + eps), whereWare triangular filters on the warped scalem(k) = log(1 + k/K0),K0 = max(1, NFFT/50)(seemake_bands). - Per-signal features (
5 + 2*NBnumbers): the frame means of log energy, centroid, spread, flatness, band log energies; the mean flux over frames1..F-1; and for each band the mean over frames1..F-1of the squared change of its log energy from the previous frame (flux and changes are 0 whenF = 1).
The CPU program uses its own mixed-radix (5, 3, 4, 2) Stockham FFT in double precision. Reduced precision is allowed for the transform: an FP32 FFT passes the tolerance below if the per-frame and per-signal accumulations (and the logs) are done in double precision.
Input format
One line: S LEN NFFT HOP NB WP WG SEED (WG decimal, SEED unsigned 64-bit, the rest integers).
Output format
signals S len LEN nfft NFFT hop HOP frames F bands NB
mean <5 + 2*NB values: mean over all signals of each per-signal feature>
meansq <5 + 2*NB values: mean over all signals of the squared feature>
signal i <5 + 2*NB values> (12 lines, i = s*S/12 for s = 0..11; fewer if S < 12)
Feature order: log energy, centroid, spread, flatness, flux, NB band log energies, NB band
changes. Values are printed with %.10e and compared numerically with rtol = 2e-5,
atol = 2e-5.
Hidden inputs
1 <= S <= 640,NFFT <= LEN <= 2^19,NFFTis a 5-smooth number (2^a 3^b 5^c) up to 2000 (including 1, 2, pure powers of 3, 5 and 2),max(1, NFFT/16) <= HOP <= NFFT,1 <= NB <= 32(some cases have more bands than bins, giving empty bands),1 <= WP <= 4,-0.3 <= WG <= 0.3.- Correctness inputs include a single frame per signal, one-sample frames, no overlap
(
HOP = NFFT) and one signal of2^19samples. - The timing input has
Sin[512, 640],LEN = 2^19,NFFTin{960, 1000, 1080, 1200, 1440, 1500, 1600, 1800, 2000},HOP = NFFT/8andNBin[16, 32].
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.
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.
- For public GPU experiments, use
/app/bin/gpu_run [--backend auto|local|remote] [--repeat N] [--quiet] SOURCE.cu INPUT_FILE.... The default usesGPU_RUNNER_URLwhen configured, otherwise a GPU attached to this sandbox. Sandbox GPU access is configured independently from verification; a CPU-only sandbox needs a runner URL. - Correctness: every hidden input (small edge cases plus the timing input) must pass.
Your output must have the same tokens as the CPU program's output. Numeric tokens may differ by at most
atol + rtol*|expected|with rtol = 2e-05 and atol = 2e-05; every other token must be identical. 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 512 to 640 signals of 2^19 samples, an FFT length in {960, ..., 2000} with hop NFFT/8 (about 2 to 3 million FFTs) and 16 to 32 bands. 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.