diff --git a/DRAMSys/simulator/src/controller/Controller.cpp b/DRAMSys/simulator/src/controller/Controller.cpp index b16f981b..56e27215 100644 --- a/DRAMSys/simulator/src/controller/Controller.cpp +++ b/DRAMSys/simulator/src/controller/Controller.cpp @@ -55,7 +55,7 @@ void Controller::buildScheduler() } else if (selectedScheduler == "SMS") { - scheduler = new SMS(*controllerCore, Configuration::getInstance().SJFProbability); + scheduler = new SMS("SMS", *controllerCore, Configuration::getInstance().SJFProbability); } //else if (selectedScheduler == "PAR_BS") //{ diff --git a/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.cpp b/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.cpp index 91aa48db..af2a624b 100644 --- a/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.cpp +++ b/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.cpp @@ -6,6 +6,11 @@ ReadyBatch::ReadyBatch() thresholdAge = sc_time(Configuration::getInstance().ReadyBatchThresholdAge, SC_NS); } +ReadyBatch::~ReadyBatch() +{ + +} + //unsigned int ReadyBatch::getNumRequests() //{ // return readybatch.size(); @@ -13,7 +18,8 @@ ReadyBatch::ReadyBatch() Row ReadyBatch::getRow() { - return DramExtension::getExtension(readybatch.front()).getRow(); + gp*& firstPayload = readybatch.front(); + return DramExtension::getExtension(firstPayload).getRow(); } //sc_time ReadyBatch::getTimeOfOldestRequest() @@ -34,7 +40,8 @@ bool ReadyBatch::addTransaction(gp* payload) { // sc_time currentAge = sc_time_stamp() - getTimeOfOldestRequest(); Row newRow = DramExtension::getExtension(payload).getRow(); - if (/*getNumRequests() == fifosize || currentAge >= thresholdAge || */newRow != getRow()) { + Row oldRow = readybatch.empty()? newRow : getRow(); + if (/*getNumRequests() == fifosize || currentAge >= thresholdAge || */newRow != oldRow) { 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 c35640a5..1b0f304c 100644 --- a/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.h +++ b/DRAMSys/simulator/src/controller/scheduler/ReadyBatch.h @@ -17,6 +17,7 @@ public: // unsigned int getNumRequests(); std::deque& getTransactions(); bool isEmpty(); + ~ReadyBatch(); private: std::deque readybatch; unsigned int fifosize; diff --git a/DRAMSys/simulator/src/controller/scheduler/SMS.h b/DRAMSys/simulator/src/controller/scheduler/SMS.h index 71f7aa96..527b350c 100644 --- a/DRAMSys/simulator/src/controller/scheduler/SMS.h +++ b/DRAMSys/simulator/src/controller/scheduler/SMS.h @@ -17,7 +17,7 @@ using namespace std; class SMS: public sc_module, public IScheduler { public: - SMS(ControllerCore &controllerCore, unsigned int SJFprobability) : IScheduler(controllerCore), SJFprobability(SJFprobability) + SMS(sc_module_name /*_name*/, ControllerCore &controllerCore, unsigned int SJFprobability) : IScheduler(controllerCore), SJFprobability(SJFprobability) { // initialize memory request counter & memory request intensity for each thread unsigned int totalNumThreads = Configuration::getInstance().NumberOfTracePlayers; @@ -26,11 +26,19 @@ public: // memrequestcounter.emplace(Thread(threadID), 0); // memoryIntensity.emplace(Thread(threadID), 0); inFlightMemRequestCounter.emplace(Thread(threadID), 0); + readybatches[Thread(threadID)] = new ReadyBatch(); } SC_THREAD(batchScheduler); } SC_HAS_PROCESS(SMS); - virtual ~SMS(){} + virtual ~SMS() + { + unsigned int totalNumThreads = Configuration::getInstance().NumberOfTracePlayers; + for (unsigned int threadID = 1; threadID <= totalNumThreads; threadID++) + { + delete readybatches[Thread(threadID)]; + } + } virtual void schedule(gp *payload) override; virtual std::pair getNextRequest(Bank bank) override; void batchScheduler();