Safeguard against empty buffer & bypass low memory intensity request

# Explain what has been changed

# Explain why this change is being made

# Provide links to any relevant tickets, articles or other resources
This commit is contained in:
Thanh C. Tran
2017-03-08 00:11:47 +01:00
parent 73eb716deb
commit ee006952de
2 changed files with 77 additions and 39 deletions

View File

@@ -50,19 +50,22 @@ unsigned int SMS::totalMemoryRequests()
return totalSize;
}
void SMS::batchFormation()
bool SMS::batchFormation()
{
if (existReadyBatch())
{
return false;
SC_REPORT_FATAL("SMS", "Form ready batches when exist at least a ready batch");
}
else
{
bool isBatchForm = false;
unsigned int totalNumThreads = Configuration::getInstance().NumberOfTracePlayers;
for (unsigned int threadID = 1; threadID <= totalNumThreads; threadID++)
{
batchFormation(Thread(threadID));
isBatchForm = isBatchForm || batchFormation(Thread(threadID));
}
return isBatchForm;
}
}
@@ -77,33 +80,31 @@ void SMS::batchScheduler()
bool isSJF = (rand() % 100) < SJFprobability;
if (!existReadyBatch())
{
// bypass low memory intensity thread
// bypass if system is lightly load
if (totalMemoryRequests() <= 16 && totalMemoryRequests() > 0) //TODO how about buffer empty?
if (totalMemoryRequests() == 0)
{
continue;
}
else if (totalMemoryRequests() <= 16 && totalMemoryRequests() > 0)
{
// bypass if system is lightly load
bypassRequests();
}
else
else if (totalMemoryRequests() > 16)
{
batchFormation();
if (isSJF)
// bypass low memory intensity thread
bypassLowMemoryIntensity();
// pick & drain a ready batch
if (batchFormation())
{
selectSJF();
}
else
{
selectRR();
isSJF ? selectSJF() : selectRR();
}
}
}
else if (isSJF)
{
selectSJF();
}
else
{
selectRR();
// pick & drain a ready batch
isSJF ? selectSJF() : selectRR();
}
}
}
@@ -115,7 +116,7 @@ void SMS::selectSJF()
unsigned int totalNumThreads = Configuration::getInstance().NumberOfTracePlayers;
for (unsigned int threadID = 2; threadID <= totalNumThreads; threadID++)
{
if (memrequestcounter[Thread(threadID)] <= memrequestcounter[Thread(minThread)])
if (inFlightMemRequestCounter[Thread(threadID)] <= inFlightMemRequestCounter[Thread(minThread)])
{
minThread = threadID;
}
@@ -123,12 +124,15 @@ void SMS::selectSJF()
// drain to bank buffers
std::deque<gp*> requestPtrs = readybatches[Thread(minThread)]->getTransactions();
for (auto intr = requestPtrs.begin(); intr != requestPtrs.end(); intr++)
if (!requestPtrs.empty())
{
Bank bank = DramExtension::getExtension(*intr).getBank();
bankbuffer[bank].emplace_back(*intr);
for (auto intr = requestPtrs.begin(); intr != requestPtrs.end(); intr++)
{
Bank bank = DramExtension::getExtension(*intr).getBank();
bankbuffer[bank].emplace_back(*intr);
}
requestPtrs.clear();
}
requestPtrs.clear();
// reform the drained ready batch
// batchFormation(Thread(minThread));
@@ -140,25 +144,38 @@ void SMS::selectRR()
// drain to bank buffers
std::deque<gp*> requestPtrs = (*next).second->getTransactions();
for (auto intr = requestPtrs.begin(); intr != requestPtrs.end(); intr++)
if (!requestPtrs.empty())
{
Bank bank = DramExtension::getExtension(*intr).getBank();
bankbuffer[bank].emplace_back(*intr);
for (auto intr = requestPtrs.begin(); intr != requestPtrs.end(); intr++)
{
Bank bank = DramExtension::getExtension(*intr).getBank();
bankbuffer[bank].emplace_back(*intr);
}
requestPtrs.clear();
}
requestPtrs.clear();
// reform the drained ready batch
// batchFormation((*next).first);
// point to next pair
do
if (existReadyBatch())
{
next++;
if (next == readybatches.end())
do
{
next = readybatches.begin();
}
} while ((*next).second->isEmpty());
next++;
if (next == readybatches.end())
{
next = readybatches.begin();
}
} while ((*next).second->isEmpty());
}
else
{
// point to next empty ready batch, later call to batchScheduler() will call batchFormation()
// this next empty ready batch will be refilled
next++;
}
}
bool SMS::existReadyBatch()
@@ -173,10 +190,11 @@ bool SMS::existReadyBatch()
return false;
}
void SMS::batchFormation(Thread thread)
bool SMS::batchFormation(Thread thread)
{
if (!readybatches[thread]->isEmpty())
{
return false;
SC_REPORT_FATAL("SMS", "Ready batch formation for non empty ready batch");
}
else
@@ -185,14 +203,15 @@ void SMS::batchFormation(Thread thread)
{
buffer[thread].pop_front();
}
return !readybatches[thread]->isEmpty();
}
}
void SMS::bypassRequests()
{
for(auto& thread_requests : buffer)
for (auto& thread_requests : buffer)
{
for(auto request = thread_requests.second.begin(); request != thread_requests.second.end(); request++)
for (auto request = thread_requests.second.begin(); request != thread_requests.second.end(); request++)
{
Bank bank = DramExtension::getExtension(*request).getBank();
bankbuffer[bank].emplace_back(*request);
@@ -200,3 +219,21 @@ void SMS::bypassRequests()
}
}
}
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);
}
}
}
}

View File

@@ -44,12 +44,13 @@ private:
unsigned int SJFprobability;
unsigned int totalMemoryRequests();
void batchFormation();
bool batchFormation();
void selectSJF();
void selectRR();
bool existReadyBatch();
void batchFormation(Thread thread);
bool batchFormation(Thread thread);
void bypassRequests();
void bypassLowMemoryIntensity();
};
#endif // SMS_H