Hardware performance counter

From Wikipedia, the free encyclopedia

In computers, hardware performance counters, or hardware counters are a set of special-purpose registers built in modern microprocessors to store the counts of hardware-related activities within computer systems. Advanced users often rely on those counters to conduct low-level performance analysis or tuning.

The number of available hardware counters in a processor is often quite limited. The following table shows some examples:

Processor available HW counters
UltraSparc II 2
Pentium III 2
AMD Athlon 4
IA-64 4
POWER4 8
Pentium 4 18

Compared to software profilers, hardware counters provide low-overhead access to a wealth of detailed performance information related to CPU's function units, caches and main memory etc. Another benefit of using them is that no source code modifications are needed in general. However, the types and meanings of hardware counters vary from one kind of architecture to another due to the variation in hardware organizations. Also, it is difficult to correlate the low level performance metrics back to source code. The limited number of registers to store the counters often force users to conduct multiple measurements to collect all desired performance metrics.

Languages