-
Notifications
You must be signed in to change notification settings - Fork 16
/
SMPCache.cpp
72 lines (57 loc) · 2.33 KB
/
SMPCache.cpp
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
#include "SMPCache.h"
SMPCache::SMPCache(int cpuid, std::vector<SMPCache * > * cacheVector){
CPUId = cpuid;
allCaches = cacheVector;
numReadHits = 0;
numReadMisses = 0;
numReadOnInvalidMisses = 0;
numReadRequestsSent = 0;
numReadMissesServicedByOthers = 0;
numReadMissesServicedByShared = 0;
numReadMissesServicedByModified = 0;
numWriteHits = 0;
numWriteMisses = 0;
numWriteOnSharedMisses = 0;
numWriteOnInvalidMisses = 0;
numInvalidatesSent = 0;
}
void SMPCache::conciseDumpStatsToFile(FILE* outFile){
fprintf(outFile,"%lu,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
CPUId,
numReadHits,
numReadMisses,
numReadOnInvalidMisses,
numReadRequestsSent,
numReadMissesServicedByOthers,
numReadMissesServicedByShared,
numReadMissesServicedByModified,
numWriteHits,
numWriteMisses,
numWriteOnSharedMisses,
numWriteOnInvalidMisses,
numInvalidatesSent);
}
void SMPCache::dumpStatsToFile(FILE* outFile){
fprintf(outFile, "-----Cache %lu-----\n",CPUId);
fprintf(outFile, "Read Hits: %d\n",numReadHits);
fprintf(outFile, "Read Misses: %d\n",numReadMisses);
fprintf(outFile, "Read-On-Invalid Misses: %d\n",numReadOnInvalidMisses);
fprintf(outFile, "Read Requests Sent: %d\n",numReadRequestsSent);
fprintf(outFile, "Rd Misses Serviced Remotely: %d\n",numReadMissesServicedByOthers);
fprintf(outFile, "Rd Misses Serviced by Shared: %d\n",numReadMissesServicedByShared);
fprintf(outFile, "Rd Misses Serviced by Modified: %d\n",numReadMissesServicedByModified);
fprintf(outFile, "Write Hits: %d\n",numWriteHits);
fprintf(outFile, "Write Misses: %d\n",numWriteMisses);
fprintf(outFile, "Write-On-Shared Misses: %d\n",numWriteOnSharedMisses);
fprintf(outFile, "Write-On-Invalid Misses: %d\n",numWriteOnInvalidMisses);
fprintf(outFile, "Invalidates Sent: %d\n",numInvalidatesSent);
}
int SMPCache::getCPUId(){
return CPUId;
}
int SMPCache::getStateAsInt(unsigned long addr){
return (int)this->cache->findLine(addr)->getState();
}
std::vector<SMPCache * > *SMPCache::getCacheVector(){
return allCaches;
}