Add debugger & fix the drain step to drain each request in each clock cycle

This commit is contained in:
Thanh C. Tran
2017-04-28 15:03:40 +02:00
parent c09f0cac0a
commit 8a2d4331ec
2 changed files with 46 additions and 11 deletions

View File

@@ -7,12 +7,15 @@ void SMS::schedule(gp *payload)
{
buffer[DramExtension::getExtension(payload).getThread()].emplace_back(payload);
inFlightMemRequestCounter[DramExtension::getExtension(payload).getThread()]++;
newRequest.notify(SC_ZERO_TIME);
}
std::pair<Command, gp*> SMS::getNextRequest(Bank bank)
{
if (bankbuffer[bank].empty())
{
debugManager.printDebugMessage(name(),
"Get next request on bank " + to_string(bank.ID()) + " : EMPTY buffer");
return pair<Command, tlm::tlm_generic_payload*>(Command::NOP, NULL);
}
else
@@ -26,6 +29,7 @@ std::pair<Command, gp*> SMS::getNextRequest(Bank bank)
bankbuffer[bank].pop_front();
}
debugManager.printDebugMessage(name(), "Get next request on bank " + to_string(bank.ID()));
return pair<Command, tlm::tlm_generic_payload*>(command, payload);
}
@@ -42,7 +46,7 @@ void SMS::batchScheduler()
while (true)
{
wait(memClk); //TODO: Is this correct???
// wait(memClk); //TODO: Is this correct???
isSJF = distribution(generator);
if (!existReadyBatch())
@@ -50,13 +54,17 @@ void SMS::batchScheduler()
// pick & drain a ready batch
if (batchFormation())
{
isSJF ? selectSJF() : selectRR();
isSJF ? selectSJF(memClk) : selectRR(memClk);
}
else
{
wait(newRequest);
}
}
else
{
// pick & drain a ready batch
isSJF ? selectSJF() : selectRR();
isSJF ? selectSJF(memClk) : selectRR(memClk);
}
}
}
@@ -95,11 +103,23 @@ bool SMS::batchFormation(Thread thread)
{
buffer[thread].pop_front();
}
return !readybatches[thread]->isEmpty();
if (readybatches[thread]->isEmpty())
{
debugManager.printDebugMessage(name(),
"EMPTY buffer, Ready batch for thread: " + to_string(thread.ID()) + " NOT formed");
return false;
}
else
{
debugManager.printDebugMessage(name(),
"Form ready batch for thread: " + to_string(thread.ID()));
return true;
}
}
}
void SMS::selectSJF()
void SMS::selectSJF(sc_time memClk)
{
// find shorstest thread
std::vector<Thread> threadsWithNonEmptyReadybatches;
@@ -121,6 +141,8 @@ void SMS::selectSJF()
minThread = thread;
}
}
debugManager.printDebugMessage(name(),
"[SJF] Select ready batch of thread " + to_string(minThread.ID()));
// drain to bank buffers
std::deque<gp*> &requestPtrs = readybatches[minThread]->getTransactions();
@@ -128,6 +150,10 @@ void SMS::selectSJF()
{
Bank bank = DramExtension::getExtension(*payloadPtrIterator).getBank();
bankbuffer[bank].emplace_back(*payloadPtrIterator);
debugManager.printDebugMessage(name(),
"[SJF] Drain request in the ready batch of thread " + to_string(minThread.ID())
+ " to bankbuffer " + to_string(bank.ID()));
wait(memClk);
}
requestPtrs.clear();
@@ -137,7 +163,7 @@ void SMS::selectSJF()
}
void SMS::selectRR()
void SMS::selectRR(sc_time memClk)
{
static std::map<Thread, ReadyBatch*>::iterator next = readybatches.begin();
@@ -151,6 +177,8 @@ void SMS::selectRR()
next = readybatches.begin();
}
}
debugManager.printDebugMessage(name(),
"[RR] Select ready batch of thread " + to_string((*next).first.ID()));
// drain to bank buffers
std::deque<gp*> &requestPtrs = (*next).second->getTransactions();
@@ -158,6 +186,10 @@ void SMS::selectRR()
{
Bank bank = DramExtension::getExtension(*payloadPtrIterator).getBank();
bankbuffer[bank].emplace_back(*payloadPtrIterator);
debugManager.printDebugMessage(name(),
"[RR] Drained request in the ready batch of thread " + to_string((*next).first.ID())
+ " to bankbuffer " + to_string(bank.ID()));
wait(memClk);
}
requestPtrs.clear();
@@ -179,5 +211,3 @@ bool SMS::existReadyBatch()
return false;
}

View File

@@ -9,6 +9,7 @@
#include "../core/ControllerCore.h"
#include "../core/configuration/Configuration.h"
#include "../../common/dramExtension.h"
#include "../../common/DebugManager.h"
#define MIN_TOTAL_REQ 16
@@ -17,7 +18,7 @@ using namespace std;
class SMS: public sc_module, public IScheduler
{
public:
SMS(sc_module_name /*_name*/, ControllerCore &controllerCore, unsigned int SJFprobability) : IScheduler(controllerCore), SJFprobability(SJFprobability)
SMS(sc_module_name /*_name*/, ControllerCore &controllerCore, unsigned int SJFprobability) : IScheduler(controllerCore), SJFprobability(SJFprobability), debugManager(DebugManager::getInstance())
{
// initialize memory request counter & memory request intensity for each thread
unsigned int totalNumThreads = Configuration::getInstance().NumberOfTracePlayers;
@@ -51,11 +52,15 @@ private:
std::map<Thread, unsigned int> inFlightMemRequestCounter;
unsigned int SJFprobability;
DebugManager& debugManager;
sc_event newRequest;
bool batchFormation();
void selectSJF();
void selectRR();
void selectSJF(sc_time memClk);
void selectRR(sc_time memClk);
bool existReadyBatch();
bool batchFormation(Thread thread);
};
#endif // SMS_H