Conformer clustering with an exact integer superposition-RMSD predicate
/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
Conformer-ensemble clustering, as done after a conformer search or an MD run, with an exact integer RMSD predicate.
- Ensemble generation (see
gen_conformer). A base molecule ofAatoms lies in a ball of radius 5 A (integer coordinates in units of 0.01 A). There areF = 8..16conformational families; a family puts each of the four "arms" (atom index blocksk*4/A) into one of three rotamer states (an integer-quaternion rotation). Conformerigets a family (skewed choice), a per-arm small torsion jitter whose size depends on the family's flexibility, per-atom noise and a random global rotation. All rotations are applied with integer quaternions and floor division. Each conformer is then centred exactly: per axis,floor(sum/A)is subtracted from every atom and 1 more from the firstsum mod Aatoms, so every coordinate sum is 0.G_i= sum of squared coordinates. - All pairs, exact RMSD cutoff tests. For a pair
(i, j)the correlation sumsS_ab = sum_k X_i[k][a] * X_j[k][b]give Horn's symmetric 4x4 key matrixK; the minimal RMSD over proper rotations satisfiesRMSD^2 = (G_i + G_j - 2 lambda_max(K)) / A. HenceRMSD <= c(c in 0.01 A) iff the integer matrixB = (G_i + G_j - A c^2) I - 2Kis not positive definite, decided with Sylvester's criterion (leading minorsd1..d4 > 0;d3,d4in 128-bit integers,d4via the 2x2-minor Laplace expansion). No floating point is involved. Pairs withRMSD <= c2form the neighbour graph, pairs withRMSD <= c1the tight graph. - Taylor-Butina clustering of the
c2graph: conformers in order of decreasing degree (ties: smaller index); an unassigned conformer becomes a centroid and takes all its unassigned neighbours. - Summaries: pair counts, degree histogram, number of clusters and singletons, how many
conformers share their centroid's family, an assignment hash
sum_j mix64((j << 32) ^ centroid(j) ^ 0x5EED)(mod 2^64), and the 12 largest clusters with their tight-member count (members withinc1of the centroid).
Input format
One line: N A c1 c2 SEED with 0 <= N <= 70000, 1 <= A <= 64, 0 <= c1 <= c2 <= 4000,
SEED an unsigned 64-bit integer.
Output format
conformers N atoms A families F cutoffs c1 c2
pairs within_c1 <n1> within_c2 <n2> maxdeg <d>
deghist h0 .. h16 (h0: degree 0, h1: degree 1, h_b: degree in [2^(b-1), 2^b), h16: >= 32768)
clusters <n> singletons <n> samefamily <n> hash <h>
cluster k centroid c family f size s tight t samefam m deg d (k < 12; size desc, centroid asc)
Hidden inputs
Correctness inputs (12 files) include N = 0, N = 1, a single pair, A = 1 (all RMSDs
zero), A = 2, c1 = c2, c1 = 0 with a huge c2, seeds 0 and 2^64-1, and random inputs with
N <= 1500. The timing input has N = 64000 conformers of A = 64 atoms (about 2.05e9
pairs), c1 in [40, 60] and c2 in [110, 140].
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 64000 conformers of 64 atoms (about 2.05e9 pairs, each needing a 64-atom 3x3 correlation and up to two exact 4x4 definiteness tests) with cutoffs c1 in [0.40, 0.60] A and c2 in [1.10, 1.40] A. 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.