#asahi-gpu · 2021-04-15 18:09
bloomFor x in the third quadrant, recall sin(x + pi) = -sin(x). So sin_pt_2 will just flip the sign, so we can compute in the first quadrant (pt_2), and then the sign gets restored with the multiply.#asahi-gpu · 2021-04-15 18:08
bloomFor x in the first quadrant, it's simply the identity. sin_pt_2 is defined as such, so when we compute sin_pt_2(sin_pt_1(x)) * sin_pt_1(x) we're just computing sine.#asahi-gpu · 2021-04-15 18:07
bloomSo what is sin_pt_1? It's just a quadrant fixup.#asahi-gpu · 2021-04-15 18:06
bloomThis is a useful property: it lets sin_pt_1 pass the sign of the output over the sin_pt_2 call, to be recombined with a later multiplication.#asahi-gpu · 2021-04-15 18:05
bloomNotice that's an even function. So sin_pt_2 is in fact defined over [-1, 1], but it ignores the sign bit of its input.#asahi-gpu · 2021-04-15 18:04
bloomBut it only computes in a single quadrant. So given 0 <= x < 1, it'll spit back sin(x * (pi/2)) / x#asahi-gpu · 2021-04-15 18:04
bloom(This is standard, there are numeric advantages here.)#asahi-gpu · 2021-04-15 18:03
bloomThe heavylifting is done by sin_pt_2. However, the function it computes is *not* sin(x), rather it's sin(x)/x#asahi-gpu · 2021-04-15 18:03
bloomdougall: ok, my curiousity got the best of me, poked at sin_pt_1/2#asahi-gpu · 2021-04-15 02:52
dougall(or maybe i was trying to say that immediates don't get sign extended? not really the best way to represent that... hmm)#asahi-gpu · 2021-04-15 02:26
bloomit's iadd specifically (imadd is fine) that's all weird..#asahi-gpu · 2021-04-15 02:26
bloomI'm not worried about 2 unknown bits in the extended encoding#asahi-gpu · 2021-04-15 02:21
dougallyeah, not sure what's up with that encoding... i do think there's _something_ in the high couple of bits in most/all instructions that i haven't figured out, which might make it make a tiny bit more sense#asahi-gpu · 2021-04-15 02:19
bloom...Interesting.#asahi-gpu · 2021-04-15 02:17
dougallfwiw i saw apple's compiler emit 64-bit subtracts and 64-bit add+shift, but (as far as i can recall) not 64-bit adds#asahi-gpu · 2021-04-15 02:16
bloomIt's like it's supposed to be a 48-bit instruction and they added an extra 2 bytes of padding for no reason? what?#asahi-gpu · 2021-04-15 02:16
bloomalso, the encoding for iadd seems really odd. this is probably the weirdest of the ISA.#asahi-gpu · 2021-04-15 02:15
bloomnot a r/e thing, just a "what is sign-extension?" thing ;)#asahi-gpu · 2021-04-15 02:14
dougallhmm, yeah, i think you're right about < 64...#asahi-gpu · 2021-04-15 02:13
bloomOh, maybe because there's no 64-bit access to uniform registers.#asahi-gpu · 2021-04-15 02:11
bloomI do wonder, if there's native 64-bit adds, why I see the blob lowering to a pair of adds#asahi-gpu · 2021-04-15 02:09
bloomI suspect s/>= 16/< 64/ was intended.#asahi-gpu · 2021-04-15 02:08
bloomdougall: " if sx and source.thread_bit_size >= 16:"#asahi-gpu · 2021-04-15 02:06
bloom...and with the generic stuff, it was a cinch to add support for all the funops#asahi-gpu · 2021-04-15 00:50
bloom2 lines shorter than I was before :-p#asahi-gpu · 2021-04-15 00:50
bloomok, added some generic ALU packing code#asahi-gpu · 2021-04-15 00:27
bloomlol#asahi-gpu · 2021-04-15 00:27
dougallyeah, C is particularly painful for that... i'd probably use __int128, and i'd probably end up regretting it :p#asahi-gpu · 2021-04-15 00:19
bloomMakes the bit arithmetic awful.#asahi-gpu · 2021-04-15 00:19
bloomHonestly the most annoying part of the encoding is the presence of >64-bit instructions#asahi-gpu · 2021-04-15 00:13
bloomit's that much cheaper :>#asahi-gpu · 2021-04-15 00:13
bloomon some arches, fp16 multiply is even vectorized (where fp32 is scalar, conversions be damned)#asahi-gpu · 2021-04-15 00:13
dougallah, good point, yeah... that makes sense#asahi-gpu · 2021-04-15 00:11
bloomIt's fundamentally a different operation. Convert, fp32 multiply, convert, versus fp16 multiply. The latter is much cheaper. (The converts are cheap regardless.)#asahi-gpu · 2021-04-15 00:11
bloomThe 32-bit ops are heavier weight. Yes, you _can_ run a fadd.32 with all operands 16-bit, but that will (depending on uarch details that are not ISA visible) be slower or higher power.#asahi-gpu · 2021-04-15 00:10
bloomThis part makes a ton of sense.#asahi-gpu · 2021-04-15 00:10
bloom"and the fact that 32-bit ops can have 16-bit sources and destinations too"#asahi-gpu · 2021-04-15 00:06
dougallyeah, they could definitely be worse - i'm just thinking of moving the Am/Bm/Cm field relative to their 32-bit equivalents (why did they do that?), and the fact that 32-bit ops can have 16-bit sources and destinations too#asahi-gpu · 2021-04-15 00:02
bloomif you want to know what my reference point for regularity is i'll link you the bifrost encoding :p#asahi-gpu · 2021-04-15 00:02
bloomfadd16/fmul16/fmadd16 seem fine?#asahi-gpu · 2021-04-14 23:58
dougallhaha least regular ALU#asahi-gpu · 2021-04-14 23:54
bloomworst as in most or least regular? ;)#asahi-gpu · 2021-04-14 23:52
dougallhaha yep, fadd16/fmul16/fmadd16 and 64-bit iadd/imadd come to mind, although i don't remember if that's the worst of it#asahi-gpu · 2021-04-14 23:41
dougallsounds good! yeah, it's mostly really nice and regular :)#asahi-gpu · 2021-04-14 23:31
bloomor at least that gets as close as possible#asahi-gpu · 2021-04-14 23:31
bloomwrites fn that can encode any ALU instruction just from the type signature#asahi-gpu · 2021-04-14 23:18
bloomld/st and texture encodings are always a mess :-p#asahi-gpu · 2021-04-14 23:18
bloomThe ALU encoding, anyway.#asahi-gpu · 2021-04-14 22:51
bloomGood news is the encoder is so regular you don't really need a fancy autogenerator.#asahi-gpu · 2021-04-14 22:51
bloom(My stuff is too wrapped up in compilerisms, and yours in HTMLisms and assemblerness and emulatorisms.)