3 ms·
How to Read Shader Assembly
- pavlov 6y agoI remember writing OpenGL fragment shader assembly for the Radeon 9600. The hardware had a 32-instruction limit for shader programs, so it was kind of fun trying to do as much as possible in one render pass. Comparing that experience with the complexity of the instruction set described in this article, it's easy to appreciate how far GPUs have come in 19 years.
- deleted 6y ago[deleted]
- okaleniuk 6y agoIt's even more fun with CUDA. You have PTX assembly and CUDA binary assembly which are completely different. But it still pays to peek into disassembly every now and then. For instance, one time I got to shorten a kernel runtime by switching an index type from size_t to uint32_t. Apparently, 64-bit integer division wasn't supported directly by the target architecture and instead of some kind of IDIV, there was a 100-lines function embedded and called on every division. Just downcasting an index before pushing it to the kernel made the whole thing considerably faster. But I wouldn't know I should have done this if not for the disassembly.
- david-gpu 6y agoGreat intro to the insanity that is my job. > Even though no one writes shaders in assembly directly nowadays I heard that back over 20 years ago in college. It wasn't true then and it is still not true. It's becoming less common, though. Sometimes people don't even have an assembler and have to resort to writing machine code directly, in binary. Incidentally, I can't express with words the admiration that I have for the experts in performance tuning that I've met over the years, especially at NVidia. These folks live and breathe GPU architecture to a degree that I will never achieve.