comparison of ptx/sass code from nvcc vs clang
- nvcc code 15–18% faster
- nvcc code is bigger and more amenable to stall counts reducing
- all mlir based compilers use vanilla llvm nvptx backend :-(
nvptx uses 58.9% of all ptx instructions
cicc 57.8%
missed in clang:
I wrote code to calculate some metrics, like
https://redplait.blogspot.com/2026/08/cyclomatic-complexity-of-sass-code.html
The Insights:
Can those 2 be expressed in SchedMachineModel?
For example I must track that consequent write after read to the same register must be delayed to ensure that read operation was completed
The combination of these facts leads to stark conclusion - CUDA compiler front-ends totally ignore PTX inline asm and only PTXAS known how to parse them. So I made little and fast parser: https://redplait.blogspot.com/2026/08/parser-of-ptx-instructions.html
Note: this is not full featured replacement of PTX parser. it is designed specifically to extract instruction attributes and determine the correct instruction form based on argument types and counts
by relaxing delays for some small set of instructions we can get speed-up 0.2-0.3% for integer-heavy kernels
I extracted it from sdk 13.4 dev preview
MD file itself: https://github.com/redplait/denvdis/blob/master/data12/sm107_1.txt
Latency tables: https://github.com/redplait/denvdis/blob/master/data12/sm107_2.txt
version in ELF 0x6b - between sm103 (0x67) & sm110 (0x6e)
- ptxas has enough good heuristic
- in average you can reduce ~3% of stall counts
- overall speed up is not equivalent to the number of optimized stall counts
sorry if this is wrong sub-reddit for such questions
Are there some papers/experiments about subj to automatically derive things like indices swizzling/caching in shared memory/pinned memory etc?
https://redplait.blogspot.com/2026/07/identification-of-const-bank0-params.html
I don't have expensive monsters like sm100+ so extracted only params from maxler till hopper
https://redplait.blogspot.com/2026/06/re-of-ptx-grammar-from-ptxas-part-4.html
You can recover tokens from compiled (f)lex code
Complexity for recovering of single token is O(T * log(T)) where T is size of yy_transition
details: https://redplait.blogspot.com/2026/06/recovering-tokens-from-flex-generated.html
https://redplait.blogspot.com/2026/06/re-of-ptx-grammar-from-ptxas-part-3.html
https://redplait.blogspot.com/2026/05/re-of-ptx-grammar-from-ptxas-part-2.html
https://redplait.blogspot.com/2026/05/re-of-ptx-grammar-from-ptxas.html
Project in active development, so if you are passionate on PTX, love digging into unstructured data and performing operations on sets, your help is welcomed
https://github.com/NVlabs/cuda-oxide
never used it but seems interesting
official nvidia link https://nvlabs.github.io/cuda-oxide/