Window-based draft polishing with partial-order alignment graphs
/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
Window-based polishing of a draft assembly with partial-order alignment (POA), end to end, in
integer arithmetic (the CPU source is the specification; hh(a,b) = mix64(seed + mix64(a*0x9E3779B97F4A7C15 + b)),
mix64 = SplitMix64 finaliser).
For each of NW independent windows of W bases:
- Data. A truth window (homopolymer-rich: each base repeats the previous one with
probability 3/10), a draft backbone (truth with ~1.6% errors, more indels in homopolymers)
and
Kread fragments (aboutDEPTHper window, 3% of windows have 0-2): noisy copies of the whole truth window or of a truncated part of it (~7% errors, indel-dominated, much worse in homopolymers). Draft and fragments are capped atNCAP = W + W/4bases. - POA graph. The graph starts as the draft chain. Fragments are added longest first (ties by index). Each fragment is aligned to the current graph by a semi-global graph DP (the fragment is aligned end to end, the graph path may start and end at any node): match +3, mismatch -4, gap -5, or -3 when the gap extends a homopolymer (an inserted fragment base equal to the previous fragment base; a skipped node with the same base as the predecessor it is reached from). Rows are graph nodes in Kahn topological order (FIFO, seeded in node-id order, out-edge lists newest first); predecessors are the node's in-edges (newest first) plus the virtual start. The traceback prefers diagonal moves, then vertical, then horizontal, each over the predecessors in list order and the start last; the best end is the first node in topological order with the maximal last-column score.
- Fusion. Matched bases reuse their node, mismatched and inserted bases create new nodes;
consecutive fragment bases get an edge (weight +1 if it exists). A fragment whose fusion would
make the graph exceed
VMAX = 2*Wnodes is dropped (its score still counts). - Consensus. Heaviest path: every node takes its in-edge with the largest weight (ties: the larger predecessor score, then list order); the path ends at the first node of maximal score.
- Quality. Levenshtein distance of the draft and of the consensus to the truth window.
Input format
One line: NW W DEPTH seed.
Output format
windows=NW W=W fragments=<total K> fragment_bases=<total fragment length> dropped=<dropped fragments>
graph_nodes=<sum of final node counts> graph_edges=<sum of final edge counts> align_score_sum=<sum of best alignment scores>
truth_len=<NW*W> consensus_len=<sum> draft_errors=<sum of draft edit distances> polished_errors=<sum of consensus edit distances>
improved=<windows polished < draft> worse=<windows polished > draft> perfect=<windows with polished distance 0>
err_hist <windows with polished distance 0, 1, 2, 3-4, 5-8, 9-16, >16>
consensus_hash=<16 hex, wrapping sum over windows of mix64(w*0x9E3779B97F4A7C15 ^ window consensus hash)>
win <w> frags=.. nodes=.. edges=.. dropped=.. draft_err=.. polished_err=.. cons_len=.. score=.. hash=<16 hex> (windows 0..5)
Hidden inputs
1 <= NW <= 20000, 16 <= W <= 1000, 0 <= DEPTH <= 40, any 64-bit seed.
Correctness inputs (12 files) include a 16-base window with no fragments, 16-base windows at
depth 40 (many dropped fragments), a single 1000-base window, 40 tiny windows at low depth and
random small cases. The timing input has about 10000 windows of 500 bases (a 5 Mb draft) at
DEPTH = 30.
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 about 10000 windows of 500 bases (a 5 Mb draft) with about 30 fragments of up to 625 bases per window; graphs grow to about 1000 nodes. 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.