7-DOF arm probabilistic roadmap with fixed-point kinematics and bisection edge checks
/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
A complete probabilistic-roadmap (PRM) planning job for a 7-DOF arm standing in a cluttered
G x G x G voxel cell, in exact integer arithmetic. The CPU source is the specification; in
short:
- Workspace. The floor (
z = 0, 1) is solid.NBOXhashed boxes and long bars are added, except those that would touch the keep-out column around the arm base (|x - G/2| <= 10,|y - G/2| <= 10,z < 30). A capped Chebyshev clearance field (clr= distance in voxels to the nearest occupied voxel, at most 15) is computed with three separable passes. - Kinematics. Joint angles are integers, 4096 per turn. A 4096-entry Q14 sine table is built
with an integer Taylor series. Forward kinematics composes rotations about local z / y axes
(
z y z y z y z) in Q14 with rounding(a*c +- b*s + 8192) >> 14; link offsets are added in Q16 voxel units. Each link carries 1, 2 or 4 spheres placed at fractionsj/nof the link (arithmetic shifts). A configuration is free iff every sphere centre voxel is inside the grid and hasclr > radius. - Samples.
NSconfigurations are hashed uniformly inside the joint limits; the free ones become the roadmap nodes (numbered in sample order). - Neighbours. Three Morton orders (4 bits per joint, joint ranges cyclically shifted by
0, 1/3, 2/3) are sorted; each node takes the
Knearest distinct nodes, under the weighted joint metricsum w_i |dq_i|withw = (6,6,4,4,2,2,1), among theWpredecessors and successors in each of the three orders, keeping only distances<= DMAX(ties by node id). The union of these pairs, deduplicated, is the candidate edge set. - Edge validation (the hot loop). A straight joint-space motion
a -> bis sampled atm = ceil(max_i |b_i - a_i| / STEP)steps: interior configurationsa + (b - a)*k/m(C integer division) fork = 1..m-1. The motion is valid iff all of them are free. (The CPU checks them coarse-to-fine, stride halving from the largest power of two belowm, stopping at the first collision; any order gives the same result.) - Queries. A home configuration and
Qgoal configurations are hashed (first free one of up to 64 attempts each; otherwise the query is invalid). Each is connected to those of its 8 nearest roadmap nodes (metric, ties by id) whose straight motion is valid. A multi-source shortest-path search from the home entries over the valid edges (edge cost = metric distance) gives the reachable set; a goal's cost is the minimum over its valid entries ofdist(entry) + metric(entry, goal)(ties by smaller node id).
Input format
One line: G NBOX NS K W DMAX STEP Q SEED (integers, SEED 64-bit unsigned).
Output format
valid_samples N of NS boxes B
candidate_edges EC valid_edges EV interior_configs IV isolated_nodes I
edge_steps_hist h0 .. h7 (valid edges by m: <=1, 2-3, 4-7, 8-15, 16-31, 32-63, 64-127, >=128)
home ok|invalid entries E reach R dist_sum S dist_max X
goal q cost C via node | goal q unreachable | goal q invalid (Q lines)
edge_checksum H (sum of mix64((u<<32)|v) over valid edges u<v, mod 2^64)
IV is the sum of max(0, m-1) over valid edges. The output must match exactly.
Hidden inputs
64 <= G <= 160, 0 <= NBOX <= 400, 0 <= NS <= 2200000, 1 <= K <= 24, 1 <= W <= 64,
0 <= DMAX <= 20000, 2 <= STEP <= 64, 0 <= Q <= 64. Correctness inputs (11) include an
empty cell, NS = 0 and NS = 1, G = 64 (the arm often leaves the grid), maximum K, W,
DMAX with STEP = 2, NBOX = 400 with STEP = 64, K = W = 1 with 64 goals, DMAX = 0, and
random small configurations. The timing input has G = 128, 50-70 boxes, 1.8-2.2 million
samples (roughly 40% free), K = 16, W = 24, DMAX = 7000, STEP = 4 (edges of a few hundred
interior configurations) and 32 goals.
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 be identical to the CPU program's output (trailing whitespace ignored). 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 a 128^3 cell with 50-70 obstacles, 1.8-2.2 million sampled configurations (about 40% free), K = 16 neighbours from 3 Morton windows of +-24, STEP = 4 (several million candidate edges of up to a few hundred interior configurations each) and 32 goals. 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.