2021-04-11
00:27DarkShadow44bloom: Even for assemling shaders?
01:21DarkShadow44bloom: okay then
01:22DarkShadow44Because I still have my propsed architecture from my asmtool
01:26DarkShadow44would be good to have feedback before I implment too much though, don't wanna duplicate the effort
01:27zkrx has quit [Ping timeout: 240 seconds]
01:28DarkShadow44heh, sure
01:29DarkShadow44but making something useful in the process would be nice too :P
01:30odmir has quit [Remote host closed the connection]
01:31odmir has joined #asahi-gpu
01:36odmir has quit [Ping timeout: 268 seconds]
01:43zkrx has joined #asahi-gpu
01:45bloomhave most of the big ideas sketched in my head, we'll see how long it takes me to get to simple shaders
01:48DarkShadow44bloom: compiler, like in from NIR to bytecode?
01:52DarkShadow44directly or using an IR?
02:03odmir has joined #asahi-gpu
02:14dougallbloom: oh, wow, that's awesome! fun to see how the goal of generating html turned into the possiblity of generating xml/c
02:34odmir has quit [Remote host closed the connection]
02:34odmir has joined #asahi-gpu
02:44dougallhaha yeah, applegpu.py doesn't feel Right either - i'd like to rewrite it a bit more deliberately, but it's enough to make RE and doc progress for now
02:48bloombut not sure if there's much point in defining an intermediate XML schema for the sake of it, or trying to wire up robclark's isaspec (which will have impedance mismatches of its own)
02:50dougallyeah, the python definitely feels like a bad fit for mesa - i hadn't seen isaspec, but it sounds like it has the right goals... hmm
02:57bloomfor the compilers at work, I have full visibility into the ISA so I can do proper top-down design.. so having one master ISA.xml that everything is generated from works well
02:57phiologe has quit [Ping timeout: 250 seconds]
02:57phiologe has joined #asahi-gpu
02:58bloomfor hw with an active r/e effort, that may backfire. otoh, being bale to add instructions easily matters far more for r/e!
03:04dougallyeah - it's definitely a strange challenge - after thinking on it, i don't have a clear opinion either way...
03:06dougalli like less magic, i like declarative descriptions, and either will potentially have to be updated as r/e progresses
03:08bloom"i like less magic, i like declarative descriptions," unfortunately writing in languages designed in the 70s means these are mutually ^
03:12dougallyeah, it's a bit crazy - did you see this thread? (scroll up) https://twitter.com/dougallj/status/1361063810493083648
03:16dougall(i don't know if apple compiler implementation specific stuff belongs in the docs, but the fact that you kind of have to re-structure your cfg to compile C was an intuition of Erika's that i didn't have at all)
03:17bloomThe CFG we get from NIR is very simple, which is great for normal hw with actual branch instructions, but...
03:18bloom(Basically we get `if { ... }` `loop { .. }` `break` and `continue` and that's it. while loops become things like `loop { if not cond { break } .. }`
03:19krbtgtWRT the earlier convo on basically starting with GPU RE; it is tricky for sure, and i'm certainly an idiot at it. me and a friend were looking at REing ancient SGI GPUs and we found a few quite things out but didn't get as far as say disassembly
03:22dougallyeah break and loop aren't bad (if you look at metal compiler output)... break is an icmpsel to r0l then pop_exec 0 (to update execmask)
03:23dougallyeah - break is the only place i've seen that done, but that was really helpful to figure out what on earth was going on
03:25dougall(you can only update r0l on threads that are active, which is either obvious or confusing)
03:25bloomall of this seems both intuitively obvious and completely impossible to wrap my head around :-p
03:27bloomsomething else that may be either obvious or confusing -- for optimal perf, the compiler needs to do full divergence analysis
03:29dougall'full * analysis' does sound optimal, but that mostly goes over my head - is that the uniform hoisting optimisation thing?
03:30bloom"Divergence analysis" ~~calculates the sums of partial derivatives of a vector field~~ determines what values might differ across threads in a SIMD gorup
03:30bloomAll the silliness is needed for divergent (data-dependent) branches "if (some_varying) { ... }"
03:31bloomBut if we can prove at compile-time that all the threads in a given SIMD group will branch together, there's often optimizations to be had
03:32bloom(Most obvious case is "if (uniform) { .. }" but also less obviously "if (ballot(..)) { ... }"
03:35bloomThis doesn't really prove anything since the latter compile is always legal, just not always optimal.
03:36dougallyeah jmp_exec_none/any are the only conditional branches i know of, which should benefit from uniformity either way... but apple does love proving things are uniform and hoisting them into a shader that only runs once
03:42dougall(i should look into how they handle convergence (ballot/etc) more - it does sound like an optimisation oportunity, and maybe i'm missing some instructions/flags there)
03:45bloomwhile(x) { ... } ---> start: icmpsel r0l, x, #0, #1; pop_exec 0; jmp_exec_none end; ....; jmp_exec_any start; pop_exec 0;
03:48dougallyeah - it's not entirely clear in my mind... I think their while loop codegen starts with a push_exec 2... you're missing an initial push/final pop of some kind
03:50dougall(yeah, icmpsel #1 is more like a break than an 'if' - like if you have "if { your while } else { foo }" the "1"s and the else threads have the same value)
03:55dougallyeah - it wasn't easy figuring out what these instruction do, but figuring out how to use them from what they do feels trickier (using metal compiler idioms seems easier, but it'd be good to understand it properly)
03:56bloompeeling that back to Metal idioms will be one of the more memorable parts of compiler bringup ;)
04:09TheJollyRoger has quit [Remote host closed the connection]
04:10TheJollyRoger has joined #asahi-gpu
04:15bloomif_icmp 1; * icmpsel r0l, #2, #0; update_exec; ....; jmp_exec_any *; else_cmp 1; ...; pop_exec 2;
04:24dougallhmm - i want to write an emulator to test that, although i guess i kinda did (maybe? i don't think i implemented jumps)... but yeah, i can't be sure either way at a glance
04:25odmir has quit [Remote host closed the connection]
04:26odmir has joined #asahi-gpu
04:30odmir has quit [Ping timeout: 240 seconds]
05:26tomtastic has quit [Ping timeout: 240 seconds]
05:28tomtastic has joined #asahi-gpu
06:54mxw39 has quit [Quit: Konversation terminated!]
09:37angelXwind has quit [Ping timeout: 240 seconds]
09:47akemin_dayo has joined #asahi-gpu
10:05Necrosporus has quit [Ping timeout: 240 seconds]
10:45Necrosporus has joined #asahi-gpu
14:48bloomdougall: After giving it some thought last night i believe this would work, but it would break if there was something after the loop before the else, etc
14:51glibcramping up on Metal... I can compile .metallib files, which I understand are LLVM IR containers. I can compile them in a metal app; how can I get the output binary?
15:55bloomdougall: not sure if you've figured this out yet, but it looks like the `i` bit on wait corresponds to the `u2` immediate on device_Load
16:00josiahmendes[m] has quit [Quit: Idle for 30+ days]
16:06bloom....why is `stac_adjust/stack_store/stack_load` the fastest way to convert i32 to u8norm...
16:27odmir has joined #asahi-gpu
16:31odmir has quit [Ping timeout: 240 seconds]
16:33glibcI guess I can build an binary archive and serialize it, but I wonder if there is an easier way to get the raw compiled binaries.
17:12tmlind has joined #asahi-gpu
17:22odmir_ has joined #asahi-gpu
17:33DarkShadow44glibc: What exactly do you want to do?
17:57DarkShadow44glibc: Alright, otherwise I could have offered you my version. Do you also use this code https://github.com/DarkShadow44/AsahiLinux-gpu/blob/asmtool/asmtool/asmtool/metallib.c ?
18:04DarkShadow44FWIW, I just copied that - but also integrated it into my tool - so you can just feed it source and it outputs disassembly
18:05glibccool, that's exactly what I wanted. (I was still missing a clean method for extracting the raw payload)
18:10DarkShadow44I take it, you're also trying to re the ISA?
18:16DarkShadow44heh, wishing you the best of luck! :)
18:18* bloomhas always ignored the 'nice' methods of doing this, preferring to just savagely parse GPU memory at runtime
18:19DarkShadow44bloom: You can extract shaders from GPU memory after they've been uploaded?
18:21DarkShadow44glibc: One more thing I forgot: Keep in mind that the metallib way of getting a shader produces different bytecode from loading a shader normally
18:22DarkShadow44they're compiled as "functions" (for lack of a better word) instead of a standalone program
18:22DarkShadow44so if you try to run them, you better check they load/store data at the right offsets :P
18:22DarkShadow44...if you want to run them in the first place
18:24DarkShadow44cool, I kinda thought once it's uploaded you can't access it anymore
18:24DarkShadow44downloading that is kinda savage indeed, but I like the idea ^
18:29DarkShadow44bloom: Say, do you know if isaspec from mesa can be used to create an assembler? Because from reading their docs it seems like this is not yet the case
18:32solarkraft has quit [Ping timeout: 240 seconds]
19:31odmir_ has quit [Remote host closed the connection]
19:32odmir has joined #asahi-gpu
19:36odmir has quit [Ping timeout: 240 seconds]
20:02odmir has joined #asahi-gpu
20:11bloomDarkShadow44: I'm not sure if they added support or not, it's definitely on their wishlist though.
20:22radex1 has quit [Quit: WeeChat 3.0]
20:26artemist has quit [Ping timeout: 276 seconds]
20:33artemist has joined #asahi-gpu
20:36odmir has quit [Ping timeout: 260 seconds]
20:39bloomdougall: Any reason why applegpu.py seperates {A,B,C,D} from {A,B,C,D}t? It looks like the fields are always adjacent
20:40bloomI guess just more convenient that way. Probably will merge them for whatever i end up doing.
20:59odmir has joined #asahi-gpu
21:32odmir has quit [Ping timeout: 240 seconds]
21:44odmir has joined #asahi-gpu
22:00yrlf has quit [Quit: The Lounge - https://thelounge.chat]
22:01yrlf has joined #asahi-gpu
22:18odmir has quit [Ping timeout: 268 seconds]
22:18bloomdougall: Also, patches incoming for `blend` and maybe `ld_var` if I have time before getting bored and reading a novel :p
22:29odmir has joined #asahi-gpu
23:02odmir has quit [Ping timeout: 240 seconds]
23:03odmir has joined #asahi-gpu