-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddressStreamDriver.hpp
146 lines (118 loc) · 5.22 KB
/
AddressStreamDriver.hpp
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
/*
* This file is part of the pebil project.
*
* Copyright (c) 2010, University of California Regents
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _AddressStreamDriver_hpp_
#define _AddressStreamDriver_hpp_
#include <set>
#include <cstdint>
class DynamicInstrumentation;
class MemoryStreamHandler;
class SamplingMethod;
class AddressRangeTool;
class CacheSimulationTool;
class ReuseDistanceTool;
class ScatterGatherLengthTool;
class SpatialLocalityTool;
template <class T> class DataManager;
template <class T, class V> class FastData;
typedef struct AddressStreamStats_s AddressStreamStats;
typedef struct BufferEntry_s BufferEntry;
#define DEFAULT_SAMPLE_ON 1000000
#define DEFAULT_SAMPLE_OFF 10000000
#define DEFAULT_SAMPLE_MAX 0
// Class to hold important variables and functions together
class AddressStreamDriver {
private:
// Are we running these tools?
bool runAddressRange;
bool runCacheSimulation;
bool runHardwarePrefetching;
bool runReuseDistance;
bool runScatterLength;
bool runSpatialLocality;
bool runSpatialLocalityPerMemOp;
// Holds the tools that are being run
std::vector<AddressStreamTool*>* tools = NULL;
uint32_t numMemoryHandlers;
DynamicInstrumentation* dynamicPoints = NULL;
SamplingMethod* sampler = NULL;
DataManager<AddressStreamStats*>* allData = NULL;
FastData<AddressStreamStats*, BufferEntry*>* fastData = NULL;
// set of instrumentation points that add addresses to the buffer
std::set<uint64_t>* liveMemoryAccessInstPointKeys = NULL;
StringParser* parser = NULL;
public:
AddressStreamDriver();
virtual ~AddressStreamDriver();
void CreateFastData(uint64_t capacity);
virtual void CreateSamplingMethod();
void DeleteAllData();
void* FinalizeImage(image_key_t*);
DataManager<AddressStreamStats*>* GetAllData() { return allData; }
DynamicInstrumentation* GetDynamicPoints() { return dynamicPoints; }
FastData<AddressStreamStats*, BufferEntry*>* GetFastData() {
return fastData; }
std::set<uint64_t>* GetLiveInstKeys() { return
liveMemoryAccessInstPointKeys; }
SamplingMethod* GetSamplingMethod() { return sampler; }
StringParser* GetStringParser() { return parser; }
uint32_t GetNumMemoryHandlers() { return numMemoryHandlers; }
uint32_t GetNumTools() { return tools->size(); }
AddressStreamTool* GetTool(uint32_t index);
bool HasLiveInstrumentationPoints();
void InitializeAddressStreamDriver(DataManager<AddressStreamStats*>* d);
void InitializeKeys();
void* InitializeNewImage(image_key_t* iid, AddressStreamStats* stats,
ThreadData* threadData);
void* InitializeNewThread(thread_key_t tid);
virtual void InitializeStatsWithNewHandlers(AddressStreamStats* stats);
virtual void InitializeStatsWithNewStreamStats(AddressStreamStats* stats);
bool IsAddressRange() { return runAddressRange; }
bool IsCacheSimulation() { return runCacheSimulation; }
bool IsHardwarePrefetching() { return runHardwarePrefetching; }
bool IsReuseDistance() { return runReuseDistance; }
bool IsScatterLength() { return runScatterLength; }
bool IsSpatialLocality() { return runSpatialLocality; }
bool IsSpatialLocalityPerMemOp() { return runSpatialLocalityPerMemOp; }
uint64_t ProcessBufferForEachHandler(image_key_t iid, thread_key_t tid,
uint32_t numElementsInBuffer);
void* ProcessThreadBuffer(image_key_t iid, thread_key_t tid);
void SetFastData(FastData<AddressStreamStats*, BufferEntry*>* f) {
fastData = f; }
void SetDynamicPoints(DynamicInstrumentation* d) { dynamicPoints = d; }
virtual void SetUpTools();
void ShutOffInstrumentationInAllBlocks();
void ShutOffInstrumentationInBlock(uint64_t blockID, uint64_t imageSeq);
void ShutOffInstrumentationInBlocks(std::set<uint64_t>& blocks, image_key_t
iid);
void ShutOffInstrumentationInMaxedGroups(image_key_t, thread_key_t);
// For Testing Purposes
void AddTool(AddressStreamTool* t) { tools->push_back(t); }
void SetAddressRange(bool b) { runAddressRange = b; }
void SetCacheSimulation(bool b) { runCacheSimulation = b; }
void SetHardwarePrefetching(bool b) { runHardwarePrefetching = b; }
void SetReuseDistance(bool b) { runReuseDistance = b; }
void SetScatterLength(bool b) { runScatterLength = b; }
void SetSpatialLocality(bool b) { runSpatialLocality = b; }
void SetNumMemoryHandlers(uint32_t n) { numMemoryHandlers = n; }
void SetParser(StringParser* p);
void SetSampler(SamplingMethod* s);
};
void GetBufferIds(BufferEntry* b, image_key_t* i);
#endif /* _AddressStreamDriver_cpp_ */