statrecord.h
6.57 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
/*
* 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.
*
*/
/**************************************************************
* statrecord.h
* Management of the MemStat counters and the detailed (byPC,byData)
* data structures.
*
* ************************************************************/
#ifndef STAT_RECORD_H
#define STAT_RECORD_H
#include <stdio.h>
#include "simtypes.h"
typedef struct StatRecordBucket StatRecordBucket;
typedef struct StatRecordSwitch StatRecordSwitch;
typedef struct StatRecordDetail StatRecordDetail;
typedef struct StatRecordSnapshot StatRecordSnapshot;
typedef struct StatRecordFieldDescStruct *StatRecordFieldDesc;
extern void StatRecordEarlyInit(void);
extern void StatRecordLateInit(void);
/* ******************************************************************
* StatRecordBucket. Allocation and Field definition
* ******************************************************************/
#define STATRECORD_INSTRUCTION (1<<0)
#define STATRECORD_DATA (1<<1)
extern StatRecordBucket *StatRecordNewBucket(void);
extern void StatRecordFreeBucket(StatRecordBucket *bucket);
extern StatRecordFieldDesc StatRecordDefineField(char *field, int instr_data);
/* *******************************************************************
* Incrementors: use either the current switches or the snapshoted switches
* ******************************************************************/
extern void StatRecordEntry(int cpuNum, VA PC, VA vAddr,
StatRecordFieldDesc field, int inc);
extern void StatRecordIncrement(StatRecordSnapshot *cur, VA PC, VA vAddr,
StatRecordFieldDesc field, int inc);
/* ****************************************************************
* Control switches
* Once a switch has been instantiated, associated MemStatBuckets can
* can be freely set and changed independently for the different cpus.
* ****************************************************************/
extern StatRecordSwitch *StatRecordNewSwitch(char *name);
extern void StatRecordSetSwitch(StatRecordSwitch *s, int cpuNum,
StatRecordBucket *newBucket);
/* *****************************************************************
* Detailed breakdowns.
* A detailed breakdown is specified by its name, byPC or byData,
* the selected fields and the selected areas of detail.
* Fields and areas of detail cannot be added once the simulation
* has started. The recording of the stats can be selectively
* turned on/off for each CPU. This must be done explicitely
* for each CPU if this is wanted.
* *****************************************************************/
extern StatRecordDetail *StatRecordNewDetail(char *fileName,
int isByPC,
int counterSize,
int lowRes,
int highRes);
extern void StatRecordDetailAddField(StatRecordDetail *detail,
int pos, char *fieldName);
extern void StatRecordDetailHighResRange(StatRecordDetail *detail,
VA addr, uint len);
extern void StatRecordDetailSetActive(StatRecordDetail *detail,
int cpuNum,bool active);
extern void StatRecordDetailDump(StatRecordDetail *detail, int fd, int reset);
extern int StatRecordDetailNumCounters(StatRecordDetail *detail);
extern void* StatRecordDetailBucketAddr(StatRecordDetail *detail, VA addr);
extern int64 StatRecordDetailCounterByIndex(StatRecordDetail *detail,
void *bucketPtr, uint index);
extern int64 StatRecordDetailCounterByField(StatRecordDetail *detail,
void *bucketPtr, char *fieldName);
extern int StatRecordDetailTableOK(StatRecordDetail *detail);
/* *****************************************************************
* Snapshots
* Certain stats cannot be classified exactly at the time of the event
* that we are associated it with, but rather only at a later point,
* for example when the line is evicted from the cache.
* In order to remember the state at the time of the event,
* a snapshot of the switches is taken that can be used to direct
* the recording.
* *****************************************************************/
extern StatRecordSnapshot *StatRecordAllocSnapshot(int cpuNum);
extern void StatRecordFreeSnapshot(StatRecordSnapshot *);
/* *******************************************************************
* StatRecordTransferBucket.
* This does 3 things: (1) increment the final bucket by the values of the
* temporary bucket (2) Redirect the snapshots that refered to the temporary
* bucket (for the given switch) to the main bucket (3) clear the temproray
* bucket
* ********************************************************************/
extern void StatRecordTransferBucket(StatRecordSwitch *sw,
StatRecordBucket *tmpBucket,
StatRecordBucket *finalBucket);
/* ****************************************************************
* StatRecordDisableCPU
* ****************************************************************/
extern void StatRecordDisableCPU(int cpuNum);
/* ****************************************************************
* Utility functions. Operations on StatRecordBucket
* ****************************************************************/
extern void StatRecordDumpBucket(char *tag, StatRecordBucket *bp, char *lead);
extern void StatRecordDumpFields(void);
extern void StatRecordInc(StatRecordBucket *a,StatRecordBucket *b);
extern void StatRecordComputeMin(StatRecordBucket *min, StatRecordBucket *a);
extern void StatRecordComputeMax(StatRecordBucket *max, StatRecordBucket *a);
extern void StatRecordZero(StatRecordBucket *b);
extern void StatRecordCopy(StatRecordBucket *src, StatRecordBucket *dst);
extern int64 StatRecordFieldValue(StatRecordBucket *b, char *field);
extern int64 StatRecordFieldValueByIndex(StatRecordBucket *b, unsigned index);
extern int StatRecordNumFields(void);
extern char* StatRecordGetFieldName(unsigned index);
extern int StatRecordDetailNumFields(StatRecordDetail *detail);
extern char* StatRecordDetailGetFieldName(StatRecordDetail *detail, unsigned index);
/* this is just temoporary. Needed for modesstats hacks */
extern int StatRecordBucketSize(void);
#endif /* STAT_RECORD_H */