kernel.s (793B)
1 .intel_syntax noprefix 2 .text 3 .globl _Z4testPc 4 .type _Z4testPc, @function 5 _Z4testPc: 6 # Stack operations that end up in L1,L2,L3 caches. The stack size on Linux 7 # is usually around 8MB (see `ulimit -s`) so most of the stack operations 8 # will have around 4 cycle latency (L1 ideally). 9 # PAPI counts these in PAPI_LST_INS counter also (NOT WHAT WE WANT!) 10 mov QWORD PTR [rsp-8], rdi 11 mov rax, QWORD PTR [rsp-8] 12 # data cache miss: read from RAM (about 200 cycles) 13 # PAPI counts this in PAPI_LST_INS counter (WHAT WE WANT) 14 mov cl, BYTE PTR [rdi] 15 # write to pointer A[0] = 1 [this will cause the printed result to be 1] 16 # (about 200 cycles) 17 # PAPI counts this in PAPI_LST_INS counter (WHAT WE WANT) 18 mov BYTE PTR [rdi], 0x1 19 ret