34
votes

In the Intel Manual, there is mention of a lot of performance events which have descriptions like "Mispredicted taken branch instructions retired.". What exactly does retired mean in this context?

Note that I have already looked at Intel's Performance Analysis Guide, which states that "retired" has a very precise meaning (on page 8), referring to the diagram on page 7, but I think I lack the background knowledge to understand exactly what is mean by Retirement / Writeback. What exactly is that process and what does it involve?

1
"Mispredicted taken branch instructions retired." means that there was some number of branches, every branch was translated to the microoperation and dispatched to the corresponding execution unit; some of them were predicted as "taken", some as "not taken", but the prediction was wrong (misprediction). The branch was "taken" (predicted as not-taken, penalty around 15-17 cycles) and it was the real branch (not speculation), because it arrives and leaves the retirement unit. Even if the branch instruction was "not taken" in real life, it still uses execution unit and, and will be retired (hmm).osgx
@osgx The performance guide implies the mispredicted branch instructions are not retired because retirement is only for correct instructions? I really am confused...user997112

1 Answers

41
votes

In the context "retired" means: the instruction (microoperation, μop) leaves the "Retirement Unit". It means that in Out-of-order CPU pipeline the instruction is finally executed and its results are correct and visible in the architectural state as if they execute in-order. In performance context this is the number you should check to compute how many instructions were really executed (with useful output). If your context is energy saving, you may check how many instructions started their execution in OOO pipeline ("ISSUED" counter or "EXECUTED" counter) and compare the number with count of retired operation; high difference shows that CPU does a lot of useless work and uses excess power.

Short description of the Retirement unit is here: http://users.utcluj.ro/~baruch/book_ssce/SSCE-Intel-Pipeline.pdf

5.4.7.4. Retirement Unit

The retirement unit writes the results of speculatively executed microoperations into the user-visible registers and removes the microoperations from the reorder buffer. Like the reservation station, the retirement unit continuously checks the status of microoperations in the reorder buffer, looking for ones that have been executed and no longer have any dependencies with other microoperations in the instruction pool. It then retires completed microoperations in their original program order.

The retirement unit can retire three microoperations per clock cycle (/<-- this may be outdated/). In retiring a microoperation, it writes the results to the processor’s register file and/or memory. After the results have been written, the microoperation is removed from the re-order buffer.

More detailed information about unit is here (by Agner Fog) http://www.agner.org/optimize/microarchitecture.pdf chapter Retirement for your CPU