interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / om / blackwell / shape.om

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