Source/Packages

Accelerator.SM90.UniformOperands

packages/hardware/architectures/nvidia-sm90/src/Accelerator/SM90/UniformOperands.alpha

108 lines26 declarations4.3 KiBSHA-256 99a68680880c

Complete file · line 49

UniformOperands.alpha

Definition view
1module Accelerator.SM90.UniformOperands
2
3import Accelerator.SM90.Word
4import Std.Natural
5
6-- The uniform datapath's operands as Hopper's asynchronous instructions name
7-- them: uniform registers (one value per warp; UR0..UR62, 63 reads as URZ)
8-- and uniform predicates (UP0..UP6, 7 reads as UPT).  Warpgroup MMA reads
9-- its shared-memory matrix descriptors from a uniform register pair, the
10-- tensor-memory copies their shared address, tensor map and coordinates from
11-- a uniform register block, and the transaction barriers their barrier
12-- address from one; the accumulate-or-overwrite choice of a warpgroup MMA is
13-- a uniform predicate.  Sources: every UR/UP operand in the probes of
14-- reference/oracles/nvidia-sm90-ptxas/hopper/ (ptxas 12.9 -arch=sm_90a).
15family SM90UniformRegister : Type 0
16constructor SM90UniformRegisterValue
17-- 0..62 a register, 63 URZ (reads zero); the encoders refuse 64 and above
18field unrestricted sm90UniformRegisterNumber : Nat
19
20end-family
21
22family SM90UniformPredicate : Type 0
23constructor SM90UniformPredicate0
24constructor SM90UniformPredicate1
25constructor SM90UniformPredicate2
26constructor SM90UniformPredicate3
27constructor SM90UniformPredicate4
28constructor SM90UniformPredicate5
29constructor SM90UniformPredicate6
30-- UPT: always true
31constructor SM90UniformPredicateTrue
32
33end-family
34
35-- A uniform predicate read as a condition: the predicate or its negation
36-- (UPT is "always", !UPT "never").
37family SM90UniformCondition : Type 0
38constructor SM90UniformWhen
39field unrestricted sm90UniformWhenPredicate : SM90UniformPredicate
40constructor SM90UniformWhenNot
41field unrestricted sm90UniformWhenNotPredicate : SM90UniformPredicate
42
43end-family
44
45def sm90UniformRegister =
46  (lambda unrestricted number : Nat .
47    constructor SM90UniformRegister SM90UniformRegisterValue number)
48
49def sm90UniformZero : Nat =
50  63
51
52def sm90UniformRegisterNumberOf =
53  (lambda unrestricted register : SM90UniformRegister .
54    eliminate
55      SM90UniformRegister
56      (lambda unrestricted current : SM90UniformRegister . Nat)
57      register
58      (branch SM90UniformRegisterValue number . number))
59
60def sm90UniformPredicateNumber =
61  (lambda unrestricted predicate : SM90UniformPredicate .
62    eliminate
63      SM90UniformPredicate
64      (lambda unrestricted current : SM90UniformPredicate . Nat)
65      predicate
66      (branch SM90UniformPredicate0 . 0)
67      (branch SM90UniformPredicate1 . 1)
68      (branch SM90UniformPredicate2 . 2)
69      (branch SM90UniformPredicate3 . 3)
70      (branch SM90UniformPredicate4 . 4)
71      (branch SM90UniformPredicate5 . 5)
72      (branch SM90UniformPredicate6 . 6)
73      (branch SM90UniformPredicateTrue . 7))
74
75def sm90UniformPredicateOf =
76  (lambda unrestricted number : Nat .
77    then (sm90Choose SM90UniformPredicate (naturalEqual number 0) SM90UniformPredicate0)
78      (sm90Choose SM90UniformPredicate (naturalEqual number 1) SM90UniformPredicate1)
79      (sm90Choose SM90UniformPredicate (naturalEqual number 2) SM90UniformPredicate2)
80      (sm90Choose SM90UniformPredicate (naturalEqual number 3) SM90UniformPredicate3)
81      (sm90Choose SM90UniformPredicate (naturalEqual number 4) SM90UniformPredicate4)
82      (sm90Choose SM90UniformPredicate (naturalEqual number 5) SM90UniformPredicate5)
83      (sm90Choose SM90UniformPredicate (naturalEqual number 6) SM90UniformPredicate6)
84      SM90UniformPredicateTrue)
85
86def sm90UniformAlways =
87  (constructor SM90UniformCondition SM90UniformWhen SM90UniformPredicateTrue)
88
89def sm90UniformNever =
90  (constructor SM90UniformCondition SM90UniformWhenNot SM90UniformPredicateTrue)
91
92-- a uniform guard's four bits: the predicate, and 8 when negated
93def sm90UniformGuardBits =
94  (lambda unrestricted condition : SM90UniformCondition .
95    eliminate
96      SM90UniformCondition
97      (lambda unrestricted current : SM90UniformCondition . Nat)
98      condition
99      (branch SM90UniformWhen predicate . sm90UniformPredicateNumber predicate)
100      (branch SM90UniformWhenNot predicate . nat-add 8 (sm90UniformPredicateNumber predicate)))
101
102def sm90UniformGuardOf =
103  (lambda unrestricted bits : Nat .
104    then (sm90Choose SM90UniformCondition (nat-less-than bits 8) (constructor SM90UniformCondition SM90UniformWhen (sm90UniformPredicateOf bits)))
105      (constructor SM90UniformCondition SM90UniformWhenNot)
106      sm90UniformPredicateOf
107      (nat-subtract bits)
108      8)

The compiler supplied declaration spans and resolved links from this source snapshot. This page does not assert that this file belongs to a checked closure.