HFMA2

Floating point

fixed bit field field the encoding fixes should be

Encoding

12712612512412312212112011911811711611511411311211111010910810710610510410310210110099989796
reusewaitrd_barwr_baryieldstall
9594939291908988878685848382818079787776757473727170696867666564
holdsholdsh0_nh1[85]negabsedswrelu[78][77]sw
6362616059585756555453525150494847464544434241403938373635343332
sw
313029282726252423222120191817161514131211109876543210
RaRdpred.notpredform000110001

bits 15:0: ---- 0010 0011 0001
bits 15:0: ---- 0100 0011 0001
bits 15:0: ---- 0110 0011 0001
bits 15:0: ---- 1000 0011 0001
bits 15:0: ---- 1010 0011 0001
bits 15:0: ---- 1100 0011 0001
bits 15:0: ---- 1110 0011 0001

Forms

Form (bits 11:9)bc
1 (001)Rb at 32Rc at 64
2 (010)Rb at 64immediate at 32
3 (011)Rb at 64constant buffer: offset at 38, bank at 54
4 (100)immediate at 32Rc at 64
5 (101)constant buffer: offset at 38, bank at 54Rc at 64
6 (110)URb at 32Rc at 64
7 (111)Rb at 64URc at 32

Runs execute_HFMA2.

Fields

FieldBitsFrom
reuse125:122the decoder
wait121:116the decoder
rd_bar115:113the decoder
wr_bar112:110the decoder
yield109the decoder
stall108:105the decoder
holds90execute_HFMA2
holds89:87execute_HFMA2
[86:85]86:85execute_HFMA2
h0_nh186execute_HFMA2
[85]85execute_HFMA2
neg84Hfma2Operand(0, A, b_at_64, h0_nh1)
absed83Hfma2Operand(0, A, b_at_64, h0_nh1)
sw82:81Hfma2Operand(0, A, b_at_64, h0_nh1)
[79:78]79:78execute_HFMA2
relu79execute_HFMA2
[78]78execute_HFMA2
[77]77execute_HFMA2
sw75:74Hfma2Operand(0, A, b_at_64, h0_nh1)
sw61:60Hfma2Operand(0, A, b_at_64, h0_nh1)
Ra31:24the decoder
Rd23:16the decoder
pred.not15the decoder
pred14:12the decoder
form11:9the decoder

Operation Sail

let relu = Field(79, 1) == 0b1;
let h0_nh1 = Field(86, 1) == 0b1;
if Field(78, 1) == 0b1 | Field(85, 1) == 0b1 | (relu & Field(77, 1) == 0b1) then
    throw(Unsupported("HFMA2 with modes 0x%x, 0x%x, saturate %u", Field(78, 2), Field(85, 2), Field(77, 1)));
let b_at_64 = Form() == 2 | Form() == 3 | Form() == 7;
let va = Hfma2Operand(0, A, b_at_64, h0_nh1);
let vb = Hfma2Operand(1, B, b_at_64, h0_nh1);
let vc = Hfma2Operand(2, C, b_at_64, h0_nh1);
let p = NoContract2(Half2Mul(va, vb));
let r0 = SumToOdd(p, vc);
let r1 = if Field(77, 1) == 0b1 then Half2Clamp01(r0) else r0;
let r = if relu then {
    let holds = PredRead(UInt(Field(87, 3)), UInt(Field(90, 1)), 0);
    /* a comparison NaN fails, and -0 passes on its way to +0 */
    let x0 = Half2At(r1, 0);
    let l0 = if holds & FCompare(3, x0, FConst(0x00000000)) then FConst(0x00000000) else x0;
    let x1 = Half2At(r1, 1);
    let l1 = if holds & FCompare(3, x1, FConst(0x00000000)) then FConst(0x00000000) else x1;
    Half2(l0, l1)
} else r1;
D_write(PackHalf(r))

Made from ScarletNX's Sail at 166ad3910f80. The Sail and the encodings' file are ScarletNX's (GPL-3.0-or-later); its encodings are from Mesa's NAK (sm70_encode.rs, MIT) and CuAssembler's sm_86 records.