systemc: avoid mutex lock in non async cases
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>
This commit is contained in:
@@ -259,6 +259,7 @@ Scheduler::asyncRequestUpdate(Channel *c)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(asyncListMutex);
|
||||
asyncUpdateList.pushLast(c);
|
||||
hasAsyncUpdate = true;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -325,11 +326,12 @@ 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 {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#ifndef __SYSTEMC_CORE_SCHEDULER_HH__
|
||||
#define __SYSTEMC_CORE_SCHEDULER_HH__
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <map>
|
||||
@@ -529,6 +530,7 @@ class Scheduler
|
||||
|
||||
ChannelList asyncUpdateList;
|
||||
std::mutex asyncListMutex;
|
||||
std::atomic<bool> hasAsyncUpdate;
|
||||
|
||||
std::map<::Event *, Tick> eventsToSchedule;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user