1cpc_event(3CPC) CPU Performance Counters Library Functions cpc_event(3CPC)
2
3
4
6 cpc_event - data structure to describe CPU performance counters
7
9 #include <libcpc.h>
10
11
13 The libcpc interfaces manipulate CPU performance counters using the
14 cpc_event_t data structure. This structure contains several fields that
15 are common to all processors, and some that are processor-dependent.
16 These structures can be declared by a consumer of the API, thus the
17 size and offsets of the fields and the entire data structure are fixed
18 per processor for any particular version of the library. See cpc_ver‐
19 sion(3CPC) for details of library versioning.
20
21 SPARC
22 For UltraSPARC, the structure contains the following members:
23
24 typedef struct {
25 int ce_cpuver;
26 hrtime_t ce_hrt;
27 uint64_t ce_tick;
28 uint64_t ce_pic[2];
29 uint64_t ce_pcr;
30 } cpc_event_t;
31
32
33 x86
34 For Pentium, the structure contains the following members:
35
36 typedef struct {
37 int ce_cpuver;
38 hrtime_t ce_hrt;
39 uint64_t ce_tsc;
40 uint64_t ce_pic[2];
41 uint32_t ce_pes[2];
42 #define ce_cesr ce_pes[0]
43 } cpc_event_t;
44
45
46
47 The APIs are used to manipulate the highly processor-dependent control
48 registers (the ce_pcr, ce_cesr, and ce_pes fields); the programmer is
49 strongly advised not to reference those fields directly in portable
50 code. The ce_pic array elements contain 64-bit accumulated counter val‐
51 ues. The hardware registers are virtualized to 64-bit quantities even
52 though the underlying hardware only supports 32-bits (UltraSPARC) or
53 40-bits (Pentium) before overflow.
54
55
56 The ce_hrt field is a high resolution timestamp taken at the time the
57 counters were sampled by the kernel. This uses the same timebase as
58 gethrtime(3C).
59
60
61 On SPARC V9 machines, the number of cycles spent running on the proces‐
62 sor is computed from samples of the processor-dependent %tick regis‐
63 ter, and placed in the ce_tick field. On Pentium processors, the pro‐
64 cessor-dependent time-stamp counter register is similarly sampled and
65 placed in the ce_tsc field.
66
68 See attributes(5) for descriptions of the following attributes:
69
70
71
72
73 ┌─────────────────────────────┬─────────────────────────────┐
74 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
75 ├─────────────────────────────┼─────────────────────────────┤
76 │Interface Stability │Evolving │
77 └─────────────────────────────┴─────────────────────────────┘
78
80 gethrtime(3C), cpc(3CPC), cpc_version(3CPC), libcpc(3LIB),
81 attributes(5)
82
83
84
85SunOS 5.11 12 May 2003 cpc_event(3CPC)