cpu_stats.h
4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* Copyright (C) 1996-1998 by the Board of Trustees
* of Leland Stanford Junior University.
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
/****************************************************************
* stats.h
*
* Definitions and macros for the general cpu statistics collection.
* The goal is for this to hook up to visualization engines easily.
*
* Author: $author$
* Date: $date$
****************************************************************/
#ifndef CPU_STATS_H
#define CPU_STATS_H
#include "simtypes.h"
/* Exported functions */
extern void InitCPUStats(void);
extern void ResetCPUStats(void);
extern void PrintPeriodicCPUStats(void);
extern void PrintAllCPUStats(void);
#define SPIN_LOOP_INST 35
#define STAT_INTERVAL (1024*1024*4)
#define MAX_SYSCALL 181
#define MAX_UTLB_CAUSE 4
#define MAX_CAUSE 75
#ifdef NO_STATS
# define STATS_INC(_cpu, _var, _count)
# define STATS_SET(_cpu, _var, _value)
# define STATS_VALUE(_cpu, _var) 0
# define STATS_ADD_INTERVAL(_cpu, _var, _startVar)
#else
#define STATS_INC(_cpu, _var, _count) cpuStats[(_cpu)]._var += _count;
#define STATS_SET(_cpu, _var, _value) cpuStats[(_cpu)]._var = _value;
#define STATS_VALUE(_cpu, _var) (cpuStats[(_cpu)]._var)
#define STATS_ADD_INTERVAL(_cpu, _var, _startVar) \
{ if (cpuStats[(_cpu)]._startVar) { \
cpuStats[(_cpu)]._var += (CPUVec.CycleCount(_cpu) - STATS_VALUE(_cpu, _startVar)); \
cpuStats[(_cpu)]._startVar = 0; \
} \
}
#endif
typedef struct CPUStats {
/* Stats */
SimCounter iReads;
SimCounter dReads;
SimCounter dWrites;
SimTime stallStart;
SimCounter stallTime;
SimCounter numInstructions; /* Number of instruction executed */
SimTime nextInstrSample; /* When to sample the PC next */
SimTime syncOpStallStart; /* Start time of sync op */
SimTime syncOpStallTime; /* Total time spent waiting for the sync op */
SimTime syncStallStart;
SimTime syncStallTime;
SimTime prefMHTStallStart;
SimTime writeMHTStallStart;
SimTime libcWaitStart;
SimTime libcWaitTime;
SimTime haltedTime; /* Just in SOLO - time before CREATE */
uint numSyscalls;
uint numFaults;
uint numInterrupts;
SimCounter numBdoorInsts;
SimCounter numFPOps;
SimCounter syscallCount[MAX_SYSCALL];
SimCounter causeCount[MAX_CAUSE];
SimCounter utlbCount[MAX_UTLB_CAUSE];
SimCounter syncOps;
struct {
SimCounter lls; /* Number of LL */
SimCounter llNonZero; /* Number of LL returned non zero */
SimCounter llStallTime; /* LL stall time*/
SimCounter scs; /* Number of SC */
SimCounter scFailed; /* Number failed SC */
SimCounter scStallTime; /* Stall time on sc in cycles*/
SimCounter llscConflictSuccess;
SimCounter syncs; /* Number of SYNCs */
SimCounter syncStallTime; /* Time stalled on SYNCs */
SimCounter locks; /* Number of Locks */
SimCounter lockStallTime; /* Time stalled on locks */
SimCounter barriers; /* Number of barriers */
SimCounter barrierStallTime; /* Time stalled on barriers */
SimCounter waitForCount; /* Number of WAIT_FOR_END calls */
SimCounter waitForStallTime; /* Time stalled in WAIT_FOR_END */
} syncStats;
struct {
SimCounter prefs; /* Number of prefetches */
SimCounter prefXs; /* Number of prefetch exclusives */
SimCounter prefTLBMisses;
SimCounter prefXTLBMisses;
SimCounter prefL1Hits;
SimCounter prefXL1Hits;
SimCounter prefL2Hits;
SimCounter prefXL2Hits;
SimCounter prefStalls;
SimCounter prefXStalls;
SimCounter prefMerges;
SimCounter prefXMerges;
SimCounter prefFails;
SimCounter prefXFails;
SimCounter prefMHTStall;
SimCounter prefXMHTStall;
SimCounter prefMHTStallTime;
SimCounter prefXMHTStallTime;
SimCounter prefUpgrades;
SimCounter prefXUpgrades;
} prefStats;
struct {
SimCounter writeMHTStall;
SimCounter writeMHTStallTime;
} writeBufferStats;
} CPUStats;
extern CPUStats *cpuStats;
#endif