Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/om_fixture_verify_test.py # CUDApp CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / om_fixture_verify_test.py` 77 lines · 4874 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Host only. Invoke under the mandatory device-hidden bwrap; never opens a GPU.""" 4 from pathlib import Path 5 import os 6 import shutil 7 import subprocess 8 9 root = Path(__file__).resolve().parents[1] 10 os.chdir(root) 11 out = root / 'build/fixture-verify' 12 out.mkdir(parents=True, exist_ok=True) 13 bridge = Path(os.environ.get('OMEGA_BRIDGE', str(Path.home()/'work/cudastack/omega-bridge'))) 14 # OMEGA_SEED defaults to the bridge's own bootstrap compiler (tools/bootstrap.sh output), which is what the 15 # hosted job builds next to OMEGA_BRIDGE; it no longer falls back to a lane checkout under the home directory. 16 env = dict(os.environ, OMEGA_SEEDED_OMC=os.environ.get('OMEGA_OMC', str(Path.home()/'work/cudastack/omega-mv/seed/out/omc')), OMEGA_SEED=os.environ.get('OMEGA_SEED', str(bridge/'build/bootstrap/omc'))) 17 cc = ['gcc','-std=gnu11','-O2','-Wall','-Wextra','-Werror','-ffp-contract=off','-Isrc'] 18 unit = 'src/cudapp_freest_fixture_verify.c' 19 source = 'tests/om_fixture_verify_test.c' 20 rows = [] 21 def run(name, args, expect=0): 22 p = subprocess.run([str(x) for x in args], env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 23 (out/(name+'.log')).write_bytes(p.stdout) 24 rows.append(f'{name}\t{p.returncode}\t'+ ' '.join(map(str,args))) 25 (out/'commands.tsv').write_text('\n'.join(rows)+'\n') 26 print(name, 'rc', p.returncode, flush=True) 27 if expect is not None and p.returncode != expect: raise SystemExit(p.stdout.decode(errors='replace')) 28 return p 29 missing = run('missing-link', cc+[source,'-o',out/'missing'], None) 30 assert missing.returncode and b'undefined reference' in missing.stdout 31 print('PASS strong entry missing-link negative',flush=True) 32 run('build-omega',cc+[source,unit,'-o',out/'omega']) 33 run('build-oracle',cc+[source,'-DCUDAPP_MIGRATION_PENDING_C_ENGINE_FIXTURE_REST=1','-o',out/'oracle']) 34 base = run('omega',[out/'omega']).stdout 35 assert base == run('oracle',[out/'oracle']).stdout 36 print('PASS scalar and wrapper source-partition differential',flush=True) 37 text=(root/'om/codegen/fixture_verify.om').read_text() 38 mutants = [ 39 ('word_equal','if ne and a `4294967295` and c `4294967295`','if eq and a `4294967295` and c `4294967295`'), 40 ('error_index','add mul a 2 b','add mul a 3 b'), 41 ('status_equal','ret fv_bool eq a 0','ret fv_bool ne a 0'), 42 ('bf16_bit','`4294967295` 262144','`4294967295` 262145'), 43 ('bfly_bit','or c `288230376151711744`','or c `288230376151711745`'), 44 ('shift_count','x = shl x 16','x = shl x 15'), 45 ('optional_mask','mask = 15','mask = 7')] 46 for name, old, new in mutants: 47 assert text.count(old)==1,(name,text.count(old)) 48 path=out/(name+'.om'); path.write_text(text.replace(old,new)) 49 p=run('generate-'+name,['sh',bridge/'tools/bridge-freest','c',path]) 50 gen=out/(name+'.c'); gen.write_bytes(p.stdout) 51 run('build-'+name,cc+[source,gen,'-o',out/name]) 52 observed=run('run-'+name,[out/name],None) 53 assert observed.returncode or observed.stdout != base, name+' SURVIVED' 54 print('KILLED',name,flush=True) 55 # Every original fixture entrypoint, with only the predicate implementation switched. 56 bindings=sorted(root.glob('src/cudapp_om_*.c'))+sorted(root.glob('src/cudapp_freest_*.c')) 57 common=['tests/om_fixture_verify_calls.c','src/omega_blackwell_codegen.c','src/omega_blackwell_matmul.c','src/omega_gpu_om_ir.c','src/sha256.c']+bindings 58 run('build-calls',cc+common+['-o',out/'calls']) 59 run('build-calls-oracle',cc+['-DCUDAPP_MIGRATION_PENDING_C_ENGINE_FIXTURE_REST=1']+common+['-o',out/'calls-oracle']) 60 assert run('calls',[out/'calls']).stdout == run('calls-oracle',[out/'calls-oracle']).stdout 61 # Corrupt golden data in a private test copy: the actual exported verifier must reject it. 62 cg=(root/'src/omega_blackwell_codegen.c').read_text() 63 assert cg.count('0x00027308U')==1 64 red=out/'red-codegen.c'; red.write_text(cg.replace('0x00027308U','0x00027309U')) 65 red_common=[red if x=='src/omega_blackwell_codegen.c' else x for x in common] 66 run('build-red-calls',cc+red_common+['-o',out/'red-calls']) 67 p=run('red-calls',[out/'red-calls'],None) 68 assert p.returncode==1 and b'FAIL codegen fixture invocation' in p.stdout 69 # Oracle coverage records source-derived branch partition reachability, not hardware qualification. 70 run('build-coverage',['gcc','-std=gnu11','-O0','--coverage','-Isrc','-DCUDAPP_MIGRATION_PENDING_C_ENGINE_FIXTURE_REST=1',source,'-o',out/'coverage']) 71 run('coverage',[out/'coverage']) 72 run('gcov',['gcov','-b','-c','-o',out,out/'coverage-om_fixture_verify_test.gcno']) 73 # gcov finds the sources from the checkout and writes its .gcov files there: keep their text in the build 74 # directory and the checkout clean (the pattern of tests/mathlibs_host_om.py) 75 for path in root.glob('*.gcov'): 76 shutil.move(str(path), out/path.name) 77 print('PASS seven exported fixtures; red golden-data control; mutants 7/7 KILLED; HW NOT_RUN',flush=True)