Port an OpenMP partial-collision census (top-t-bit bucket occupancy over a key range, collision statistics, then a second pass for the minimum key in the fullest bucket) to CUDA
harbor run -t elfsong/cpu2gpu-bits-arx-collideharbor download elfsong/cpu2gpu-bits-arx-collide/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.
For each query, every key k in [lo, lo+N) is hashed with a keyed ARX hash G
(two 64-bit lanes, R rounds of add / rotate / xor; keys k0 = mix64(seed),
k1 = mix64(seed+1); exact round function in the CPU source). The top t bits of
G(k) select one of 2^t buckets. From the bucket occupancy c_b the program reports
partial-collision statistics, then runs a second pass over the keys to find the
smallest key that falls in the fullest bucket.
Q
lo N t R seed
... (Q lines)
All values are unsigned decimal integers.
One line per query, in input order:
qi PAIRS EMPTY TRIPLE PROFILE CMAX BMAX KMIN
PAIRS: sum over buckets of c_b*(c_b-1)/2 (number of colliding key pairs).EMPTY: number of buckets with c_b = 0; TRIPLE: number of buckets with c_b >= 3.PROFILE: sum over non-empty buckets of mix64((b << 20) ^ c_b) modulo 2^64
(mix64 = SplitMix64 finaliser in the CPU source).CMAX: the largest c_b; BMAX: the smallest bucket index with c_b = CMAX;
KMIN: the smallest key in bucket BMAX.N = 0 the line is qi 0 EMPTY 0 0 0 - -.0 <= lo < 2^63, 0 <= N <= 3.0e8, 16 <= t <= 28, 1 <= R <= 12, seed any 64-bit value.N = 0, N = 1, R = 1, t = 16 with dense buckets, t = 28
with a sparse table, and ranges ending at 2^63.N in [2.2e8, 3.0e8], t in [22, 28], R in [6, 12].
Up to 2^28 32-bit counters (1 GiB) are needed.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.