#
#asahi-gpu · 2021-04-17 03:58
bloomdougall: https://github.com/AsahiLinux/gpu/commit/f6dba34f41d957820ae880ffdf8fce8e42b1ecd1
#asahi-gpu · 2021-04-17 03:52
bloomjust bruteforces
#asahi-gpu · 2021-04-17 03:51
bloomr0-r3
#asahi-gpu · 2021-04-17 03:50
dougall(is one register quadword like r0-r3 or like r0l-r1h?)
#asahi-gpu · 2021-04-17 03:50
bloomIf Q >= 14, you have less. I was about to say I had the formula but my formula is buggy, hang on
#asahi-gpu · 2021-04-17 03:48
bloomIf Q <= 13, then you have 1024 threads.
#asahi-gpu · 2021-04-17 03:48
bloom(call that Q)
#asahi-gpu · 2021-04-17 03:48
bloomSo, in terms of the "register quadwords" field in the cmdstream:
#asahi-gpu · 2021-04-17 03:47
dougallah, what's it look like?
#asahi-gpu · 2021-04-17 03:46
bloomJust dumped maxTotalThreadsPerThreadgroup and varied register pressure systematically
#asahi-gpu · 2021-04-17 03:46
bloomactually r/e is a stretch
#asahi-gpu · 2021-04-17 03:46
bloomdougall: Ok, I just r/e'd thread count
#asahi-gpu · 2021-04-17 03:21
bloomSo rsqrt_special(+inf) needs to be some positive number.
#asahi-gpu · 2021-04-17 03:20
bloombut rsqrt(+inf) = 0.0 and 0.0 * +inf = NaN (indeterminate form)
#asahi-gpu · 2021-04-17 03:20
bloomlikewise, we want sqrt(+inf) = +inf
#asahi-gpu · 2021-04-17 03:19
bloomwhich holds if we set rsqrt(-0.0) = 0.0 since 0.0 * -0.0 = -0.0
#asahi-gpu · 2021-04-17 03:19
bloomalso need sqrt(-0.0) = -0.0
#asahi-gpu · 2021-04-17 03:18
dougallah, yeah, that'd make sense :)
#asahi-gpu · 2021-04-17 03:18
bloomso rsqrt_special has to define rsqrt(0) to be finite (which is wrong)
#asahi-gpu · 2021-04-17 03:17
bloomrsqrt(0) is probably NaN and NaN * 0 = NaN, yet sqrt(0) = 0
#asahi-gpu · 2021-04-17 03:17
bloomProbably the usual suspects: NaN, Inf, signed zero
#asahi-gpu · 2021-04-17 03:16
dougall(asside from precision)
#asahi-gpu · 2021-04-17 03:16
dougall"Implemented as x * rsqrt(x) with special cases handled correctly" - so i guess how does sqrt(x) differ from x * rsqrt(x)?
#asahi-gpu · 2021-04-17 03:11
bloombut we already.. had rsqrt
#asahi-gpu · 2021-04-17 03:11
bloomso it's in fact rsqrt
#asahi-gpu · 2021-04-17 03:10
bloomit's actually sqrt(x) = f(x) * x
#asahi-gpu · 2021-04-17 03:10
bloomthe thing I called sqrt, call it f(x)
#asahi-gpu · 2021-04-17 03:10
bloomdougall: Oh, ouch, embarassing - misread the sqrt op
#asahi-gpu · 2021-04-17 03:03
bloomthe way it schedules the scalarization of vec4 arithmetic is suggestive
#asahi-gpu · 2021-04-17 03:03
blooma bit of a hunch looking at a funny shader I compiled -- looks like integer ALU issues 2 insructions at once, maybe?
#asahi-gpu · 2021-04-17 02:52
bloomnote to self: r5 appears preloaded with vertex id in vs
#asahi-gpu · 2021-04-17 02:09
bloom(that could be granularity of 8 instead, for example. etc)
#asahi-gpu · 2021-04-17 02:08
bloombut that might not be the allocation of threads
#asahi-gpu · 2021-04-17 02:08
bloomGranularity of 4 is almost certainly the allocation of registers
#asahi-gpu · 2021-04-17 02:08
bloomPossibly, possibly not.
#asahi-gpu · 2021-04-17 02:07
dougalli think a granularity of four is possibly correct... register granularity is observable by using out-of-range register ids. occupancy would be 'floor(total / round_up(register_count))' right?
#asahi-gpu · 2021-04-17 02:04
dougallhmm... yeah, i've been wanting to get at those counters, but i'm not quite sure how to approach it
#asahi-gpu · 2021-04-17 02:01
bloom"the shader cores... feature a constant execution and prefetch"
#asahi-gpu · 2021-04-17 01:58
bloomhttps://metalkit.org/2020/07/03/wwdc20-whats-new-in-metal.html has some goodies.
#asahi-gpu · 2021-04-17 01:57
bloom"Advanced Metal Shader Optimization" from WWDC'16 is still relevant :)
#asahi-gpu · 2021-04-17 01:55
bloomOh, even better maxTotalThreadsPerThreadgroup is literally in the Metal API. nice!
#asahi-gpu · 2021-04-17 01:48
bloomSo it ought to be able to figure out from the other direction like you've done with the cpu?
#asahi-gpu · 2021-04-17 01:48
bloomBut! Apple docs talk about occupancy perf counters?
#asahi-gpu · 2021-04-17 01:48
bloomThe cmdstream just specifies register count/4, but that seems more fine grained than real hw would implement
#asahi-gpu · 2021-04-17 01:47
bloomI'd like to know what the thresholds are for register usage --> thread occupancy
#asahi-gpu · 2021-04-17 01:47
bloomdougall: hey, I have a reversing question for you
#asahi-gpu · 2021-04-17 01:42
bloompiles of ALU
#asahi-gpu · 2021-04-16 23:03
chrisfwhat does the precise sin code look like?
#asahi-gpu · 2021-04-16 22:46
bloomI would expect if you have fast imprecise transcendentals available, you'd use them and feed the estimate into Newton's method or something
#asahi-gpu · 2021-04-16 22:46
bloomwhat's more interesting to me is that they don't use the fast sine anywhere in it

plus ›