diff --git a/OHRgoal/PFOO-L/lib/parse_trace.cpp b/OHRgoal/PFOO-L/lib/parse_trace.cpp index 3b9da69..1171a5d 100644 --- a/OHRgoal/PFOO-L/lib/parse_trace.cpp +++ b/OHRgoal/PFOO-L/lib/parse_trace.cpp @@ -3,24 +3,39 @@ #include #include #include +#include #include #include #include "parse_trace.h" -void parseTraceFile(std::vector & trace, std::string & path) { +void parseTraceFile(std::vector & 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, uint64_t> lastSeen; + std::unordered_set> 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"; } diff --git a/OHRgoal/PFOO-L/lib/parse_trace.h b/OHRgoal/PFOO-L/lib/parse_trace.h index 36f4593..07d7fa2 100644 --- a/OHRgoal/PFOO-L/lib/parse_trace.h +++ b/OHRgoal/PFOO-L/lib/parse_trace.h @@ -35,4 +35,4 @@ struct trEntry { }; }; -void parseTraceFile(std::vector & trace, std::string & path); +void parseTraceFile(std::vector & trace, std::string & path, uint64_t warmup); diff --git a/OHRgoal/PFOO-L/lib/solve_mcf.cpp b/OHRgoal/PFOO-L/lib/solve_mcf.cpp index a6972c4..b3efe0a 100644 --- a/OHRgoal/PFOO-L/lib/solve_mcf.cpp +++ b/OHRgoal/PFOO-L/lib/solve_mcf.cpp @@ -33,7 +33,7 @@ void printRes(std::vector & 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; diff --git a/OHRgoal/PFOO-L/pfool b/OHRgoal/PFOO-L/pfool new file mode 100755 index 0000000..6399380 Binary files /dev/null and b/OHRgoal/PFOO-L/pfool differ diff --git a/OHRgoal/PFOO-L/pfool.cpp b/OHRgoal/PFOO-L/pfool.cpp index 8dea48c..6b56f94 100644 --- a/OHRgoal/PFOO-L/pfool.cpp +++ b/OHRgoal/PFOO-L/pfool.cpp @@ -9,8 +9,8 @@ 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; } @@ -18,11 +18,12 @@ int main(int argc, char* argv[]) { 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 trace; - parseTraceFile(trace, path); + parseTraceFile(trace, path, warmup); std::cerr << "parsed up\n"; cacheAlg(trace);