Change to better variable name
This commit is contained in:
@@ -49,7 +49,7 @@ void SMS::batchScheduler()
|
||||
}
|
||||
}
|
||||
|
||||
bool SMS::selectSJF(sc_time memClk, std::map<Thread, ReadyBatch*>::iterator &select)
|
||||
bool SMS::selectSJF(sc_time memClk, std::map<Thread, ReadyBatch*>::iterator &lastSelectedThread)
|
||||
{
|
||||
// find threads with non-empty ready batch
|
||||
std::vector<Thread> threadsWithNonEmptyReadybatches;
|
||||
@@ -89,7 +89,7 @@ bool SMS::selectSJF(sc_time memClk, std::map<Thread, ReadyBatch*>::iterator &sel
|
||||
}
|
||||
|
||||
// save selected thread
|
||||
select = readybatches.find(Thread(minThread));
|
||||
lastSelectedThread = readybatches.find(Thread(minThread));
|
||||
|
||||
debugManager.printDebugMessage(name(),
|
||||
"[SJF] Select ready batch of thread " + to_string(minThread.ID()));
|
||||
@@ -120,29 +120,29 @@ bool SMS::selectSJF(sc_time memClk, std::map<Thread, ReadyBatch*>::iterator &sel
|
||||
|
||||
}
|
||||
|
||||
bool SMS::selectRR(sc_time memClk, std::map<Thread, ReadyBatch*>::iterator &select)
|
||||
bool SMS::selectRR(sc_time memClk, std::map<Thread, ReadyBatch*>::iterator &nextSelectedThread)
|
||||
{
|
||||
// pick a non-empty ready batch
|
||||
std::map<Thread, ReadyBatch*>::iterator saved = select;
|
||||
while ((*select).second->isEmpty())
|
||||
std::map<Thread, ReadyBatch*>::iterator savedOriginalNextSelectedThread = nextSelectedThread;
|
||||
while ((*nextSelectedThread).second->isEmpty())
|
||||
{
|
||||
// form ready batch for this thread
|
||||
Thread thread = (*select).first;
|
||||
while (!buffer[thread].empty() && (*select).second->addTransaction(buffer[thread].front()))
|
||||
Thread thread = (*nextSelectedThread).first;
|
||||
while (!buffer[thread].empty() && (*nextSelectedThread).second->addTransaction(buffer[thread].front()))
|
||||
{
|
||||
buffer[thread].pop_front();
|
||||
}
|
||||
|
||||
if ((*select).second->isEmpty())
|
||||
if ((*nextSelectedThread).second->isEmpty())
|
||||
{
|
||||
// cannot form ready batch then move to next thread
|
||||
select++;
|
||||
if (select == readybatches.end())
|
||||
nextSelectedThread++;
|
||||
if (nextSelectedThread == readybatches.end())
|
||||
{
|
||||
select = readybatches.begin();
|
||||
nextSelectedThread = readybatches.begin();
|
||||
}
|
||||
|
||||
if (select == saved)
|
||||
if (nextSelectedThread == savedOriginalNextSelectedThread)
|
||||
{
|
||||
// the next thread is the original thread, that mean req buffer are totally empty
|
||||
// non-existed ready batch to be picked up & drained
|
||||
@@ -151,17 +151,17 @@ bool SMS::selectRR(sc_time memClk, std::map<Thread, ReadyBatch*>::iterator &sele
|
||||
}
|
||||
}
|
||||
debugManager.printDebugMessage(name(),
|
||||
"[RR] Select ready batch of thread " + to_string((*select).first.ID()));
|
||||
"[RR] Select ready batch of thread " + to_string((*nextSelectedThread).first.ID()));
|
||||
|
||||
// drain to bank buffers
|
||||
std::deque<gp*> &requestPtrs = (*select).second->getTransactions();
|
||||
std::deque<gp*> &requestPtrs = (*nextSelectedThread).second->getTransactions();
|
||||
for (auto payloadPtrIterator = requestPtrs.begin(); payloadPtrIterator != requestPtrs.end();
|
||||
payloadPtrIterator++)
|
||||
{
|
||||
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((*select).first.ID())
|
||||
"[RR] Drained request in the ready batch of thread " + to_string((*nextSelectedThread).first.ID())
|
||||
+ " to bankbuffer " + to_string(bank.ID()));
|
||||
wait(memClk);
|
||||
}
|
||||
@@ -175,7 +175,7 @@ void SMS::selectRR_SJF(bool isSJF, sc_time memClk) {
|
||||
if (isSJF)
|
||||
{
|
||||
// select by Shortest Job First policy
|
||||
bool success = selectSJF(memClk, selected);
|
||||
bool success = selectSJF(memClk, selectedThread);
|
||||
if (!success)
|
||||
{
|
||||
wait(newRequest);
|
||||
@@ -184,11 +184,11 @@ void SMS::selectRR_SJF(bool isSJF, sc_time memClk) {
|
||||
else
|
||||
{
|
||||
// select by Round Robin policy
|
||||
if (selected == readybatches.end())
|
||||
if (selectedThread == readybatches.end())
|
||||
{
|
||||
// first Round Robin selection
|
||||
selected = readybatches.begin();
|
||||
bool success = selectRR(memClk, selected);
|
||||
selectedThread = readybatches.begin();
|
||||
bool success = selectRR(memClk, selectedThread);
|
||||
if (!success)
|
||||
{
|
||||
wait(newRequest);
|
||||
@@ -198,12 +198,12 @@ void SMS::selectRR_SJF(bool isSJF, sc_time memClk) {
|
||||
{
|
||||
// subsequent Round Robin selection
|
||||
// move the select iterator to the next one
|
||||
selected++;
|
||||
if (selected == readybatches.end())
|
||||
selectedThread++;
|
||||
if (selectedThread == readybatches.end())
|
||||
{
|
||||
selected = readybatches.begin();
|
||||
selectedThread = readybatches.begin();
|
||||
}
|
||||
bool success = selectRR(memClk, selected);
|
||||
bool success = selectRR(memClk, selectedThread);
|
||||
if (!success)
|
||||
{
|
||||
wait(newRequest);
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
}
|
||||
|
||||
// initialize selected thread iterator
|
||||
selected = readybatches.end();
|
||||
selectedThread = readybatches.end();
|
||||
SC_THREAD(batchScheduler);
|
||||
}
|
||||
SC_HAS_PROCESS(SMS);
|
||||
@@ -53,7 +53,7 @@ private:
|
||||
std::map<Bank, std::deque<gp*>> bankbuffer;
|
||||
std::map<Thread, ReadyBatch*> readybatches;
|
||||
std::map<Thread, unsigned int> inFlightMemRequestCounter;
|
||||
std::map<Thread, ReadyBatch*>::iterator selected;
|
||||
std::map<Thread, ReadyBatch*>::iterator selectedThread;
|
||||
unsigned int SJFprobability;
|
||||
|
||||
DebugManager& debugManager;
|
||||
|
||||
Reference in New Issue
Block a user