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/api_hostrest_check.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 / api_hostrest_check.py` 51 lines · 3276 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Focused differential/red/link/mutant acceptance; temporary mutants never alter sources.""" 4 import os 5 from pathlib import Path 6 import subprocess 7 import tempfile 8 ROOT=Path(__file__).resolve().parents[1] 9 WRAP=['bwrap','--dev-bind','/','/','--dev','/dev','--proc','/proc','--','taskset','-c','10-14','nice','-n','10'] 10 ENV=dict(os.environ,OMEGA_SEEDED_OMC=os.environ.get('OMEGA_OMC',str(Path.home()/'work/cudastack/omega-mv/seed/out/omc'))) 11 BRIDGE=Path(os.environ['OMEGA_BRIDGE'])/'tools/bridge-seeded' 12 RT=BRIDGE 13 def run(cmd,negative=False): 14 p=subprocess.run(cmd,cwd=ROOT,env=ENV,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True) 15 if (p.returncode==0)==negative: raise RuntimeError(f'{cmd}: rc={p.returncode}\n{p.stdout}') 16 return p 17 with tempfile.TemporaryDirectory(prefix='api-hostrest-') as tmp: 18 t=Path(tmp) 19 def build(family,unit,extra=()): 20 exe=t/(family+'test') 21 src=['cc','-std=c11','-ffp-contract=off','-Isrc',*extra] 22 if family=='host':src+=['tests/api_hostrest_test.c',str(unit)] 23 else: 24 run(['cc','-std=c11','-ffp-contract=off','-Isrc','-DCUDAPP_MIGRATION_PENDING_C_SCAN_REFERENCE_REST','-Domega_gpu_prefix_sum_reference=scan_c_prefix','-Domega_gpu_reduce_reference=scan_c_reduce','-Domega_gpu_prefix_sum_u32_reference=scan_c_prefix_u32','-Domega_gpu_radix_sort_reference=scan_c_radix_sort','-c','src/omega_gpu_scan_ref.c','-o',str(t/'oracle.o')]) 25 src+=['tests/scan_rest_test.c','src/omega_gpu_scan_ref.c','src/cudapp_om_av_scan.c',str(t/'oracle.o'),str(unit),'-lm'] 26 run(src+['-o',str(exe)]) 27 return exe 28 for family,file,bridge,changes in [ 29 ('host','hostrest.om',BRIDGE,[('eq c 48','eq c 49'),('eq c 50','eq c 51'),('rem k 512','rem k 511'),('decl 65536','decl 65535'),('div uint 48 groups','div uint 47 groups'),('ge n 1000','ge n 999')]), 30 ('scan','scancarry.om',RT,[('ulong 32','ulong 33'),('lt e n','lt e sub n 1'),('div e 32 1','div e 32 0'),('add get src','sub get src'),('add e 1','add e 2'),('lt len src','le len src')])]: 31 source=(ROOT/'om/apiviews'/file).read_text() 32 original=ROOT/'src'/('cudapp_om_ah_rest.c' if family=='host' else 'cudapp_om_ar_carry.c') 33 exe=build(family,original) 34 p=run(WRAP+[str(exe)]);print(p.stdout.strip(),flush=True) 35 if family=='host': 36 exe=build(family,original,['-DCUDAPP_API_HOSTREST_RED']) 37 p=run(WRAP+[str(exe)],True);print(f'host red killed rc={p.returncode}',flush=True) 38 # Strong symbol must fail to link without its generated unit. 39 missing=t/'missing.c';missing.write_text('/* deliberately no Omega entry */\n') 40 try:build(family,missing) 41 except RuntimeError:print(f'{family} strong-link negative PASS',flush=True) 42 else:raise RuntimeError('missing Omega entry linked') 43 for i,(old,new) in enumerate(changes): 44 assert source.count(old)==1,(old,source.count(old)) 45 mutant=t/(family+str(i)+'.om');mutant.write_text(source.replace(old,new)) 46 cmd=[str(bridge)]+(['--runtime-views'] if family=='scan' else [])+['c',str(mutant)] 47 p=run(cmd);unit=t/(family+str(i)+'.c');unit.write_text(p.stdout) 48 exe=build(family,unit) 49 p=run(WRAP+[str(exe)],True) 50 print(f'{family} mutant {i+1} killed rc={p.returncode}: {old} -> {new}',flush=True) 51 print('API_HOSTREST_SCAN acceptance PASS',flush=True)