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/amd-exec/gemv2.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 / amd-exec / gemv2.py` 147 lines · 6901 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 """Test-only exact Fraction oracle. No kernel or executor code derives expectations. 4 Recorded arithmetic: chunk=256, lane owns 4 consecutive columns; ascending k per lane; 5 simultaneous XOR stages 32,16,8,4,2,1, each with IEEE nearest-even binary32 addition. 6 Large fixtures retain actual M/K and sample first/middle/last rows through row-probe. 7 """ 8 import pathlib 9 import runpy 10 import struct 11 import subprocess 12 import sys 13 14 HERE = pathlib.Path(__file__).parent 15 SG = runpy.run_path(str(HERE/'sgemm.py')) 16 FP = runpy.run_path(str(HERE/'fp8gemv.py')) 17 BF = runpy.run_path(str(HERE/'bf16gemv.py')) 18 SHAPES = tuple(sorted(set(FP['SHAPES']) | set(BF['SHAPES']) | 19 {(m, k) for m in (1, 2, 65) for k in (255, 256, 257, 1023, 1024, 1025, 2049)})) 20 LARGE = ((17408, 5120), (5120, 17408), (5120, 5120)) 21 TREE = (32, 16, 8, 4, 2, 1) 22 23 24 def result(weights, xs, decoder, scale=None): 25 partial = [0]*64 26 for lane in range(64): 27 for chunk in range(0, len(xs), 256): 28 for j in range(4): 29 k = chunk+4*lane+j 30 if k < len(xs): 31 partial[lane] = SG['fma'](decoder(weights[k]), xs[k], partial[lane]) 32 for distance in TREE: 33 before = partial 34 partial = [SG['fma'](before[lane], 0x3f800000, before[lane ^ distance]) for lane in range(64)] 35 answer = partial[0] 36 if scale is not None: 37 answer = SG['fma'](scale, answer, (scale ^ answer) & 0x80000000) 38 return answer 39 40 41 def fixture(kind, m, k, special=False, rows=None, witness=False): 42 fp = kind == 'fp8gemv2' 43 size = 1 if fp else 2 44 wp = 64 if fp else 66 45 xp = (wp + m*k*size+19) & ~3 46 sp = xp+4*k+16 47 yp = sp+4*m+16 if fp else sp 48 data = bytearray([0xa5])*(yp+4*m+64) 49 if fp: 50 struct.pack_into('