Port a batched OpenMP global aligner (generated substitution table, position-dependent gap opens, two-piece affine gaps, 5 DP states) to CUDA and make it fast
harbor run -t elfsong/cpu2gpu-dp-align-twopieceharbor download elfsong/cpu2gpu-dp-align-twopiece/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.
A batch of independent global alignments of integer sequences over a 20-letter alphabet, scored with rules that do not appear in any standard aligner:
i is multiplied by a zone weight w(i) in {1, 2}
(zones of 64 positions of sequence A);i opens with cost oh(i),
a vertical gap in column j with cost ov(j) (zones of 32 positions, values 6..15);L costs min(o + 3L, o + 24 + L), realised by
two independent affine gap states per direction (E1/E2 horizontal, F1/F2 vertical).The score is maximised. All sequences, gap tables and the substitution table are generated
inside the program from the seed (SplitMix64 mix64, see the CPU source). Sequence B of each
pair is a noisy, stretched copy of sequence A.
For every pair the program reports the optimal global score H[LA][LB], a hash of the full
last row H[LA][0..LB] and a hash of the full last column H[0..LA][LB]. The boundary row
and column use closed forms (see align in the CPU source).
Q SEED
LA_1 LB_1
...
LA_Q LB_Q
SEED is an unsigned 64-bit integer, 0 <= LA, LB <= 32000.
One line per pair p (0-based, input order): p LA LB SCORE ROWHASH COLHASH, then
total SUM ALLHASH (sum of scores and a combined hash). Hashes are sums of mix64 values
modulo 2^64, exactly as in the CPU source.
Correctness inputs contain empty sequences (LA = 0 and/or LB = 0), length 1, very
unequal lengths (32000 x small), seeds 0 and 2^64-1, and pairs up to a few thousand long,
with 1 to 12 pairs per input. The timing input has 96 pairs with both lengths uniform in
[16000, 32000].
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.
/app/gpu/main.cu is collected. It is compiled with
nvcc -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.system(, popen(, fork(, exec*, dlopen(, getenv(,
#include <filesystem>, /tests/, /proc/. The program may read only the input file it is given.reward = min(2, t_reference / t_yours) using the medians./app/inputs/ holds a few public inputs. /app/bin/run_public.sh compiles your port with the
flags above and compares it against the CPU baseline on each of them.