Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added warmup #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions OHRgoal/PFOO-L/lib/parse_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,39 @@
#include <map>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include "parse_trace.h"

void parseTraceFile(std::vector<trEntry> & trace, std::string & path) {
void parseTraceFile(std::vector<trEntry> & trace, std::string & path, uint64_t warmup) {
std::ifstream traceFile(path);

uint64_t time, id, size, reqc=0;
uint64_t count = 0;
uint64_t count2 = 0;
std::unordered_map<std::pair<uint64_t, uint64_t>, uint64_t> lastSeen;
std::unordered_set<std::pair<uint64_t, uint64_t>> warmup_objs;

while(traceFile >> time >> id >> size) {
const auto idsize = std::make_pair(id,size);
if(size > 0 && lastSeen.count(idsize)>0) {
trace[lastSeen[idsize]].hasNext = true;
count++;
const auto idsize = std::make_pair(id,size);
if (count < warmup && size > 0) {
warmup_objs.insert(idsize);
continue;
}
count2++;
trace.emplace_back(size);
if(size > 0 && lastSeen.count(idsize)==0 && warmup_objs.count(idsize)>0) {
trace[reqc].hasNext = true;
const uint64_t volume = (reqc-0) * size;
trace[reqc].volume = volume;
} else if(size > 0 && lastSeen.count(idsize)>0) {
trace[lastSeen[idsize]].hasNext = true;
const uint64_t volume = (reqc-lastSeen[idsize]) * size;
trace[lastSeen[idsize]].volume = volume;
}
trace.emplace_back(size);
lastSeen[idsize]=reqc++;
}
std::cerr << "total requests: " << count << " after warmup: " << count2 << "\n";
}
2 changes: 1 addition & 1 deletion OHRgoal/PFOO-L/lib/parse_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ struct trEntry {
};
};

void parseTraceFile(std::vector<trEntry> & trace, std::string & path);
void parseTraceFile(std::vector<trEntry> & trace, std::string & path, uint64_t warmup);
2 changes: 1 addition & 1 deletion OHRgoal/PFOO-L/lib/solve_mcf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void printRes(std::vector<trEntry> & trace, std::string algName, uint64_t cacheS
}
// fill in the gaps (if the cache fits the whole trace)
// keep outputting the last hit count (as trace is too short)
while(nextCsizePrint < lcacheSizeMax) {
while(nextCsizePrint <= lcacheSizeMax) {
std::cerr << "filling in gaps, trace too short\n";
*resultfile << algName << " " << nextCsizePrint << " " << hitc << " " << trace.size() << " " << (double)hitc/trace.size() << " " << csize << " " << reqcDiff << "\n";
nextCsizePrint*=2;
Expand Down
Binary file added OHRgoal/PFOO-L/pfool
Binary file not shown.
7 changes: 4 additions & 3 deletions OHRgoal/PFOO-L/pfool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@

int main(int argc, char* argv[]) {

if (argc != 4) {
std::cerr << argv[0] << " traceFile cacheSizeMax resultPath" << std::endl;
if (argc != 5) {
std::cerr << argv[0] << " traceFile cacheSizeMax resultPath warmup" << std::endl;
return 1;
}

std::cerr << "start up\n";
std::string path(argv[1]);
uint64_t cacheSizeMax(std::stoull(argv[2]));
std::string resultPath(argv[3]);
uint64_t warmup(std::stoull(argv[4]));
std::ofstream * resultFile = new std::ofstream(resultPath);

// parse trace file
std::vector<trEntry> trace;
parseTraceFile(trace, path);
parseTraceFile(trace, path, warmup);
std::cerr << "parsed up\n";

cacheAlg(trace);
Expand Down