While poking around RT kernels (extracted from libcuda.so) I stumbled upon very remarkable sample - sm159.elf. First let's check what tools were used to compile it - dump section .note.nv.tkinfo (here it has index 5):
readelf -x 5 sm159.elf
As you can see it was compiled with regular ptxas from SDK 13.1 (and not with nvasm_internal). This file contains huge function _ZN6RefTMA12TMACommand_tC1ERKNS_19ptx_inst_parametersE - first branch happens at offset 0xc70 and first back-edge at 37c0. Let's take a look at this piece of code:
Hex dump of section '.note.nv.tkinfo':
0x00000000 0c000000 9c000000 d0070000 4e564944 ............NVID
0x00000010 49412043 6f727000 02000000 00000000 IA Corp.........
0x00000020 01000000 07000000 35000000 54000000 ........5...T...
0x00000030 00707478 61730043 75646120 636f6d70 .ptxas.Cuda comp
0x00000040 696c6174 696f6e20 746f6f6c 732c2072 ilation tools, r
0x00000050 656c6561 73652031 332e312c 20563133 elease 13.1, V13
0x00000060 2e312e30 00427569 6c642063 7564615f .1.0.Build cuda_
0x00000070 612e6375 64615f61 2e333630 34343438 a.cuda_a.3604448
0x00000080 365f3000 2d6d6178 72726567 636f756e 6_0.-maxrregcoun
0x00000090 74203332 202d6172 63682073 6d5f3132 t 32 -arch sm_12
0x000000a0 31202d64 6c636d20 6367202d 6d203634 1 -dlcm cg -m 64
0x000000b0 20000000 ... /*01b0*/ LDC.64 R28, c[0x0][0x358] ; move base ptr into R28-29What noteworthy things can we examine here?
/*01c0*/ R2UR UR4, R28.reuse ; assign UR4
/*01d0*/ R2UR UR5, R29.reuse ;
/*01e0*/ R2UR UR6, R28 ;
/*01f0*/ R2UR UR7, R29 ;
/*0200*/ R2UR UR8, R28.reuse ; assign the same value from R28-29
/*0210*/ R2UR UR9, R29.reuse ;
/*0220*/ R2UR UR10, R28.reuse ;
/*0230*/ R2UR UR11, R29.reuse ;
/*0240*/ ST.E desc[UR4][R16.64+0x18], R3 ; use UR4 for desc operand
/*0250*/ R2UR UR12, R28.reuse ;
/*0260*/ R2UR UR13, R29 ;
/*0270*/ ST.E desc[UR6][R16.64+0x38], R3 ;
/*0280*/ R2UR UR70, R28 ;
/*0290*/ R2UR UR71, R29.reuse ;
/*02a0*/ ST.E desc[UR8][R16.64+0x58], R3 ;
/*02b0*/ R2UR UR68, R28.reuse ;
/*02c0*/ R2UR UR69, R29.reuse ;
/*02d0*/ ST.E desc[UR10][R16.64+0x78], R3 ;
/*02e0*/ R2UR UR66, R28.reuse ;
/*02f0*/ R2UR UR67, R29 ;
/*0300*/ ST.E desc[UR12][R16.64+0x118], R5 ;