Source/Packages

Realization.Nvidia.SM86.StreamingAttentionSM86

packages/realizations/cooperative/nvidia-sm86/src/Realization/Nvidia/SM86/StreamingAttentionSM86.alpha

3,230 lines493 declarations193.3 KiBSHA-256 cc0366b3d857

def · lines 274–283

saMaskTile

Full file
the diagonal tile's mask: element (row r + 8h, column 8 nt + 2 (lane % 4) + b) is masked when its column exceeds its row: when 8 nt + b - 8 h exceeds 16 warp + lane / 4 - 2 (lane % 4). saMask holds that plus 64, plus 4096 for every tile after this one, so no element of an earlier tile is masked
274def saMaskTile = (lambda unrestricted tail : (family SM86Program) .
275  (saFor 32 (lambda unrestricted i : Nat .
276    (let unrestricted nt = (naturalDivideUnchecked i 4) in (let unrestricted h = (naturalDivideUnchecked (naturalModuloUnchecked i 4) 2) in
277      (let unrestricted b = (naturalModuloUnchecked i 2) in
278      (let unrestricted threshold = (naturalSaturatingSubtract (naturalAdd (naturalAdd (naturalMultiply 8 nt) b) 63) (naturalMultiply 8 h)) in
279      (lambda unrestricted rest : (family SM86Program) .
280        (saGreater saP0 saMask threshold
281          (saUnless saP0 (constructor SM86InstructionBody SM86MoveImmediate (saR (saElem (saS nt) h b)) (saU saMinusInfinity) saPlain)
282            rest))))))))
283    tail))

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.