interplane.Get Omega
Read in your language

omega-gpu-driver

aien-dev/omega-gpu-driver

Brought by drakestapleton

branch main Branches Tags History

omega-gpu-driver / tests / arena_bytes.lean

28 lines · 967 bytes Raw Blame History
1import Std.Tactic.BVDecide
2
3namespace ArenaBytes
4
5-- The upper byte offsets and word indices used by arword and arshift.
6theorem bounds (o : Nat) (lo : 16777216 ≤ o) (hi : o < 83886080) :
7 (o - 16777216) / 8 < 8388608 ∧
8 16777216 + 8 * ((o - 16777216) / 8) + o % 8 = o := by omega
9
10def shift (lane : BitVec 3) : BitVec 64 := lane.zeroExtend 64 <<< 3
11
12def getByte (w : BitVec 64) (lane : BitVec 3) : BitVec 8 :=
13 (w >>> shift lane).truncate 8
14
15def setByte (w : BitVec 64) (lane : BitVec 3) (v : BitVec 8) : BitVec 64 :=
16 (w &&& ~~~((255 : BitVec 64) <<< shift lane)) ||| (v.zeroExtend 64 <<< shift lane)
17
18theorem readWrite (w : BitVec 64) (lane : BitVec 3) (v : BitVec 8) :
19 getByte (setByte w lane v) lane = v := by
20 unfold getByte setByte shift
21 bv_decide
22
23theorem otherLanes (w : BitVec 64) (a b : BitVec 3) (v : BitVec 8) (h : a ≠ b) :
24 getByte (setByte w a v) b = getByte w b := by
25 unfold getByte setByte shift
26 bv_decide
27
28end ArenaBytes