Counting Instructions — Intel® SDE documentation

# Counting Instructions

The most basic Intel® SDE analysis is to find the application’s dynamic instruction count. This task is done in the instruction count analysis tool. It count the instructions executed per thread, and dump the number whenever a thread ends. The output is written to the standard error as well as to a file.

    % sde -skx -icount -- myapp
    $$ TID: 2 ICOUNT: 2789
    $$ TID: 1 ICOUNT: 6409
    $$ TID: 3 ICOUNT: 1659
    $$ TID: 4 ICOUNT: 1659
    All threads ended
    $$ TID: 0 ICOUNT: 279289

The x86 architecture has a few repeat string instructions. These instructions are implemented as a micro-code loop that execute the instruction. This causes multiple issues that are complex to handle in this way, therefore Intel® Pin translate the instruction into an explicit loop that execute each iteration of the string instructions as an individual instruction.

The instruction counting tool, normally count each (“internal”) iteration, as execution of the instruction. This can cause bias when comparing with the CPU performance counters. Therefore, Intel® SDE provides an option to count every repeat string instruction as a single instruction and ignore all the internal iterations. Use the knob -icount-norep for this mode.

Instruction Count Controls

`-icount`

  Count instructions (faster than mix) [default 0]

`-icount_file`

  Output file for instructions [default sde-icount.txt]

`-icount_norep`

  Count instructions without repeat string iterations [default 0]

`-icount_stderr`

  Attempt to write output to stderr [default 1]