#asahi-gpu · 2021-04-15 18:14
bloom{ 2 - x if 1 <= x < 2#asahi-gpu · 2021-04-15 18:13
bloom{ x if 0 <= x < 1#asahi-gpu · 2021-04-15 18:13
bloomsin_pt_1(x) =#asahi-gpu · 2021-04-15 18:13
bloomsin_pt_1 : [0, 4] -> [-1, 1], sin_pt_2 : [-1, 1] -> R#asahi-gpu · 2021-04-15 18:12
bloomPutting it together, we get definitions:#asahi-gpu · 2021-04-15 18:12
bloomThe last detail I glossed is the units. sin_pt_2 wants its angle as [-1, 1] but sin_pt_1 takes in a rotation [0, 4]. This doesn't affect any of the math, but it means the constants work out to nice integers.#asahi-gpu · 2021-04-15 18:11
bloomLikewise for the fourth quadrant, where we both complement and flip the sign.#asahi-gpu · 2021-04-15 18:11
bloomFor xin the second quadrant, recall sin(x + pi/2) = cos(x) = sin(pi/2 - x). So rather than flip the sign, we take the arithmetic complement.#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: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:19
bloom...Interesting.#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: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: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: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: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:54
bloomworst as in most or least 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.)#asahi-gpu · 2021-04-14 22:50
bloomwithout any derived code from applegpu I don't think#asahi-gpu · 2021-04-14 22:50
bloomdougall: Leaning towards a Python code gen thing