Page 168 - DCAP210_INTRODUCTION__TO_MICROPROCESSORS
P. 168
Introduction to Microprocessors
Notes Adding 1 more means we have to zero out col 1 and add 1 to col 2. However, this makes col 2 =
F+1. So we have also to zero out col 2 and add 1 to col 3
Performance Analysis and Monitoring Using Hardware Counters
he UltraSPARC and Pentium microprocessors contain hardware performance counters
that allow counting a series of processor events, such as cache misses, pipeline stalls
Tand floating-point operations. Statistics of processor events can be collected in hardware
with little or no overhead, making these counters a powerful means to monitor an application
and analyze its performance. Such counters, to their advantage, are non-intrusive, do not to
require recompilation of applications and are available in every UltraSPARC-based system
that Sun Microsystems currently ships. Nonetheless, these counters are not widely used beyond
hardware specialists because of the lack of programming interfaces and sparse documentation.
Starting with release 8 of the Solaris OE, there is an increasing support of hardware counters,
with the availability of utility tools and public programming interfaces. This support for
hardware counters at the operating system level is a major milestone for the Solaris software
developer community but is not a direct answer to its needs. Application programmers work
at a higher level where the common metrics are a combination of the low-level event counts
accumulated in hardware. There is a need for higher-level tools that hide the complexity of
the underlying hardware design and present in a uniform manner the common metrics the
programmers expect: million instructions per second (MIPS), floating-point operations per
second (FLOPS), cache miss rate.
In this study, the Solaris 8 platform’s support for hardware performance counters is covered,
and a tool, the Hardware Activity Reporter that builds on the new Solaris interfaces and aims
to address the needs of application programmers is introduced.
Solaris 8 OE Support for Hardware Performance Counters
In February 2000, Sun Microsystems announced a new release of the Solaris Operating
Environment, Solaris 8. With the latest release of Solaris 8 OE, Sun began to deliver public
interfaces to the UltraSPARC and Pentium hardware performance counters. A series of
application programming interfaces (APIs) have been made available as shared libraries, to
program various hardware counters and the utility tools cpustat and cputrack to access the
microprocessor (CPU) hardware counters from the command line. The Solaris 8 platform
also provides similar libraries and tools to access the hardware counters of the system bus
and I/O boards.
Solaris 8 OE Libraries
Solaris 8 software ships with two libraries directly related to the usage of the CPU performance
counters: libcpc, to access CPU counters and libpctx, to track a process. Using these APIs, one
can instrument code to access the performance hardware counters and collect performance
information. The steps to instrument a piece of code are:
1. Check the versions and accessibility of the hardware performance counters with
cpc_version() and cpc_access();
2. Initialize a cpc_event_t data structure, using cpc_getcpuver() and cpc_strtoevent(), to be
used in conjunction with the counters;
3. Bind the data structure to the CPU using cpc_bind_event();
Contd...
162 LOVELY PROFESSIONAL UNIVERSITY