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
CUDApp / om / prefill-shape / workspace-check.py
| 1 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | # Independent capacity oracle, not production. |
| 3 | import ctypes,sys,random |
| 4 | lib=ctypes.CDLL(sys.argv[1]);f=lib.omega_native_qgworkspace |
| 5 | f.argtypes=[ctypes.POINTER(ctypes.c_uint64)]+[ctypes.c_uint64]*5;f.restype=ctypes.c_uint32 |
| 6 | cases=[] |
| 7 | for rows in [0,1,3,30,63,64,65,128,129,512,4096,2**32-1,2**32,2**64-1]: |
| 8 | for bm in [0,32,64,128,2**32-1,2**32,2**64-1]: |
| 9 | for delta in [-1,0,1]: |
| 10 | cap=max(0,rows+delta);pad=min(2**64-1,rows+bm+delta);tiles=(rows+bm-1)//bm+1 if bm else 0 |
| 11 | if cap<2**64 and pad>=0:cases += [(cap,pad,tiles,rows,bm),(cap,pad,max(0,tiles-1),rows,bm)] |
| 12 | cases += [(4096,4224,33,30,64),(4096,4224,33,4096,128),(4096,4224,33,4096,64)] |
| 13 | rng=random.Random(710) |
| 14 | for _ in range(1000):cases.append(tuple(rng.randrange(8193) for _ in range(5))) |
| 15 | for args in cases: |
| 16 | capacity,padded,tiles,rows,bm=args |
| 17 | want=int(0<rows<2**32 and 0<bm<2**32 and rows<=capacity and rows+bm<=padded and (rows+bm-1)//bm+1<=tiles) |
| 18 | out=ctypes.c_uint64(9);assert f(ctypes.byref(out),*args)==0;assert out.value==want,(args,out.value,want) |
| 19 | assert f(None,4096,4224,33,30,64)==32 |
| 20 | print('PASS independent workspace capacity oracle',len(cases),'cases') |