[gem5-dev] Change in gem5/gem5[develop]: systemc: avoid dynamic_cast in the critical path

2020-09-15 Thread Earl Ou (Gerrit) via gem5-dev
Earl Ou has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/34355 )


Change subject: systemc: avoid dynamic_cast in the critical path
..

systemc: avoid dynamic_cast in the critical path

NodeList is in the critical path of the systemc scheduler in gem5. A
unnecessary dynamic_cast in the NodeList slow down the event process by
about 15%. Fix the issue by avoiding dynamic_cast.

We see about 15% speed improvement on the example provided by Matthias Jung:
https://gist.github.com/myzinsky/557200aa04556de44a317e0a10f51840

Compare with Accellera implementation, gem5 version is originally 10x
slower and now it's about 8.5x slower.

Change-Id: I3b4ddca31e58e1d4e96144a4021b0a5bb956fda4
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34355
Reviewed-by: Gabe Black 
Maintainer: Gabe Black 
Tested-by: kokoro 
---
M src/systemc/core/list.hh
1 file changed, 7 insertions(+), 2 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/systemc/core/list.hh b/src/systemc/core/list.hh
index b1c5f55..6ba2825 100644
--- a/src/systemc/core/list.hh
+++ b/src/systemc/core/list.hh
@@ -102,8 +102,13 @@
 prevListNode = t;
 }

-T *getNext() { return dynamic_cast(nextListNode); }
-bool empty() { return getNext() == nullptr; }
+T *
+getNext()
+{
+return empty() ? nullptr : static_cast(nextListNode);
+}
+
+bool empty() { return nextListNode == this; }
 };

 } // namespace sc_gem5

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34355
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: I3b4ddca31e58e1d4e96144a4021b0a5bb956fda4
Gerrit-Change-Number: 34355
Gerrit-PatchSet: 6
Gerrit-Owner: Earl Ou 
Gerrit-Reviewer: Earl Ou 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Yu-hsin Wang 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

[gem5-dev] Change in gem5/gem5[develop]: systemc: avoid dynamic_cast in the critical path

2020-09-10 Thread Earl Ou (Gerrit) via gem5-dev
Earl Ou has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/34355 )



Change subject: systemc: avoid dynamic_cast in the critical path
..

systemc: avoid dynamic_cast in the critical path

NostList is in the critical path of the event queue in gem5. A
unnecessary dynamic_cast in the NodeList slow down the event process by
about 15%. Fix the issue by avoiding dynamic_cast.

We see about 15% speed improvement on the example provided by Jung Matthias:
https://gist.github.com/myzinsky/557200aa04556de44a317e0a10f51840

Compare with Accellera implementation, gem5 version is originally 10x
slower and now it's about 8.5x slower.

Change-Id: I3b4ddca31e58e1d4e96144a4021b0a5bb956fda4
---
M src/systemc/core/list.hh
1 file changed, 6 insertions(+), 2 deletions(-)



diff --git a/src/systemc/core/list.hh b/src/systemc/core/list.hh
index b1c5f55..c22bfc9 100644
--- a/src/systemc/core/list.hh
+++ b/src/systemc/core/list.hh
@@ -102,8 +102,12 @@
 prevListNode = t;
 }

-T *getNext() { return dynamic_cast(nextListNode); }
-bool empty() { return getNext() == nullptr; }
+T *getNext()
+{
+return nextListNode == this ? nullptr
+: static_cast(nextListNode);
+}
+bool empty() { return nextListNode == this; }
 };

 } // namespace sc_gem5

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/34355
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: I3b4ddca31e58e1d4e96144a4021b0a5bb956fda4
Gerrit-Change-Number: 34355
Gerrit-PatchSet: 1
Gerrit-Owner: Earl Ou 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s