-
Notifications
You must be signed in to change notification settings - Fork 0
/
meamviz.h
69 lines (62 loc) · 1.82 KB
/
meamviz.h
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
//
// Author: _mee_
// GHUB: meetesh06
//
#pragma once
#include <string>
#include <fstream>
#include <iostream>
#include "memory_class.h"
class MeamViz {
public:
MeamViz(std::string path) {
logFile.open(path, std::ios::out);
if (!logFile){
std::cout<<"Unable to open the logfile!!" << std::endl;
exit(1);
}
logFile << "CYCLE, EVENT_NAME, CACHE_NAME, ADDR, IP, CACHE_HIT, TYPE" << std::endl;
}
void logCachePrefetchEvent(
const uint64_t & currentCycle, const std::string & cacheName,
const uint64_t & addr
) {
logFile << currentCycle << ",";
logFile << "PREFETCH_SUCCESS" << ",";
logFile << cacheName << ",";
logFile << addr << ",";
logFile << 0 << ",";
logFile << 0 << ",";
logFile << 0 << std::endl;
}
void logCacheOperateEvent(
const uint64_t & currentCycle, const std::string & cacheName,
const uint64_t & addr, const uint64_t & ip, const uint8_t & cache_hit,
const uint8_t & type) {
logFile << currentCycle << ",";
logFile << "CACHE_OPERATE" << ",";
logFile << cacheName << ",";
logFile << addr << ",";
logFile << ip << ",";
logFile << std::to_string(cache_hit) << ",";
logFile << getCacheEventTypeString(type) << std::endl;
}
~MeamViz() {
std::cout << "Logger End" << std::endl;
logFile.close(); }
private:
std::fstream logFile;
std::string getCacheEventTypeString(const uint8_t & type) {
switch (type)
{
case LOAD: return std::string("LOAD");
case RFO: return std::string("RFO");
case PREFETCH: return std::string("PREFETCH");
case WRITEBACK: return std::string("WRITEBACK");
case TRANSLATION: return std::string("TRANSLATION");
case NUM_TYPES: return std::string("NUM_TYPES");
default:
return std::string("UKN");
}
}
};