-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LLVM MCA / IACA integration? #40
Comments
Thanks, this really looks like something worth doing. So Having said this, Maybe we could emit this "delimiters" from rustc somehow ? For example, using inline assembly before and after the loop we might be able to put some labels or directives, that we can use to identify the loop. Also, rustc recently gained the ability to comment assembly code, so maybe we could make it spit comments before and after the loop as well, which shouldn't inhibit as many optimizations as inline assembly would. Once those are in the generated assembly, cargo mca / cargo iaca could find those, extract the assembly, and forward it to the tool in whatever format it accepts. The alternative would be for cargo asm to somehow "identify" the loop. Some loops jump around many labels, and some loops are tighter, so I don't think this is easily doable, but maybe the tool could become "interactive", where the user inputs e.g. the line numbers of where the loop starts and ends. No idea, how does your tool work? |
Yup, sorry I was unclear, that's what I was trying to get at with "the code would be common"... I guess the choice of how to call it is purely a UX concern.
It works ... kind of badly 🙃 It has macros that insert inline asm, which sticks byte markers into the generated machine code, which the IACA tool then disassembles to select the loop body. But it turns out (I think, it's been a year or so) that the inline asm markers will sometimes slide around a bit, so you have to look at the generated asm anyways to check that the optimizer didn't move them. The usability is pretty bad: you have to add the crate as a dep, stick in the markers manually, compile and emit asm, check the asm, then find the generated binary in As is, Maybe to start, it would be sufficient to use the same function-selection logic as |
llvm-mca integration is now supported by |
First,
cargo asm
is a really wonderful addition to the Rust tooling ecosystem -- thanks so much for making it.I'm wondering whether it would make sense to integrate it with the LLVM MCA tool, or Intel's IACA. These do static analysis on machine code, to estimate throughput and port pressures on a specific microarchitecture.
I made a proof-of-concept for using IACA with Rust code. It doesn't really work super well (and IACA is proprietary anyways), but it is pretty neat:
It would be really cool if there was an easy way to use these tools on fragments of Rust code (I mean, so that it's as easy to see throughput estimates as
cargo asm
makes it easy to see the generated asm).I'm not sure exactly how it would work -- AFAIK they're intended to be used for loop bodies (to estimate throughput), but
cargo asm
is oriented around specific functions. Maybe it would work to have a way to apply the MCA analysis to a specific function, as if that function was the body of a loop? I'm also not sure if it makes sense for that functionality to be part ofcargo asm
, vs acargo mca
tool or something, but it seems like a bunch of the code required to pull out a specific function would be common.The text was updated successfully, but these errors were encountered: