#!/usr/bin/env python3 import subprocess,json,random,statistics,hashlib,datetime from pathlib import Path HERE=Path(__file__).resolve().parent OLD=HERE.parent/'full_search_feasibility' OUT=HERE/'pipeline_results' POS=HERE/'pipeline_positions' OUT.mkdir(exist_ok=True);POS.mkdir(exist_ok=True) def lifts(x,z): return [(xx,zz) for xx in range(-1875000+(x+1875000)%65536,1875000,65536) for zz in range(-1875000+(z+1875000)%131072,1875000,131072)] def save(name,coords): p=POS/(name+'.txt');p.write_text(''.join(f'{x} {z}\n' for x,z in coords));return p known=save('known_lifts',lifts(51069,419124)) rng=random.Random(2026101105) coords=[] classes=set() while len(classes)<512: c=(rng.randrange(65536),rng.randrange(131072)) if c in classes:continue classes.add(c) coords.extend(rng.sample(lifts(*c),64)) mixed=save('mixed512',coords) cases={'known_lifts':known,'nonempty32':OLD/'positions/lifts.txt','mixed512':mixed,'random4096':OLD/'positions/random4096.txt'} subprocess.run(['nvcc','-O3','-std=c++17','-arch=sm_86',str(HERE/'pipeline_bench.cu'),'-o','/tmp/slime_pipeline_cuda'],check=True) summary={'metadata':{'date':datetime.datetime.now().astimezone().isoformat(),'gpu':subprocess.check_output(['nvidia-smi','--query-gpu=name,driver_version','--format=csv'],text=True)}} for name,path in cases.items(): cmd=['/tmp/slime_pipeline_cuda',str(path),'3'] p=subprocess.run(cmd,capture_output=True,text=True,timeout=300) (OUT/(name+'.jsonl')).write_text(p.stdout);(OUT/(name+'.stderr')).write_text(p.stderr) if p.returncode:raise RuntimeError(p.stderr) rows=[json.loads(l) for l in p.stdout.splitlines()] d={} for m in range(4): a=[r for r in rows if r['type']=='pipeline' and r['mode']==m] d[str(m)]={k:statistics.median(r[k] for r in a) for k in ['host_ms','build_ms','root_ms','expand_ms','search_ms','jobs','classes','positions','active_positions','matches']} d['validation']=next(r for r in rows if r['type']=='validation') d['setup_ms']=next(r['host_ms'] for r in rows if r['type']=='setup') summary[name]=d (OUT/'summary.json').write_text(json.dumps(summary,indent=2)) print(name,json.dumps({k:v for k,v in d.items() if k!='validation'}),flush=True) summary['source_sha256']={n:hashlib.sha256((HERE/n).read_bytes()).hexdigest() for n in ['pipeline_bench.cu','cuda_bench.cu','grouped.hpp','run_pipeline.py']} summary['shared_headers_sha256']={name:hashlib.sha256((HERE.parents[2]/'include'/'slime'/name).read_bytes()).hexdigest() for name in ['solver_core.hpp','upper_interval.hpp']} (OUT/'summary.json').write_text(json.dumps(summary,indent=2))