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/om/blackwell/shape.om # 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 / om / blackwell / shape.om` 66 lines · 1008 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note Three positive runtime lengths determine row-major m,k,n uniquely. 3 note Cancel denominator before multiplying: reduced product is n squared. 4 fn bw_gcd a ulong b ulong to ulong 5 while ne b 0 6 r = rem a b 7 a = b 8 b = r 9 end 10 ret a 11 end 12 fn bw_root x ulong to ulong 13 lo = ulong 1 14 hi = ulong `4294967295` 15 ans = ulong 0 16 while le lo hi 17 mid = add lo shr sub hi lo 1 18 if le mid div x mid 19 ans = mid 20 lo = add mid 1 21 else 22 hi = sub mid 1 23 end 24 end 25 ret ans 26 end 27 fn bw_dim a ulong b ulong c ulong to ulong 28 if or eq a 0 or eq b 0 eq c 0 29 ret 0 30 end 31 d = bw_gcd a b 32 aa = div a d 33 bb = div b d 34 e = bw_gcd aa c 35 aa = div aa e 36 cc = div c e 37 if ne aa 1 38 ret 0 39 end 40 if gt bb div `18446744073709551615` cc 41 ret 0 42 end 43 sq = mul bb cc 44 nn = bw_root sq 45 if or eq nn 0 ne mul nn nn sq 46 ret 0 47 end 48 if ne rem b nn 0 49 ret 0 50 end 51 kk = div b nn 52 if or eq kk 0 gt kk `4294967295` 53 ret 0 54 end 55 if ne rem a kk 0 56 ret 0 57 end 58 mm = div a kk 59 if or eq mm 0 gt mm `4294967295` 60 ret 0 61 end 62 if ne mul mm nn c 63 ret 0 64 end 65 ret nn 66 end