stats.h
5.68 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
* 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.
*
*/
#ifndef STATS_H
#define STATS_H
#ifndef _LANGUAGE_ASSEMBLY
#include <stdio.h>
#include "syslimits.h"
#endif
#ifdef GONE_CLEANUP
#define GET_CACHE
/* This gets information on the QC performance (if in page mode) */
/* #define GET_QC*/
/* This flag controls whether we monitor register usage */
/*#define GET_REG_USAGE*/
/* This flag controls whether we tabulate basic block info */
/* #define BB_HISTOGRAM */
#endif
#define STAT_TIMER_START(x) (hw_counter_start(&(em_stats.x)))
#define STAT_TIMER_STOP(x) (hw_counter_stop(&(em_stats.x)))
#define STAT_TIMER_RESET(x) (hw_counter_reset(&(em_stats.x)))
#define STAT_INC(x) ((em_stats.x)++)
#define STAT_DEC(x) ((em_stats.x)--)
#define STAT_INC_BY(x,_step) ((em_stats.x)+=_step)
#define STAT_EXC(_name,_code,_utlb) ((em_stats._name[_utlb][_code]++))
#ifdef GET_QC
#define STAT_VQC(_sel) (VQC_INST(_sel)?(em_stats.vqc_i_misses)++:((VQC_EXCL(_sel)?(em_stats.vqc_d_excl_misses)++:(em_stats.vqc_d_shared_misses)++)))
#define STAT_PQC(_sel) (VQC_INST(_sel)?(em_stats.pqc_i_misses)++:((VQC_EXCL(_sel)?(em_stats.pqc_d_excl_misses)++:(em_stats.pqc_d_shared_misses)++)))
#else
#define STAT_VQC(_sel)
#define STAT_PQC(_sel)
#endif
#ifdef GET_CACHE
/* Simple increment */
#define CACHE_SINC(_cpuNum, _mode, _label) (em_cache_info[_mode][_cpuNum]._label)++
#define CACHE_INC(_cpuNum, _mode, _I, _D, _state) {if(VQC_INST(_state)) { (em_cache_info[_mode][_cpuNum]._I)++;} else {(em_cache_info[_mode][_cpuNum]._D)++;}}
#define CACHE_INC_BY(_cpuNum, _mode, _I, _D, _state,_step) {if(VQC_INST(_state)) { (em_cache_info[_mode][_cpuNum]._I)+=_step;} else {(em_cache_info[_mode][_cpuNum]._D)+=_step;}}
#else
#define CACHE_SINC(_cpuNum, _mode, _label)
#define CACHE_INC(_cpuNum, _mode, _I, _D, _state)
#define CACHE_INC_BY(_cpuNum, _mode, _I, _D, _state,_step)
#endif
#ifdef GET_REG_USAGE
#define STAT_INC_REG_USE(x) (em_stats.reg_usage[x]++)
#else
#define STAT_INC_REG_USE(x)
#endif
#ifdef BB_HISTOGRAM
#define STAT_BB_SIZE(_sz) (((_sz)<640)?em_stats.bb_sizes[(unsigned)(_sz)>>6]++:\
em_stats.bb_sizes[9]++)
#define STAT_DEC_BB_SIZE(_sz) (((_sz)<40)?\
em_stats.dec_bb_sizes[(uint)(_sz)>>2]++:em_stats.dec_bb_sizes[9]++)
#else
#define STAT_BB_SIZE(x)
#define STAT_DEC_BB_SIZE(_sz)
#endif
#ifndef _LANGUAGE_ASSEMBLY
/* This provides an interface to the SGI memory mapped counter. */
/* 32 bit wrapping is detected and corrected */
typedef struct {
uint64 current;
uint64 ticks;
int on;
} HW_counter;
/* These return int so they can be used as part of a conditional */
/* expression. As seen in stats.h the conditional expression checks */
/* to see if we are on an R_4000 where this service is available */
int hw_counter_start( HW_counter* count );
int hw_counter_stop( HW_counter* count );
int hw_counter_reset( HW_counter* count );
typedef struct {
/* TC stuff */
int tc_flushes;
/*int kern_tc_flushes;*/
int tc_filled;
int kern_cacheflush_tc_flush;
int kern_ID_cacheflush;
int kern_I_cacheflush;
int kern_D_cacheflush;
/* Translator Stuff */
int translations;
int trans_instrs;
/* PC_TC stuff */
int pc_tc_insert;
int pc_tc_conflicts;
int pc_tc_lookup;
int ne_pc_tc_lookup;
int pc_tc_lookup_misses;
int ne_pc_tc_lookup_misses;
int pc_tc_bdoor_misses;
int kern_pc_tc_insert;
int kern_pc_tc_conflicts;
int kern_pc_tc_lookup;
int kern_pc_tc_lookup_misses;
/* QC stats */
int64 vqc_i_misses;
int64 vqc_d_excl_misses;
int64 vqc_d_shared_misses;
int64 pqc_i_misses;
int64 pqc_d_excl_misses;
int64 pqc_d_shared_misses;
/* Backdoor */
int backdoor_calls;
int64 backdoor_ref;
int64 backdoor_unaltered_ref;
/* Exceptions */
int exceptions;
int exception_type[2][41];
int raised_clock_bit; /*Could see if any are being dropped by
checking against an annotation set at clock */
/* icache coherence */
int icache_coherence;
/* Chaining Stats */
uint chain_invocations;
uint chain_bounced;
uint chain_known_chains;
uint chain_spec_chains;
uint chain_samepg_chains;
uint chain_user_chains;
uint chain_sameln_chains;
/* Timers */
HW_counter trans_timer;
/* Translated Basic Block Sizes */
int bb_sizes[10];
/* Decoded Basic Block Sizes */
int dec_bb_sizes[10];
/* Register usage (number of regs used in a BB)*/
/* 33 because 0 to 32 (inclusive) registers can be used */
int reg_usage[33];
}stats_t;
/* Cache Info Unit */
typedef uint64 ci_u;
typedef struct {
ci_u pc_sample; /* PC sampling for time */
/* Cache */
ci_u i_stall_cyc; /* I Stall */
ci_u d_stall_cyc; /* D Stall */
/* This information only used to Sanity Check */
ci_u i_miss; /* number of times miss in cache simulator */
ci_u d_miss; /* number of times miss in cache simulator */
ci_u instr_count; /* Number of executed instructions */
ci_u data_refs; /* Total number of memory references */
ci_u upgrades; /* Total number of upgrades */
ci_u upgd_inval; /* Total number of upgrades w/ invalidation*/
/*int cache_conflict;*/
}cache_info_t;
extern stats_t em_stats;
extern SimTime EmbraCpuInstrCount(int cpuNum);
extern void Stat_Init( void );
extern void Print_Recent_Stats( int cpuNum );
extern void Print_Total_Stats( void );
#ifdef gone
extern void Embra_Change_Mode_Actions( int cpuNum, CPUMode prev_mode );
#endif
extern void Dump_QC_Counters (int cpuNum);
extern SimTime EmbraInstrCount(void);
extern double EmbraTimeDiff(void);
#endif /* _LANGUAGE_ASSEMBLY */
#endif /* STATS_H */