Replies: 2 comments 2 replies
-
Yeah, this is kind of hard to answer as there are basically three layers:
@eddyb is probably the best to say what guarantees if nay happen where. I will say when we require the rust-gpu layer to output something specific, we put a disassembly test in so that it generates as expected. |
Beta Was this translation helpful? Give feedback.
-
I'd answer it differently: It doesn't really matter how shitty our SPIRV output is. Once you give that SPIRV to the driver, it'll spin up an entire LLVM toolchain to compile it down to machine code for the GPU you're running. (At least AMD and Nvidia use an LLVM backend, can't comment on other drivers). You should look at their output instead of our SPIRV to know if something is getting properly optimized. And in my experience, the answer was always yes. AMD provides their windows shader compiler within their Radeon GPU Analyser (RGA) package and it's available within RenderDoc as a viewing option for shader code. (Godbolt only exposes it with HLSL and Shader Playground can do SPIRV to AMD ISA become incredibly slow). AMD also provides public specs on their ISA. One thing you'll quickly notice on AMD's ISA is that they differenciate between scalar |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I feel like writing code with rust-gpu is a bit more tedious than it should be since I don't know what relatively trivial optimizations it can and can't do today comparing to almighty LLVM, where anything that is easy to deduce I leave where it is the easiest to read and expect compiler to move it in assembly to where it makes the most sense.
A simple example is a code like this in a loop:
Can I expect the compiler to consistently hoist this variable outside the loop or will it translate the thing literally and compute this on every loop iteration?
I'm probably asking too much, but some list of guaranteed optimizations would have been nice to have (if such list exists, I am not aware of it yet).
Beta Was this translation helpful? Give feedback.
All reactions