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
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -14,7 +14,7 @@ class ReadyBatch
|
||||
public:
|
||||
ReadyBatch();
|
||||
bool addTransaction(gp* payload);
|
||||
unsigned int getNumRequests();
|
||||
// unsigned int getNumRequests();
|
||||
std::deque<gp*>& getTransactions();
|
||||
bool isEmpty();
|
||||
private:
|
||||
@@ -23,7 +23,7 @@ private:
|
||||
sc_time thresholdAge;
|
||||
|
||||
Row getRow();
|
||||
sc_time getTimeOfOldestRequest();
|
||||
// sc_time getTimeOfOldestRequest();
|
||||
};
|
||||
|
||||
#endif // READYBATCH_H
|
||||
|
||||
@@ -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<Command, gp*> SMS::getNextRequest(Bank bank)
|
||||
@@ -39,16 +39,16 @@ std::pair<Command, gp*> 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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -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<Thread, std::deque<gp*>> buffer;
|
||||
std::map<Bank, std::deque<gp*>> bankbuffer;
|
||||
std::map<Thread, ReadyBatch*> readybatches;
|
||||
std::map<Thread, unsigned int> memrequestcounter;
|
||||
// std::map<Thread, unsigned int> memrequestcounter;
|
||||
std::map<Thread, unsigned int> inFlightMemRequestCounter;
|
||||
std::map<Thread, float> memoryIntensity;
|
||||
// std::map<Thread, float> 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
|
||||
|
||||
Reference in New Issue
Block a user