Avoid acquiring a mutex lock in case there is no async update in the
scheduler. This helps increasing simulation speed by about 4%.
Change-Id: I971c7bf1a1eeb46208eeee6e5da6385c907092b3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34695
Reviewed-by: Earl Ou <shunhsingou@google.com>
Maintainer: Earl Ou <shunhsingou@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
{
std::lock_guard<std::mutex> lock(asyncListMutex);
asyncUpdateList.pushLast(c);
+ hasAsyncUpdate = true;
}
void
Scheduler::runUpdate()
{
status(StatusUpdate);
- {
+ if (hasAsyncUpdate) {
std::lock_guard<std::mutex> lock(asyncListMutex);
Channel *channel;
while ((channel = asyncUpdateList.getNext()) != nullptr)
updateList.pushLast(channel);
+ hasAsyncUpdate = false;
}
try {
#ifndef __SYSTEMC_CORE_SCHEDULER_HH__
#define __SYSTEMC_CORE_SCHEDULER_HH__
+#include <atomic>
#include <functional>
#include <list>
#include <map>
ChannelList asyncUpdateList;
std::mutex asyncListMutex;
+ std::atomic<bool> hasAsyncUpdate;
std::map<::Event *, Tick> eventsToSchedule;