Earl Ou has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/34695 )
Change subject: systemc: avoid mutex lock in non async cases
......................................................................
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
---
M src/systemc/core/scheduler.cc
M src/systemc/core/scheduler.hh
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/systemc/core/scheduler.cc b/src/systemc/core/scheduler.cc
index 50a1e6b..cc0be7c 100644
--- a/src/systemc/core/scheduler.cc
+++ b/src/systemc/core/scheduler.cc
@@ -259,6 +259,7 @@
{
std::lock_guard<std::mutex> lock(asyncListMutex);
asyncUpdateList.pushLast(c);
+ hasAsyncUpdate = true;
}
void
@@ -325,11 +326,12 @@
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 {
diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh
index 273faf7..b2ab94d 100644
--- a/src/systemc/core/scheduler.hh
+++ b/src/systemc/core/scheduler.hh
@@ -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 @@
ChannelList asyncUpdateList;
std::mutex asyncListMutex;
+ std::atomic<bool> hasAsyncUpdate;
std::map<::Event *, Tick> eventsToSchedule;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34695
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I971c7bf1a1eeb46208eeee6e5da6385c907092b3
Gerrit-Change-Number: 34695
Gerrit-PatchSet: 1
Gerrit-Owner: Earl Ou <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s