#
…

2021-04-15

00:02bloomfadd16/fmul16/fmadd16 seem fine?
00:02vlixa has quit [Remote host closed the connection]
00:02bloomif you want to know what my reference point for regularity is i'll link you the bifrost encoding :p
00:06dougallyeah, 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
00:10bloom"and the fact that 32-bit ops can have 16-bit sources and destinations too"
00:10bloomThis part makes a ton of sense.
00:11bloomThe 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.
00:11bloomIt's fundamentally a different operation. Convert, fp32 multiply, convert, versus fp16 multiply. The latter is much cheaper. (The converts are cheap regardless.)
00:13dougallah, good point, yeah... that makes sense
00:13bloomon some arches, fp16 multiply is even vectorized (where fp32 is scalar, conversions be damned)
00:13bloomit's that much cheaper :>
00:19bloomHonestly the most annoying part of the encoding is the presence of >64-bit instructions
00:19bloomMakes the bit arithmetic awful.
00:27dougallyeah, C is particularly painful for that... i'd probably use __int128, and i'd probably end up regretting it :p
00:50bloomok, added some generic ALU packing code
00:50bloom2 lines shorter than I was before :-p
01:38odmir has joined #asahi-gpu
01:42odmir has quit [Ping timeout: 240 seconds]
01:56vijfhoek has quit [Ping timeout: 246 seconds]
01:56vijfhoek has joined #asahi-gpu
01:57anuejn has quit [Ping timeout: 246 seconds]
01:58anuejn has joined #asahi-gpu
02:06bloom...and with the generic stuff, it was a cinch to add support for all the funops
02:08bloomdougall: " if sx and source.thread_bit_size >= 16:"
02:09bloomI suspect s/>= 16/< 64/ was intended.
02:11bloomI do wonder, if there's native 64-bit adds, why I see the blob lowering to a pair of adds
02:13bloomOh, maybe because there's no 64-bit access to uniform registers.
02:14dougallhmm, yeah, i think you're right about < 64...
02:15bloomnot a r/e thing, just a "what is sign-extension?" thing ;)
02:16bloomalso, the encoding for iadd seems really odd. this is probably the weirdest of the ISA.
02:16bloomIt's like it's supposed to be a 48-bit instruction and they added an extra 2 bytes of padding for no reason? what?
02:17dougallfwiw 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
02:19bloom...Interesting.
02:21dougallyeah, 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
02:24TheJollyRoger has quit [Quit: TheJollyRoger]
02:24TheJollyRoger has joined #asahi-gpu
02:26bloomI'm not worried about 2 unknown bits in the extended encoding
02:26bloomit's iadd specifically (imadd is fine) that's all weird..
02:29Necrosporus has quit [Killed (beckett.freenode.net (Nickname regained by services))]
02:29Necrosporus has joined #asahi-gpu
02:35Necrosporus has quit [Killed (verne.freenode.net (Nickname regained by services))]
02:35Necrosporus has joined #asahi-gpu
02:52dougall(or maybe i was trying to say that immediates don't get sign extended? not really the best way to represent that... hmm)
02:52phiologe has quit [Ping timeout: 250 seconds]
02:55phiologe has joined #asahi-gpu
05:35pthariensflame has joined #asahi-gpu
05:42pthariensflame has quit []
05:46bpye has quit [Quit: The Lounge - https://thelounge.chat]
05:47bpye has joined #asahi-gpu
07:04vlixa has joined #asahi-gpu
08:41bpye has quit [Quit: Ping timeout (120 seconds)]
08:42bpye has joined #asahi-gpu
09:00Bastian[m] has quit [Quit: Idle for 30+ days]
09:08neobrain has quit [Remote host closed the connection]
09:12Bastian[m] has joined #asahi-gpu
11:09gabboman has joined #asahi-gpu
11:21gabboman has quit [Quit: Ping timeout (120 seconds)]
12:31gabboman has joined #asahi-gpu
12:39gabboman has quit [Quit: Connection closed]
14:45tomtastic has quit [Ping timeout: 240 seconds]
14:49tomtastic has joined #asahi-gpu
15:20vup has quit [Ping timeout: 245 seconds]
15:20vup has joined #asahi-gpu
16:50chrisf has quit [Quit: ZNC - https://znc.in]
16:54chrisf has joined #asahi-gpu
17:17odmir has joined #asahi-gpu
18:03bloomdougall: ok, my curiousity got the best of me, poked at sin_pt_1/2
18:03bloomThe heavylifting is done by sin_pt_2. However, the function it computes is *not* sin(x), rather it's sin(x)/x
18:04bloom(This is standard, there are numeric advantages here.)
18:04bloomBut it only computes in a single quadrant. So given 0 <= x < 1, it'll spit back sin(x * (pi/2)) / x
18:05bloomNotice 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.
18:06bloomThis 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.
18:07bloomSo what is sin_pt_1? It's just a quadrant fixup.
18:08bloomFor 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.
18:09bloomFor 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.
18:11bloomFor 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.
18:11bloomLikewise for the fourth quadrant, where we both complement and flip the sign.
18:12bloomThe 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.
18:12bloomPutting it together, we get definitions:
18:13bloomsin_pt_1 : [0, 4] -> [-1, 1], sin_pt_2 : [-1, 1] -> R
18:13bloomsin_pt_1(x) =
18:13bloom{ x if 0 <= x < 1
18:14bloom{ 2 - x if 1 <= x < 2
18:14bloom{ 2 - x if 2 <= x < 3
18:14bloom{ x - 4 if 3 <= x < 4
18:14bloomOr more clearly:
18:14bloomsin_pt_1(x) =
18:14bloom{ fract(x) if 0 <= x < 1
18:15bloom{ 1 - fract(x) if 1 <= x < 2
18:15bloom{ - fract(x) if 2 <= x < 3
18:15bloom{ fract(x) - 1 if 3 <= x < 4
18:15bloomAs well as:
18:15bloomsin_pt_2(x) = sin((pi/2) * |x|) / |x|
18:16bloom(Is sin_pt_2(0) undefined? Maybe, maybe not. It doesn't matter, as long as it's value satisfies sin_pt_2(0) * 0 = 0 since sin(0) = 0.)
18:17bloom(This requires the value to be finite, since Inf * 0 and NaN * 0 are both NaN under standard IEEE 754 rules.)
18:18bloomAnd that's how AGX computes sine and cosine!
18:21bloom(Up to constants, sin_pt_2 is the "sinc" function.)
20:04odmir has quit [Remote host closed the connection]
20:05odmir has joined #asahi-gpu
20:07nickiminjaj has joined #asahi-gpu
20:10odmir has quit [Ping timeout: 260 seconds]
20:11robinp has quit [Read error: Connection reset by peer]
20:14robinp has joined #asahi-gpu
20:21odmir has joined #asahi-gpu
20:26odmir has quit [Ping timeout: 268 seconds]
20:37odmir has joined #asahi-gpu
20:57odmir has quit [Ping timeout: 240 seconds]
21:11odmir has joined #asahi-gpu
21:42glibc# 48 00 C2 00 -unk48 h0, 2l, u0l.neg
21:42glibcthat appears even in empty fragment shaders
21:43glibcwith early-z, no alpha-to-coverage or other weird features
21:49bloomI *suspect* that controls some detail of the tilebuffer
21:50bloomand if you look at how MRT writeout works you can see a pair of bits moving along in those unk48 ("writeout" in dougall's)
21:50bloomsimilarly interesting patterns with depth/stencil writeouts, et
21:56pthariensflame has joined #asahi-gpu
21:57pthariensflame has quit [Client Quit]
22:21chrisf has quit [Quit: ZNC - https://znc.in]
22:25chrisf has joined #asahi-gpu
23:06odmir has quit [Remote host closed the connection]
23:07odmir has joined #asahi-gpu
23:12odmir has quit [Ping timeout: 268 seconds]
23:38odmir has joined #asahi-gpu
…