From a0227b2a6005f15cf12fbb9406c7c8a3b1b0458b Mon Sep 17 00:00:00 2001 From: "Thanh C. Tran" Date: Wed, 8 Mar 2017 23:50:19 +0100 Subject: [PATCH] Remove unnecessary functions, keep it simple for testing # Explain what has been changed # Explain why this change is being made # Provide links to any relevant tickets, articles or other resources --- .../src/controller/scheduler/ReadyBatch.cpp | 38 +++--- .../src/controller/scheduler/ReadyBatch.h | 4 +- .../src/controller/scheduler/SMS.cpp | 109 ++++++++---------- .../simulator/src/controller/scheduler/SMS.h | 14 +-- 4 files changed, 75 insertions(+), 90 deletions(-) diff --git a/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.cpp b/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.cpp index 2200a6f4..91aa48db 100644 --- a/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.cpp +++ b/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.cpp @@ -6,35 +6,35 @@ ReadyBatch::ReadyBatch() thresholdAge = sc_time(Configuration::getInstance().ReadyBatchThresholdAge, SC_NS); } -unsigned int ReadyBatch::getNumRequests() -{ - return readybatch.size(); -} +//unsigned int ReadyBatch::getNumRequests() +//{ +// return readybatch.size(); +//} Row ReadyBatch::getRow() { return DramExtension::getExtension(readybatch.front()).getRow(); } -sc_time ReadyBatch::getTimeOfOldestRequest() -{ - sc_time oldestTime = sc_time_stamp(); - for (auto reqPayload = readybatch.begin(); reqPayload != readybatch.end(); reqPayload++) - { - sc_time requestTimeOfGeneration = GenerationExtension::getExtension(*reqPayload).TimeOfGeneration(); - if (requestTimeOfGeneration < oldestTime) - { - oldestTime = requestTimeOfGeneration; - } - } - return oldestTime; -} +//sc_time ReadyBatch::getTimeOfOldestRequest() +//{ +// sc_time oldestTime = sc_time_stamp(); +// for (auto reqPayload = readybatch.begin(); reqPayload != readybatch.end(); reqPayload++) +// { +// sc_time requestTimeOfGeneration = GenerationExtension::getExtension(*reqPayload).TimeOfGeneration(); +// if (requestTimeOfGeneration < oldestTime) +// { +// oldestTime = requestTimeOfGeneration; +// } +// } +// return oldestTime; +//} bool ReadyBatch::addTransaction(gp* payload) { - sc_time currentAge = sc_time_stamp() - getTimeOfOldestRequest(); +// sc_time currentAge = sc_time_stamp() - getTimeOfOldestRequest(); Row newRow = DramExtension::getExtension(payload).getRow(); - if (getNumRequests() == fifosize || currentAge >= thresholdAge || newRow != getRow()) { + if (/*getNumRequests() == fifosize || currentAge >= thresholdAge || */newRow != getRow()) { return false; } else { readybatch.emplace_back(payload); diff --git a/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.h b/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.h index 5e2e8f49..c35640a5 100644 --- a/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.h +++ b/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.h @@ -14,7 +14,7 @@ class ReadyBatch public: ReadyBatch(); bool addTransaction(gp* payload); - unsigned int getNumRequests(); +// unsigned int getNumRequests(); std::deque& getTransactions(); bool isEmpty(); private: @@ -23,7 +23,7 @@ private: sc_time thresholdAge; Row getRow(); - sc_time getTimeOfOldestRequest(); +// sc_time getTimeOfOldestRequest(); }; #endif // READYBATCH_H diff --git a/DRAMSys/simulator/src/controller/scheduler/SMS.cpp b/DRAMSys/simulator/src/controller/scheduler/SMS.cpp index 4790edb7..147cea6e 100644 --- a/DRAMSys/simulator/src/controller/scheduler/SMS.cpp +++ b/DRAMSys/simulator/src/controller/scheduler/SMS.cpp @@ -8,13 +8,13 @@ void SMS::schedule(gp *payload) Thread thread = DramExtension::getExtension(payload).getThread(); // update memory request counter - memrequestcounter[thread]++; +// memrequestcounter[thread]++; inFlightMemRequestCounter[thread]++; // update memory request intensity - sc_time lastrequestTimeOfGeneration = GenerationExtension::getExtension(payload).TimeOfGeneration(); - sc_time memClk = Configuration::getInstance().memSpec.clk; - memoryIntensity[thread] = (memrequestcounter[thread] * 1000.0 * memClk) / lastrequestTimeOfGeneration; // in MPKC +// sc_time lastrequestTimeOfGeneration = GenerationExtension::getExtension(payload).TimeOfGeneration(); +// sc_time memClk = Configuration::getInstance().memSpec.clk; +// memoryIntensity[thread] = (memrequestcounter[thread] * 1000.0 * memClk) / lastrequestTimeOfGeneration; // in MPKC } std::pair SMS::getNextRequest(Bank bank) @@ -39,16 +39,16 @@ std::pair SMS::getNextRequest(Bank bank) } -unsigned int SMS::totalMemoryRequests() -{ - //TODO: recheck this? how about total in-flight requests instead? - unsigned int totalSize = 0; - for (auto &reqQueue : buffer) - { - totalSize += reqQueue.second.size(); - } - return totalSize; -} +//unsigned int SMS::totalMemoryRequests() +//{ +// //TODO: recheck this? how about total in-flight requests instead? +// unsigned int totalSize = 0; +// for (auto &reqQueue : buffer) +// { +// totalSize += reqQueue.second.size(); +// } +// return totalSize; +//} bool SMS::batchFormation() { @@ -80,25 +80,10 @@ void SMS::batchScheduler() bool isSJF = (rand() % 100) < SJFprobability; if (!existReadyBatch()) { - if (totalMemoryRequests() == 0) + // pick & drain a ready batch + if (batchFormation()) { - continue; - } - else if (totalMemoryRequests() <= 16 && totalMemoryRequests() > 0) - { - // bypass if system is lightly load - bypassRequests(); - } - else if (totalMemoryRequests() > 16) - { - // bypass low memory intensity thread - bypassLowMemoryIntensity(); - - // pick & drain a ready batch - if (batchFormation()) - { - isSJF ? selectSJF() : selectRR(); - } + isSJF ? selectSJF() : selectRR(); } } else @@ -207,33 +192,33 @@ bool SMS::batchFormation(Thread thread) } } -void SMS::bypassRequests() -{ - for (auto& thread_requests : buffer) - { - for (auto request = thread_requests.second.begin(); request != thread_requests.second.end(); request++) - { - Bank bank = DramExtension::getExtension(*request).getBank(); - bankbuffer[bank].emplace_back(*request); - thread_requests.second.erase(request); - } - } -} - -void SMS::bypassLowMemoryIntensity() -{ - unsigned int totalNumThreads = Configuration::getInstance().NumberOfTracePlayers; - for (unsigned int threadID = 1; threadID <= totalNumThreads; threadID++) - { - if (memoryIntensity[Thread(threadID)] < 1 && memoryIntensity[Thread(threadID)] > 0) - { - for (auto request = buffer[Thread(threadID)].begin(); - request != buffer[Thread(threadID)].end(); request++) - { - Bank bank = DramExtension::getExtension(*request).getBank(); - bankbuffer[bank].emplace_back(*request); - buffer[Thread(threadID)].erase(request); - } - } - } -} +//void SMS::bypassRequests() +//{ +// for (auto& thread_requests : buffer) +// { +// for (auto request = thread_requests.second.begin(); request != thread_requests.second.end(); request++) +// { +// Bank bank = DramExtension::getExtension(*request).getBank(); +// bankbuffer[bank].emplace_back(*request); +// thread_requests.second.erase(request); +// } +// } +//} +// +//void SMS::bypassLowMemoryIntensity() +//{ +// unsigned int totalNumThreads = Configuration::getInstance().NumberOfTracePlayers; +// for (unsigned int threadID = 1; threadID <= totalNumThreads; threadID++) +// { +// if (memoryIntensity[Thread(threadID)] < 1 && memoryIntensity[Thread(threadID)] > 0) +// { +// for (auto request = buffer[Thread(threadID)].begin(); +// request != buffer[Thread(threadID)].end(); request++) +// { +// Bank bank = DramExtension::getExtension(*request).getBank(); +// bankbuffer[bank].emplace_back(*request); +// buffer[Thread(threadID)].erase(request); +// } +// } +// } +//} diff --git a/DRAMSys/simulator/src/controller/scheduler/SMS.h b/DRAMSys/simulator/src/controller/scheduler/SMS.h index 00fe6877..71f7aa96 100644 --- a/DRAMSys/simulator/src/controller/scheduler/SMS.h +++ b/DRAMSys/simulator/src/controller/scheduler/SMS.h @@ -23,8 +23,8 @@ public: unsigned int totalNumThreads = Configuration::getInstance().NumberOfTracePlayers; for (unsigned int threadID = 1; threadID <= totalNumThreads; threadID++) { - memrequestcounter.emplace(Thread(threadID), 0); - memoryIntensity.emplace(Thread(threadID), 0); +// memrequestcounter.emplace(Thread(threadID), 0); +// memoryIntensity.emplace(Thread(threadID), 0); inFlightMemRequestCounter.emplace(Thread(threadID), 0); } SC_THREAD(batchScheduler); @@ -39,19 +39,19 @@ private: std::map> buffer; std::map> bankbuffer; std::map readybatches; - std::map memrequestcounter; +// std::map memrequestcounter; std::map inFlightMemRequestCounter; - std::map memoryIntensity; +// std::map memoryIntensity; unsigned int SJFprobability; - unsigned int totalMemoryRequests(); +// unsigned int totalMemoryRequests(); bool batchFormation(); void selectSJF(); void selectRR(); bool existReadyBatch(); bool batchFormation(Thread thread); - void bypassRequests(); - void bypassLowMemoryIntensity(); +// void bypassRequests(); +// void bypassLowMemoryIntensity(); }; #endif // SMS_H