[gem5-dev] [M] Change in gem5/gem5[develop]: mem-ruby: AbstractController can send retry req to mem controller

2023-07-07 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67658?usp=email )


Change subject: mem-ruby: AbstractController can send retry req to mem  
controller

..

mem-ruby: AbstractController can send retry req to mem controller

Prior to this patch, when a memory controller was failing at sending a
response to AbstractController, it would not wakeup until the next
request. This patch gives the opportunity to Ruby models to notify
memory response buffer dequeue so that AbstractController can send a
retry request if necessary.

A dequeueMemRspQueue function has been added AbstractController to
automate the dequeue+notify operation.

Note that models that don't notify AbstractController will continue
working as before.

Change-Id: I261bb4593c126208c98825e54f538638d818d16b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67658
Tested-by: kokoro 
Reviewed-by: Bobby Bruce 
Maintainer: Bobby Bruce 
---
M src/mem/ruby/slicc_interface/AbstractController.cc
M src/mem/ruby/slicc_interface/AbstractController.hh
2 files changed, 51 insertions(+), 7 deletions(-)

Approvals:
  kokoro: Regressions pass
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved




diff --git a/src/mem/ruby/slicc_interface/AbstractController.cc  
b/src/mem/ruby/slicc_interface/AbstractController.cc

index 2d10422..f7b01cf 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.cc
+++ b/src/mem/ruby/slicc_interface/AbstractController.cc
@@ -62,8 +62,10 @@
   m_buffer_size(p.buffer_size), m_recycle_latency(p.recycle_latency),
   m_mandatory_queue_latency(p.mandatory_queue_latency),
   m_waiting_mem_retry(false),
+  m_mem_ctrl_waiting_retry(false),
   memoryPort(csprintf("%s.memory", name()), this),
   addrRanges(p.addr_ranges.begin(), p.addr_ranges.end()),
+  mRetryRespEvent{*this, false},
   stats(this)
 {
 if (m_version == 0) {
@@ -367,11 +369,17 @@
 return num_functional_writes + 1;
 }

-void
+bool
 AbstractController::recvTimingResp(PacketPtr pkt)
 {
-assert(getMemRespQueue());
-assert(pkt->isResponse());
+auto* memRspQueue = getMemRespQueue();
+gem5_assert(memRspQueue);
+gem5_assert(pkt->isResponse());
+
+if (!memRspQueue->areNSlotsAvailable(1, curTick())) {
+m_mem_ctrl_waiting_retry = true;
+return false;
+}

 std::shared_ptr msg =  
std::make_shared(clockEdge());

 (*msg).m_addr = pkt->getAddr();
@@ -395,8 +403,9 @@
 panic("Incorrect packet type received from memory controller!");
 }

-getMemRespQueue()->enqueue(msg, clockEdge(), cyclesToTicks(Cycles(1)));
+memRspQueue->enqueue(msg, clockEdge(), cyclesToTicks(Cycles(1)));
 delete pkt;
+return true;
 }

 Tick
@@ -438,11 +447,33 @@
 }


+void
+AbstractController::memRespQueueDequeued() {
+if (m_mem_ctrl_waiting_retry && !mRetryRespEvent.scheduled()) {
+schedule(mRetryRespEvent, clockEdge(Cycles{1}));
+}
+}
+
+void
+AbstractController::dequeueMemRespQueue() {
+auto* q = getMemRespQueue();
+gem5_assert(q);
+q->dequeue(clockEdge());
+memRespQueueDequeued();
+}
+
+void
+AbstractController::sendRetryRespToMem() {
+if (m_mem_ctrl_waiting_retry) {
+m_mem_ctrl_waiting_retry = false;
+memoryPort.sendRetryResp();
+}
+}
+
 bool
 AbstractController::MemoryPort::recvTimingResp(PacketPtr pkt)
 {
-controller->recvTimingResp(pkt);
-return true;
+return controller->recvTimingResp(pkt);
 }

 void
diff --git a/src/mem/ruby/slicc_interface/AbstractController.hh  
b/src/mem/ruby/slicc_interface/AbstractController.hh

index a5ab5c2..7fdb88b 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.hh
+++ b/src/mem/ruby/slicc_interface/AbstractController.hh
@@ -61,6 +61,7 @@
 #include "mem/ruby/system/CacheRecorder.hh"
 #include "params/RubyController.hh"
 #include "sim/clocked_object.hh"
+#include "sim/eventq.hh"

 namespace gem5
 {
@@ -100,6 +101,14 @@
 virtual MessageBuffer* getMandatoryQueue() const = 0;
 virtual MessageBuffer* getMemReqQueue() const = 0;
 virtual MessageBuffer* getMemRespQueue() const = 0;
+
+// That function must be called by controller when dequeuing mem resp  
queue

+// for memory controller to receive the retry request in time
+void memRespQueueDequeued();
+// Or that function can be called to perform both dequeue and  
notification

+// at once.
+void dequeueMemRespQueue();
+
 virtual AccessPermission getAccessPermission(const Addr ) = 0;

 virtual void print(std::ostream & out) const = 0;
@@ -165,7 +174,7 @@
 Port (const std::string _name,
   PortID idx=InvalidPortID);

-void recvTimingResp(PacketPtr pkt);
+bool recvTimingResp(PacketPtr pkt);
 Tick recvAtomic(PacketPtr pkt);

 const AddrRangeList () const { return addrRanges; }
@@ -364,6 +373,7 @@
 Cycles 

[gem5-dev] [L] Change in gem5/gem5[develop]: base: Provide several hash implementations for common types

2023-07-07 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67663?usp=email )


 (

11 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.
 )Change subject: base: Provide several hash implementations for common  
types

..

base: Provide several hash implementations for common types

These types include std::pair, std::tuple, all iterable types and any
composition of these. Convenience hash factory and computation
functions are also provided.

These functions are in the stl_helpers namespace and must not move to
::std which could cause undefined behaviour. This is because
specialization of std templates for std or native types (or
composition of these) is undefined behaviour. This inconvenience can't
be circumvented for generic code. Users are free to bring these hash
implementations to namespace std after specialization for their own
non-std and non-native types.

Change-Id: Ifd0f0b64e5421d5d44890eb25428cc9c53484eb3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67663
Reviewed-by: Daniel Carvalho 
Maintainer: Daniel Carvalho 
Tested-by: kokoro 
---
M src/base/stl_helpers.hh
A src/base/stl_helpers/SConscript
A src/base/stl_helpers/hash_helpers.hh
A src/base/stl_helpers/hash_helpers.test.cc
4 files changed, 285 insertions(+), 0 deletions(-)

Approvals:
  kokoro: Regressions pass
  Daniel Carvalho: Looks good to me, approved; Looks good to me, approved




diff --git a/src/base/stl_helpers.hh b/src/base/stl_helpers.hh
index d12f266..1d19f56 100644
--- a/src/base/stl_helpers.hh
+++ b/src/base/stl_helpers.hh
@@ -31,10 +31,12 @@

 #include 
 #include 
+#include 
 #include 
 #include 

 #include "base/compiler.hh"
+#include "base/stl_helpers/hash_helpers.hh"

 namespace gem5
 {
diff --git a/src/base/stl_helpers/SConscript  
b/src/base/stl_helpers/SConscript

new file mode 100644
index 000..1143dc2
--- /dev/null
+++ b/src/base/stl_helpers/SConscript
@@ -0,0 +1,28 @@
+# Copyright (c) 2023 Arteris, Inc. and its applicable licensors and  
affiliates.

+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are  
met:
+# redistributions of source code must retain the above copyright notice,  
this
+# list of conditions and the following disclaimer; redistributions in  
binary
+# form must reproduce the above copyright notice, this list of conditions  
and
+# the following disclaimer in the documentation and/or other materials  
provided

+# with the distribution; neither the name of the copyright holders nor the
+# names of its contributors may be used to endorse or promote products  
derived

+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS  
IS"

+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  
PURPOSE

+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF  
THE

+# POSSIBILITY OF SUCH DAMAGE.
+
+Import('*')
+
+GTest('hash_helpers.test', 'hash_helpers.test.cc')
diff --git a/src/base/stl_helpers/hash_helpers.hh  
b/src/base/stl_helpers/hash_helpers.hh

new file mode 100644
index 000..f638ea9
--- /dev/null
+++ b/src/base/stl_helpers/hash_helpers.hh
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2023 Arteris, Inc. and its applicable licensors and
+ * affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS  
IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,  
THE
+ * IMPLIED WARRANTIES OF 

[gem5-dev] [XS] Change in gem5/gem5[develop]: configs: Fix default CustomMesh for use with Garnet

2023-07-07 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67660?usp=email )


 (

2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.

 )Change subject: configs: Fix default CustomMesh for use with Garnet
..

configs: Fix default CustomMesh for use with Garnet

Garnet routers do not support 0 latency switches. Use 1 instead if the
network is garnet.

Change-Id: I09841a01eaf413bee0a1629307ecff0ae2bda948
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67660
Reviewed-by: Jason Lowe-Power 
Tested-by: kokoro 
Maintainer: Jason Lowe-Power 
---
M configs/topologies/CustomMesh.py
1 file changed, 4 insertions(+), 1 deletion(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/configs/topologies/CustomMesh.py  
b/configs/topologies/CustomMesh.py

index c62b39a..21fa2dc 100644
--- a/configs/topologies/CustomMesh.py
+++ b/configs/topologies/CustomMesh.py
@@ -171,7 +171,9 @@
 def _createRNFRouter(self, mesh_router):
 # Create a zero-latency router bridging node controllers
 # and the mesh router
-node_router = self._Router(router_id=len(self._routers), latency=0)
+node_router = self._Router(
+router_id=len(self._routers), latency=self.node_router_latency
+)
 self._routers.append(node_router)

 # connect node_router <-> mesh router
@@ -270,6 +272,7 @@
 self._ExtLink = ExtLink
 self._Router = Router

+self.node_router_latency = 1 if options.network == "garnet" else 0
 if hasattr(options, "router_link_latency"):
 self._router_link_latency = options.router_link_latency
 self._node_link_latency = options.node_link_latency

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67660?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings?usp=email


Gerrit-MessageType: merged
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I09841a01eaf413bee0a1629307ecff0ae2bda948
Gerrit-Change-Number: 67660
Gerrit-PatchSet: 7
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: kokoro 
Gerrit-CC: kokoro 
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [XS] Change in gem5/gem5[develop]: mem-ruby: Fix of an address bug in MESI_Two_Level-dir.sm

2023-07-07 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67661?usp=email )


 (

3 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.

 )Change subject: mem-ruby: Fix of an address bug in MESI_Two_Level-dir.sm
..

mem-ruby: Fix of an address bug in MESI_Two_Level-dir.sm

Physical access address and line address were mixed up in
qw_queueMemoryWBRequest_partial

Change-Id: I0b238ffc59d2bb3de221d96905c75b7616eac964
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67661
Tested-by: kokoro 
Reviewed-by: Jason Lowe-Power 
Maintainer: Jason Lowe-Power 
---
M src/mem/ruby/protocol/MESI_Two_Level-dir.sm
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/mem/ruby/protocol/MESI_Two_Level-dir.sm  
b/src/mem/ruby/protocol/MESI_Two_Level-dir.sm

index aa61424..84ec578 100644
--- a/src/mem/ruby/protocol/MESI_Two_Level-dir.sm
+++ b/src/mem/ruby/protocol/MESI_Two_Level-dir.sm
@@ -365,7 +365,7 @@
  desc="Queue off-chip writeback request") {
 peek(requestNetwork_in, RequestMsg) {
   enqueue(memQueue_out, MemoryMsg, to_mem_ctrl_latency) {
-out_msg.addr := address;
+out_msg.addr := in_msg.addr;
 out_msg.Type := MemoryRequestType:MEMORY_WB;
 out_msg.Sender := machineID;
 out_msg.MessageSize := MessageSizeType:Writeback_Data;

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67661?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings?usp=email


Gerrit-MessageType: merged
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I0b238ffc59d2bb3de221d96905c75b7616eac964
Gerrit-Change-Number: 67661
Gerrit-PatchSet: 7
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: kokoro 
Gerrit-CC: kokoro 
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [XS] Change in gem5/gem5[develop]: python: Fix namespaced enums params code generation

2023-07-07 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67662?usp=email )


Change subject: python: Fix namespaced enums params code generation
..

python: Fix namespaced enums params code generation

The wrapper_name parameter was not properly handled. Enums were always
generated in the enums namespace even if required differently by
wrapper_name.

Change-Id: I366846ce39dfe10effc2cc145e7772a3fd171b92
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67662
Tested-by: kokoro 
Reviewed-by: Bobby Bruce 
Maintainer: Bobby Bruce 
---
M build_tools/enum_cc.py
M src/python/m5/params.py
2 files changed, 4 insertions(+), 4 deletions(-)

Approvals:
  kokoro: Regressions pass
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved




diff --git a/build_tools/enum_cc.py b/build_tools/enum_cc.py
index 5d82b40..173143f 100644
--- a/build_tools/enum_cc.py
+++ b/build_tools/enum_cc.py
@@ -97,7 +97,7 @@
 )
 else:
 code(
-"""namespace enums
+"""namespace ${wrapper_name}
 {"""
 )
 code.indent(1)
@@ -112,7 +112,7 @@

 if not enum.wrapper_is_struct and not enum.is_class:
 code.dedent(1)
-code("} // namespace enums")
+code("} // namespace ${wrapper_name}")

 code("} // namespace gem5")

diff --git a/src/python/m5/params.py b/src/python/m5/params.py
index 2ca6dfc..2559b55 100644
--- a/src/python/m5/params.py
+++ b/src/python/m5/params.py
@@ -1560,8 +1560,8 @@
 if cls.is_class:
 cls.cxx_type = f"{name}"
 else:
-cls.cxx_type = f"enums::{name}"
-
+scope = init_dict.get("wrapper_name", "enums")
+cls.cxx_type = f"{scope}::{name}"
 super().__init__(name, bases, init_dict)



--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67662?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings?usp=email


Gerrit-MessageType: merged
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I366846ce39dfe10effc2cc145e7772a3fd171b92
Gerrit-Change-Number: 67662
Gerrit-PatchSet: 9
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Andreas Sandberg 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: kokoro 
Gerrit-CC: kokoro 
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: base: stl_hlp::unordered_{map,set} with stl_hlp::hash by default

2023-07-07 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67664?usp=email )


 (

12 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.
 )Change subject: base: stl_hlp::unordered_{map,set} with stl_hlp::hash by  
default

..

base: stl_hlp::unordered_{map,set} with stl_hlp::hash by default

Change-Id: Iad01d7fa6ff6293a2d931ba79ad3550c6e44
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67664
Reviewed-by: Daniel Carvalho 
Tested-by: kokoro 
Maintainer: Daniel Carvalho 
---
M src/base/stl_helpers/hash_helpers.hh
1 file changed, 31 insertions(+), 0 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/base/stl_helpers/hash_helpers.hh  
b/src/base/stl_helpers/hash_helpers.hh

index f638ea9..1432d52 100644
--- a/src/base/stl_helpers/hash_helpers.hh
+++ b/src/base/stl_helpers/hash_helpers.hh
@@ -40,6 +40,11 @@

 #include "base/type_traits.hh"

+#include 
+#include 
+#include 
+#include 
+
 namespace gem5::stl_helpers
 {

@@ -165,6 +170,32 @@
 using hash_impl::hash_value;
 using hash_impl::is_hash_enabled;

+/*
+ * Provide unordered_map and unordered_set with stl_helpers::hash  
functions.
+ * These aliases enable clean use of stl_helpers::hash as default Hash  
template
+ * parameter. The reason for not using an alias is that template type  
aliases
+ * with default template arguments do not behave well with template  
parameter
+ * deductions in certain situations. One must remember that  
std::unordered_X
+ * is not a polymorphic type and as such, gem5::stl_helpers::unordered_X  
shall

+ * never be owned as a std::unordered_X.
+ */
+template<
+typename Key,
+typename T,
+typename Hash = hash,
+typename KeyEqual = std::equal_to,
+typename Allocator = std::allocator< std::pair >>
+struct unordered_map: std::unordered_map
+{};
+
+template<
+typename Key,
+typename Hash = hash,
+typename KeyEqual = std::equal_to,
+typename Allocator = std::allocator>
+struct unordered_set: std::unordered_set
+{};
+
 } // namespace gem5::stl_helpers

 #endif // BASE_STL_HELPERS_HASH_HELPERS_HH

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67664?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings?usp=email


Gerrit-MessageType: merged
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Iad01d7fa6ff6293a2d931ba79ad3550c6e44
Gerrit-Change-Number: 67664
Gerrit-PatchSet: 14
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: kokoro 
Gerrit-CC: kokoro 
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: mem-ruby: Switch to dequeueMemRspQueue() in all Ruby protocols

2023-07-07 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67659?usp=email )


Change subject: mem-ruby: Switch to dequeueMemRspQueue() in all Ruby  
protocols

..

mem-ruby: Switch to dequeueMemRspQueue() in all Ruby protocols

Change-Id: I33bca345d985618e3fca62e9ddd5bcc3ad8226a3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67659
Tested-by: kokoro 
Maintainer: Bobby Bruce 
Reviewed-by: Bobby Bruce 
---
M src/learning_gem5/part3/MSI-dir.sm
M src/mem/ruby/protocol/MESI_Two_Level-dir.sm
M src/mem/ruby/protocol/MI_example-dir.sm
M src/mem/ruby/protocol/MOESI_AMD_Base-Region-dir.sm
M src/mem/ruby/protocol/MOESI_AMD_Base-dir.sm
M src/mem/ruby/protocol/MOESI_AMD_Base-probeFilter.sm
M src/mem/ruby/protocol/MOESI_CMP_directory-dir.sm
M src/mem/ruby/protocol/MOESI_CMP_token-dir.sm
M src/mem/ruby/protocol/MOESI_hammer-dir.sm
M src/mem/ruby/protocol/RubySlicc_Defines.sm
M src/mem/ruby/protocol/chi/CHI-mem.sm
11 files changed, 12 insertions(+), 10 deletions(-)

Approvals:
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/learning_gem5/part3/MSI-dir.sm  
b/src/learning_gem5/part3/MSI-dir.sm

index ca5ea3e..70d9601 100644
--- a/src/learning_gem5/part3/MSI-dir.sm
+++ b/src/learning_gem5/part3/MSI-dir.sm
@@ -448,7 +448,7 @@
 }

 action(popMemQueue, "pM", desc="Pop the memory queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
 }

 // Stalling actions
diff --git a/src/mem/ruby/protocol/MESI_Two_Level-dir.sm  
b/src/mem/ruby/protocol/MESI_Two_Level-dir.sm

index 9d69755..aa61424 100644
--- a/src/mem/ruby/protocol/MESI_Two_Level-dir.sm
+++ b/src/mem/ruby/protocol/MESI_Two_Level-dir.sm
@@ -299,7 +299,7 @@
   }

   action(l_popMemQueue, "q", desc="Pop off-chip request queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   action(kd_wakeUpDependents, "kd", desc="wake-up dependents") {
diff --git a/src/mem/ruby/protocol/MI_example-dir.sm  
b/src/mem/ruby/protocol/MI_example-dir.sm

index 11d2862..bbaa7d0 100644
--- a/src/mem/ruby/protocol/MI_example-dir.sm
+++ b/src/mem/ruby/protocol/MI_example-dir.sm
@@ -523,7 +523,7 @@
   }

   action(l_popMemQueue, "q", desc="Pop off-chip request queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   // TRANSITIONS
diff --git a/src/mem/ruby/protocol/MOESI_AMD_Base-Region-dir.sm  
b/src/mem/ruby/protocol/MOESI_AMD_Base-Region-dir.sm

index f16c257..ec8ffe6 100644
--- a/src/mem/ruby/protocol/MOESI_AMD_Base-Region-dir.sm
+++ b/src/mem/ruby/protocol/MOESI_AMD_Base-Region-dir.sm
@@ -1397,7 +1397,7 @@
   }

   action(pm_popMemQueue, "pm", desc="pop mem queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   action(pt_popTriggerQueue, "pt", desc="pop trigger queue") {
diff --git a/src/mem/ruby/protocol/MOESI_AMD_Base-dir.sm  
b/src/mem/ruby/protocol/MOESI_AMD_Base-dir.sm

index 3b38e3b..4dd03a1 100644
--- a/src/mem/ruby/protocol/MOESI_AMD_Base-dir.sm
+++ b/src/mem/ruby/protocol/MOESI_AMD_Base-dir.sm
@@ -1169,7 +1169,7 @@
   }

   action(pm_popMemQueue, "pm", desc="pop mem queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   action(pt_popTriggerQueue, "pt", desc="pop trigger queue") {
diff --git a/src/mem/ruby/protocol/MOESI_AMD_Base-probeFilter.sm  
b/src/mem/ruby/protocol/MOESI_AMD_Base-probeFilter.sm

index 8608608..5e815a7 100644
--- a/src/mem/ruby/protocol/MOESI_AMD_Base-probeFilter.sm
+++ b/src/mem/ruby/protocol/MOESI_AMD_Base-probeFilter.sm
@@ -1103,7 +1103,7 @@
   }

   action(pm_popMemQueue, "pm", desc="pop mem queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   action(pt_popTriggerQueue, "pt", desc="pop trigger queue") {
diff --git a/src/mem/ruby/protocol/MOESI_CMP_directory-dir.sm  
b/src/mem/ruby/protocol/MOESI_CMP_directory-dir.sm

index 3b4a801..f21400c 100644
--- a/src/mem/ruby/protocol/MOESI_CMP_directory-dir.sm
+++ b/src/mem/ruby/protocol/MOESI_CMP_directory-dir.sm
@@ -598,7 +598,7 @@
   }

   action(q_popMemQueue, "q", desc="Pop off-chip request queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   action(qf_queueMemoryFetchRequest, "qf", desc="Queue off-chip fetch  
request") {
diff --git a/src/mem/ruby/protocol/MOESI_CMP_token-dir.sm  
b/src/mem/ruby/protocol/MOESI_CMP_token-dir.sm

index 97ea292..7f2bdf9 100644
--- a/src/mem/ruby/protocol/MOESI_CMP_token-dir.sm
+++ b/src/mem/ruby/protocol/MOESI_CMP_token-dir.sm
@@ -821,7 +821,7 @@
   }

   action(l_popMemQueue, "q", desc="Pop off-chip request queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   action(r_bounceResponse, "r", desc="Bounce response to starving  
processor") {
diff --git a/src/mem/ruby/protocol/MOESI_hammer-dir.sm  
b/src/mem/ruby/protocol/MOESI_hammer-dir.sm

[gem5-dev] [S] Change in gem5/gem5[develop]: base: define is_iterable type trait

2023-07-07 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/71838?usp=email )


Change subject: base: define is_iterable type trait
..

base: define is_iterable type trait

Change-Id: I38bb0ddcbb95645797f1d20724b78aff3bef4580
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/71838
Maintainer: Daniel Carvalho 
Tested-by: kokoro 
Reviewed-by: Daniel Carvalho 
---
M src/base/type_traits.hh
1 file changed, 16 insertions(+), 3 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/base/type_traits.hh b/src/base/type_traits.hh
index 1fec93d..a42f786 100644
--- a/src/base/type_traits.hh
+++ b/src/base/type_traits.hh
@@ -27,8 +27,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */

-#ifndef __BASE_TYPETRAITS_HH__
-#define __BASE_TYPETRAITS_HH__
+#ifndef BASE_TYPETRAITS_HH
+#define BASE_TYPETRAITS_HH

 #include 
 #include 
@@ -92,6 +92,19 @@
 using MemberFunctionArgsTuple_t =
 typename MemberFunctionSignature::argsTuple_t;

+
+// iterable type trait
+template 
+struct is_iterable: std::false_type {};
+
+template 
+struct is_iterable())),
+decltype(end(std::declval()))>>: std::true_type {};
+
+template 
+constexpr bool is_iterable_v = is_iterable::value;
+
 } // namespace gem5

-#endif // __BASE_TYPETRAITS_HH__
+#endif // BASE_TYPETRAITS_HH

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/71838?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings?usp=email


Gerrit-MessageType: merged
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I38bb0ddcbb95645797f1d20724b78aff3bef4580
Gerrit-Change-Number: 71838
Gerrit-PatchSet: 2
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: kokoro 
Gerrit-CC: Giacomo Travaglini 
Gerrit-CC: kokoro 
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: base: define is_std_hash_enabled type trait

2023-07-07 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/71839?usp=email )


Change subject: base: define is_std_hash_enabled type trait
..

base: define is_std_hash_enabled type trait

Change-Id: I7ffb7f80a90006d6b8cd42bdf3d63e34c6dbda01
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/71839
Reviewed-by: Bobby Bruce 
Tested-by: kokoro 
Maintainer: Bobby Bruce 
---
M src/base/type_traits.hh
1 file changed, 11 insertions(+), 0 deletions(-)

Approvals:
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/base/type_traits.hh b/src/base/type_traits.hh
index a42f786..fd13044 100644
--- a/src/base/type_traits.hh
+++ b/src/base/type_traits.hh
@@ -105,6 +105,17 @@
 template 
 constexpr bool is_iterable_v = is_iterable::value;

+// std::hash-enabled type trait
+template 
+struct is_std_hash_enabled: std::false_type {};
+
+template 
+struct is_std_hash_enabled())>>: std::true_type {};
+
+template 
+constexpr bool is_std_hash_enabled_v = is_std_hash_enabled::value;
+
 } // namespace gem5

 #endif // BASE_TYPETRAITS_HH

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/71839?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings?usp=email


Gerrit-MessageType: merged
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I7ffb7f80a90006d6b8cd42bdf3d63e34c6dbda01
Gerrit-Change-Number: 71839
Gerrit-PatchSet: 4
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: kokoro 
Gerrit-CC: kokoro 
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: base: define is_iterable type trait

2023-06-27 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/71838?usp=email )



Change subject: base: define is_iterable type trait
..

base: define is_iterable type trait

Change-Id: I38bb0ddcbb95645797f1d20724b78aff3bef4580
---
M src/base/type_traits.hh
1 file changed, 16 insertions(+), 3 deletions(-)



diff --git a/src/base/type_traits.hh b/src/base/type_traits.hh
index 1fec93d..a42f786 100644
--- a/src/base/type_traits.hh
+++ b/src/base/type_traits.hh
@@ -27,8 +27,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */

-#ifndef __BASE_TYPETRAITS_HH__
-#define __BASE_TYPETRAITS_HH__
+#ifndef BASE_TYPETRAITS_HH
+#define BASE_TYPETRAITS_HH

 #include 
 #include 
@@ -92,6 +92,19 @@
 using MemberFunctionArgsTuple_t =
 typename MemberFunctionSignature::argsTuple_t;

+
+// iterable type trait
+template 
+struct is_iterable: std::false_type {};
+
+template 
+struct is_iterable())),
+decltype(end(std::declval()))>>: std::true_type {};
+
+template 
+constexpr bool is_iterable_v = is_iterable::value;
+
 } // namespace gem5

-#endif // __BASE_TYPETRAITS_HH__
+#endif // BASE_TYPETRAITS_HH

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/71838?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings?usp=email


Gerrit-MessageType: newchange
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I38bb0ddcbb95645797f1d20724b78aff3bef4580
Gerrit-Change-Number: 71838
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: base: Add Printer util class to force use of operator<< helpers

2023-06-27 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/71840?usp=email )



Change subject: base: Add Printer util class to force use of operator<<  
helpers

..

base: Add Printer util class to force use of operator<< helpers

Wrapping any value in a Printer instance before using operator<< will
force the use of stl_helpers::operator<<.

Change-Id: I7b505194eeabc3e0721effd9b5ce98f9e151b807
---
M src/base/stl_helpers/ostream_helpers.hh
1 file changed, 22 insertions(+), 1 deletion(-)



diff --git a/src/base/stl_helpers/ostream_helpers.hh  
b/src/base/stl_helpers/ostream_helpers.hh

index cee5fc0..d562a4d 100644
--- a/src/base/stl_helpers/ostream_helpers.hh
+++ b/src/base/stl_helpers/ostream_helpers.hh
@@ -41,6 +41,19 @@
 namespace gem5::stl_helpers
 {

+/*
+ * Wrap any object in a Printer object to force using a opExtract_impl  
printing

+ * function. This is not required for types that do not already enable
+ * operator<< in another namespace. However, to enable the special printing
+ * function for, e.g., raw pointers, those must be wrapped in a Printer.
+ */
+template
+struct Printer
+{
+Printer(const T& value): value{value} {}
+const T& value;
+};
+
 namespace opExtract_impl
 {

@@ -128,6 +141,13 @@
 return opExtractPrimDisp(os, p.get());
 }

+template 
+std::ostream&
+opExtractPrimDisp(std::ostream& os, const Printer& p)
+{
+return opExtractSecDisp(os, p.value);
+}
+
 template 
 constexpr bool isOpExtractNativelySupported = false;

@@ -179,7 +199,8 @@

 } // namespace opExtract_impl

-// Add "using stl_helpers::operator<<" in the scope where you want to use  
it.
+// use the Printer wrapper or add "using stl_helpers::operator<<" in the  
scope

+// where you want to use that operator<<.
 template
 std::enable_if_t, std::ostream&>
 operator<<(std::ostream& os, const T& v)

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/71840?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings?usp=email


Gerrit-MessageType: newchange
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I7b505194eeabc3e0721effd9b5ce98f9e151b807
Gerrit-Change-Number: 71840
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: base: define is_std_hash_enabled type trait

2023-06-27 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/71839?usp=email )



Change subject: base: define is_std_hash_enabled type trait
..

base: define is_std_hash_enabled type trait

Change-Id: I7ffb7f80a90006d6b8cd42bdf3d63e34c6dbda01
---
M src/base/type_traits.hh
1 file changed, 11 insertions(+), 0 deletions(-)



diff --git a/src/base/type_traits.hh b/src/base/type_traits.hh
index a42f786..c40696c 100644
--- a/src/base/type_traits.hh
+++ b/src/base/type_traits.hh
@@ -105,6 +105,17 @@
 template 
 constexpr bool is_iterable_v = is_iterable::value;

+// std::hash-enabled type trait
+template 
+struct is_std_hash_enabled: std::false_type {};
+
+template 
+struct is_std_hash_enabled())>>>: std::true_type {};
+
+template 
+constexpr bool is_std_hash_enabled_v = is_std_hash_enabled::value;
+
 } // namespace gem5

 #endif // BASE_TYPETRAITS_HH

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/71839?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings?usp=email


Gerrit-MessageType: newchange
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I7ffb7f80a90006d6b8cd42bdf3d63e34c6dbda01
Gerrit-Change-Number: 71839
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [XS] Change in gem5/gem5[develop]: sim: Deprecate EventWrapper in favour of MemberEventWrapper

2023-03-13 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67654?usp=email )


Change subject: sim: Deprecate EventWrapper in favour of MemberEventWrapper
..

sim: Deprecate EventWrapper in favour of MemberEventWrapper

Change-Id: I87363fb36cd998e7f0afeb25381e5b230a15b493
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67654
Reviewed-by: Jason Lowe-Power 
Maintainer: Jason Lowe-Power 
Reviewed-by: Daniel Carvalho 
Tested-by: kokoro 
---
M src/sim/eventq.hh
1 file changed, 2 insertions(+), 1 deletion(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved
  kokoro: Regressions pass
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved




diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index b46a25b..ff9d4bf 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -1129,7 +1129,8 @@
 };

 template 
-using EventWrapper = MemberEventWrapper;
+using EventWrapper [[deprecated("Use MemberEventWrapper instead")]]
+= MemberEventWrapper;

 class EventFunctionWrapper : public Event
 {

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67654?usp=email
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: I87363fb36cd998e7f0afeb25381e5b230a15b493
Gerrit-Change-Number: 67654
Gerrit-PatchSet: 4
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Jason Lowe-Power 
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


[gem5-dev] [S] Change in gem5/gem5[develop]: sim: Use ref constructor of MemberEventWrapper everywhere

2023-03-13 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67657?usp=email )


 (

2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.

 )Change subject: sim: Use ref constructor of MemberEventWrapper everywhere
..

sim: Use ref constructor of MemberEventWrapper everywhere

Change-Id: I77989aa7318142634c771c558293138e7b1e8e51
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67657
Maintainer: Bobby Bruce 
Tested-by: kokoro 
Reviewed-by: Daniel Carvalho 
---
M src/arch/sparc/isa.cc
M src/arch/sparc/ua2005.cc
M src/base/remote_gdb.cc
M src/dev/arm/smmu_v3.cc
M src/dev/arm/smmu_v3_deviceifc.cc
M src/dev/arm/smmu_v3_proc.cc
M src/mem/qos/mem_sink.cc
M src/systemc/core/kernel.cc
M src/systemc/core/scheduler.cc
9 files changed, 18 insertions(+), 18 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved
  Bobby Bruce: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/arch/sparc/isa.cc b/src/arch/sparc/isa.cc
index 38b3d1c..e7807c2 100644
--- a/src/arch/sparc/isa.cc
+++ b/src/arch/sparc/isa.cc
@@ -953,15 +953,15 @@
 UNSERIALIZE_SCALAR(hstick_cmp);

 if (tick_cmp) {
-tickCompare = new TickCompareEvent(this);
+tickCompare = new TickCompareEvent(*this);
 schedule(tickCompare, tick_cmp);
 }
 if (stick_cmp)  {
-sTickCompare = new STickCompareEvent(this);
+sTickCompare = new STickCompareEvent(*this);
 schedule(sTickCompare, stick_cmp);
 }
 if (hstick_cmp)  {
-hSTickCompare = new HSTickCompareEvent(this);
+hSTickCompare = new HSTickCompareEvent(*this);
 schedule(hSTickCompare, hstick_cmp);
 }
 }
diff --git a/src/arch/sparc/ua2005.cc b/src/arch/sparc/ua2005.cc
index 3f5372a..45cc9d7 100644
--- a/src/arch/sparc/ua2005.cc
+++ b/src/arch/sparc/ua2005.cc
@@ -107,7 +107,7 @@

   case MISCREG_TICK_CMPR:
 if (tickCompare == NULL)
-tickCompare = new TickCompareEvent(this);
+tickCompare = new TickCompareEvent(*this);
 setMiscRegNoEffect(miscReg, val);
 if ((tick_cmpr & ~mask(63)) && tickCompare->scheduled())
 cpu->deschedule(tickCompare);
@@ -122,7 +122,7 @@

   case MISCREG_STICK_CMPR:
 if (sTickCompare == NULL)
-sTickCompare = new STickCompareEvent(this);
+sTickCompare = new STickCompareEvent(*this);
 setMiscRegNoEffect(miscReg, val);
 if ((stick_cmpr & ~mask(63)) && sTickCompare->scheduled())
 cpu->deschedule(sTickCompare);
@@ -193,7 +193,7 @@

   case MISCREG_HSTICK_CMPR:
 if (hSTickCompare == NULL)
-hSTickCompare = new HSTickCompareEvent(this);
+hSTickCompare = new HSTickCompareEvent(*this);
 setMiscRegNoEffect(miscReg, val);
 if ((hstick_cmpr & ~mask(63)) && hSTickCompare->scheduled())
 cpu->deschedule(hSTickCompare);
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index 43f53d1..dd37a35 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -393,7 +393,7 @@
 BaseRemoteGDB::BaseRemoteGDB(System *_system, int _port) :
 incomingConnectionEvent(nullptr), incomingDataEvent(nullptr),
 _port(_port), fd(-1), sys(_system),
-connectEvent(this), disconnectEvent(this), trapEvent(this),
+connectEvent(*this), disconnectEvent(*this), trapEvent(this),
 singleStepEvent(*this)
 {}

diff --git a/src/dev/arm/smmu_v3.cc b/src/dev/arm/smmu_v3.cc
index 41f7424e..8ce8bd9 100644
--- a/src/dev/arm/smmu_v3.cc
+++ b/src/dev/arm/smmu_v3.cc
@@ -100,7 +100,7 @@
 deviceInterfaces(params.device_interfaces),
 commandExecutor(name() + ".cmd_exec", *this),
 regsMap(params.reg_map),
-processCommandsEvent(this)
+processCommandsEvent(*this)
 {
 fatal_if(regsMap.size() != SMMU_REG_SIZE,
 "Invalid register map size: %#x different than SMMU_REG_SIZE  
= %#x\n",
diff --git a/src/dev/arm/smmu_v3_deviceifc.cc  
b/src/dev/arm/smmu_v3_deviceifc.cc

index 166b85d..0966150 100644
--- a/src/dev/arm/smmu_v3_deviceifc.cc
+++ b/src/dev/arm/smmu_v3_deviceifc.cc
@@ -78,7 +78,7 @@
 deviceNeedsRetry(false),
 atsDeviceNeedsRetry(false),
 sendDeviceRetryEvent(*this),
-atsSendDeviceRetryEvent(this)
+atsSendDeviceRetryEvent(*this)
 {}

 void
diff --git a/src/dev/arm/smmu_v3_proc.cc b/src/dev/arm/smmu_v3_proc.cc
index ef3db5d..f0c2633 100644
--- a/src/dev/arm/smmu_v3_proc.cc
+++ b/src/dev/arm/smmu_v3_proc.cc
@@ -199,7 +199,7 @@
 void
 SMMUProcess::scheduleWakeup(Tick when)
 {
-auto *ep = new MemberEventWrapper<::wakeup> (this, true);
+auto *ep = new MemberEventWrapper<::wakeup> (*this, true);

 smmu.schedule(ep, when);
 }
diff --git a/src/mem/qos/mem_sink.cc b/src/mem/qos/mem_sink.cc
index b6b77ca..66b9451 100644
--- a/src/mem/qos/mem_sink.cc

[gem5-dev] [S] Change in gem5/gem5[develop]: sim: Switch from EventWrapper to MemberEventWrapper before deprec

2023-03-13 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67655?usp=email )


 (

2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.
 )Change subject: sim: Switch from EventWrapper to MemberEventWrapper  
before deprec

..

sim: Switch from EventWrapper to MemberEventWrapper before deprec

Change-Id: I25c81787d522a0dd063112b6727669da46e0f0e7
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67655
Reviewed-by: Daniel Carvalho 
Tested-by: kokoro 
Maintainer: Jason Lowe-Power 
---
M src/arch/sparc/isa.hh
M src/base/remote_gdb.hh
M src/dev/arm/smmu_v3.hh
M src/dev/arm/smmu_v3_deviceifc.hh
M src/dev/arm/smmu_v3_proc.cc
M src/mem/qos/mem_sink.hh
M src/sim/power_domain.hh
M src/systemc/core/kernel.hh
M src/systemc/core/scheduler.hh
M util/systemc/systemc_within_gem5/systemc_simple_object/feeder.hh
10 files changed, 19 insertions(+), 24 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved
  kokoro: Regressions pass
  Daniel Carvalho: Looks good to me, approved




diff --git a/src/arch/sparc/isa.hh b/src/arch/sparc/isa.hh
index 22bfba4..dee71d6 100644
--- a/src/arch/sparc/isa.hh
+++ b/src/arch/sparc/isa.hh
@@ -133,13 +133,13 @@
 void processSTickCompare();
 void processHSTickCompare();

-typedef EventWrapper TickCompareEvent;
+typedef MemberEventWrapper<::processTickCompare> TickCompareEvent;
 TickCompareEvent *tickCompare = nullptr;

-typedef EventWrapper STickCompareEvent;
+typedef MemberEventWrapper<::processSTickCompare>  
STickCompareEvent;

 STickCompareEvent *sTickCompare = nullptr;

-typedef EventWrapper  
HSTickCompareEvent;
+typedef MemberEventWrapper<::processHSTickCompare>  
HSTickCompareEvent;

 HSTickCompareEvent *hSTickCompare = nullptr;

 static const int NumGlobalRegs = 8;
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index 1c5cd9c..7981a13 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -274,8 +274,8 @@

 BaseGdbRegCache *regCachePtr = nullptr;

-EventWrapper connectEvent;
-EventWrapper  disconnectEvent;
+MemberEventWrapper<::connect> connectEvent;
+MemberEventWrapper<::detach>  disconnectEvent;

 class TrapEvent : public Event
 {
@@ -308,7 +308,7 @@

 // Single step.
 void singleStep();
-EventWrapper  
singleStepEvent;

+MemberEventWrapper<::singleStep> singleStepEvent;

 void clearSingleStep();
 void setSingleStep();
diff --git a/src/dev/arm/smmu_v3.hh b/src/dev/arm/smmu_v3.hh
index 25b91ff..8721352 100644
--- a/src/dev/arm/smmu_v3.hh
+++ b/src/dev/arm/smmu_v3.hh
@@ -167,7 +167,7 @@
 SMMUAction runProcessTiming(SMMUProcess *proc, PacketPtr pkt);

 void processCommands();
-EventWrapper processCommandsEvent;
+MemberEventWrapper<::processCommands> processCommandsEvent;

 void processCommand(const SMMUCommand );

diff --git a/src/dev/arm/smmu_v3_deviceifc.hh  
b/src/dev/arm/smmu_v3_deviceifc.hh

index c4ffa37..3152f8a 100644
--- a/src/dev/arm/smmu_v3_deviceifc.hh
+++ b/src/dev/arm/smmu_v3_deviceifc.hh
@@ -114,9 +114,7 @@
 bool atsDeviceNeedsRetry;

 SMMUDeviceRetryEvent sendDeviceRetryEvent;
-EventWrapper<
-SMMUv3DeviceInterface,
-::atsSendDeviceRetry>  
atsSendDeviceRetryEvent;
+MemberEventWrapper<::atsSendDeviceRetry>  
atsSendDeviceRetryEvent;


 Port& getPort(const std::string , PortID id) override;

diff --git a/src/dev/arm/smmu_v3_proc.cc b/src/dev/arm/smmu_v3_proc.cc
index 2cf2cf9..ef3db5d 100644
--- a/src/dev/arm/smmu_v3_proc.cc
+++ b/src/dev/arm/smmu_v3_proc.cc
@@ -199,8 +199,7 @@
 void
 SMMUProcess::scheduleWakeup(Tick when)
 {
-auto *ep = new EventWrapper<
-SMMUProcess, ::wakeup> (this, true);
+auto *ep = new MemberEventWrapper<::wakeup> (this, true);

 smmu.schedule(ep, when);
 }
diff --git a/src/mem/qos/mem_sink.hh b/src/mem/qos/mem_sink.hh
index d2310c6..bd42a9a 100644
--- a/src/mem/qos/mem_sink.hh
+++ b/src/mem/qos/mem_sink.hh
@@ -222,9 +222,7 @@
 void processNextReqEvent();

 /** Event wrapper to schedule next request handler function */
-EventWrapper<
-MemSinkCtrl,
-::processNextReqEvent> nextReqEvent;
+MemberEventWrapper<::processNextReqEvent> nextReqEvent;

 /**
  * Check if the read queue has room for more entries
diff --git a/src/sim/power_domain.hh b/src/sim/power_domain.hh
index 96233e4..1264d8f 100644
--- a/src/sim/power_domain.hh
+++ b/src/sim/power_domain.hh
@@ -151,7 +151,7 @@
 /**
  * Event to update the power states of the followers
  */
-EventWrapper
+MemberEventWrapper<::setFollowerPowerStates>
 pwrStateUpdateEvent;

   protected:
diff --git a/src/systemc/core/kernel.hh b/src/systemc/core/kernel.hh
index 9dba903..ec47569 100644
--- a/src/systemc/core/kernel.hh
+++ 

[gem5-dev] [S] Change in gem5/gem5[develop]: sim: Deprecate pointer version of MemberEventWrapper constructor

2023-03-13 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67656?usp=email )


Change subject: sim: Deprecate pointer version of MemberEventWrapper  
constructor

..

sim: Deprecate pointer version of MemberEventWrapper constructor

It makes no sense to initialize such event with nullptr. Favor the
reference version for safer behavior.

Change-Id: I695f41362a56aca98ceb52d49cf84be43f1465a2
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67656
Reviewed-by: Daniel Carvalho 
Tested-by: kokoro 
Maintainer: Daniel Carvalho 
---
M src/sim/eventq.hh
1 file changed, 10 insertions(+), 9 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index ff9d4bf..cf1734b 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -1095,16 +1095,12 @@
 static_assert(std::is_same_v,  
std::tuple<>>);


 public:
+[[deprecated("Use reference version of this constructor instead")]]
 MemberEventWrapper(CLASS *object,
bool del = false,
Priority p = Default_Pri):
-Event(p),
-Named(object->name() + ".wrapped_event"),
-mObject(object)
-{
-gem5_assert(mObject);
-if (del) setFlags(AutoDelete);
-}
+MemberEventWrapper{*object, del, p}
+{}

 /**
  * @brief Construct a new MemberEventWrapper object
@@ -1116,8 +1112,13 @@
 MemberEventWrapper(CLASS ,
bool del = false,
Priority p = Default_Pri):
-MemberEventWrapper(, del, p)
-{}
+Event(p),
+Named(object.name() + ".wrapped_event"),
+mObject()
+{
+if (del) setFlags(AutoDelete);
+gem5_assert(mObject);
+}

 void process() override {
 (mObject->*F)();

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67656?usp=email
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: I695f41362a56aca98ceb52d49cf84be43f1465a2
Gerrit-Change-Number: 67656
Gerrit-PatchSet: 4
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Jason Lowe-Power 
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


[gem5-dev] [M] Change in gem5/gem5[develop]: sim: Define a new MemberEventWrapper event class

2023-03-13 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67653?usp=email )


Change subject: sim: Define a new MemberEventWrapper event class
..

sim: Define a new MemberEventWrapper event class

This new event class simplifies the use of EventWrapper and aims at
superseeding it. EventWrapper has been redefined in terms of
MemberEventWrapper.

MemberEventWrapper makes use of the new type traits to simplify
template parameterization and encourage its use over SimpleEvent that
often wraps a lambda that merely calls a member function.

Change-Id: Ie59e4c51705b9c2b2faa27097678d7d85f5b99c6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67653
Reviewed-by: Jason Lowe-Power 
Tested-by: kokoro 
Maintainer: Daniel Carvalho 
Reviewed-by: Daniel Carvalho 
---
M src/sim/eventq.hh
1 file changed, 51 insertions(+), 23 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved
  Daniel Carvalho: Looks good to me, but someone else must approve; Looks  
good to me, approved

  kokoro: Regressions pass




diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index 62495bf..b46a25b 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -46,7 +46,9 @@

 #include "base/debug.hh"
 #include "base/flags.hh"
+#include "base/named.hh"
 #include "base/trace.hh"
+#include "base/type_traits.hh"
 #include "base/types.hh"
 #include "base/uncontended_mutex.hh"
 #include "debug/Event.hh"
@@ -1071,38 +1073,64 @@
 void setCurTick(Tick newVal) { eventq->setCurTick(newVal); }
 };

-template 
-class EventWrapper : public Event
+/**
+ * @brief Wrap a member function inside MemberEventWrapper to use it as an
+ * event callback. This wrapper should be prefered over  
EventFunctionWrapper

+ * for better performance and type safety.
+ *
+ * Wrapping a function *process* member of a class *klass* can be done by
+ * adding a member variable of the following type:
+ * MemberEventWrapper<::process>.
+ *
+ * It is required that klass::process takes no explicit argument and  
returns no

+ * value as these could not be handled by the event scheduler.
+ *
+ * @tparam F Pointer to the member function wrapped in this event.
+ */
+template 
+class MemberEventWrapper final: public Event, public Named
 {
-  private:
-T *object;
+using CLASS = MemberFunctionClass_t;
+static_assert(std::is_same_v>);
+static_assert(std::is_same_v,  
std::tuple<>>);


-  public:
-EventWrapper(T *obj, bool del = false, Priority p = Default_Pri)
-: Event(p), object(obj)
+public:
+MemberEventWrapper(CLASS *object,
+   bool del = false,
+   Priority p = Default_Pri):
+Event(p),
+Named(object->name() + ".wrapped_event"),
+mObject(object)
 {
-if (del)
-setFlags(AutoDelete);
+gem5_assert(mObject);
+if (del) setFlags(AutoDelete);
 }

-EventWrapper(T , bool del = false, Priority p = Default_Pri)
-: Event(p), object()
-{
-if (del)
-setFlags(AutoDelete);
+/**
+ * @brief Construct a new MemberEventWrapper object
+ *
+ * @param object instance of the object to call the wrapped member  
func on

+ * @param del if true, flag this event as AutoDelete
+ * @param p priority of this event
+ */
+MemberEventWrapper(CLASS ,
+   bool del = false,
+   Priority p = Default_Pri):
+MemberEventWrapper(, del, p)
+{}
+
+void process() override {
+(mObject->*F)();
 }

-void process() { (object->*F)(); }
-
-const std::string
-name() const
-{
-return object->name() + ".wrapped_event";
-}
-
-const char *description() const { return "EventWrapped"; }
+const char *description() const override { return "EventWrapped"; }
+private:
+CLASS *mObject;
 };

+template 
+using EventWrapper = MemberEventWrapper;
+
 class EventFunctionWrapper : public Event
 {
   private:

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67653?usp=email
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: Ie59e4c51705b9c2b2faa27097678d7d85f5b99c6
Gerrit-Change-Number: 67653
Gerrit-PatchSet: 4
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Jason Lowe-Power 
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


[gem5-dev] [M] Change in gem5/gem5[develop]: base: Create a gem5 type_traits.hh header

2023-03-13 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67652?usp=email )


Change subject: base: Create a gem5 type_traits.hh header
..

base: Create a gem5 type_traits.hh header

That header currently contains type traits that derive the class, the
return type and the arguments of a member function from a pointer to
that member function.

Change-Id: I41dd41056f507016219d6111d25c8cb4c2ad3439
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67652
Reviewed-by: Daniel Carvalho 
Maintainer: Daniel Carvalho 
Tested-by: kokoro 
---
A src/base/type_traits.hh
1 file changed, 97 insertions(+), 0 deletions(-)

Approvals:
  Daniel Carvalho: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/base/type_traits.hh b/src/base/type_traits.hh
new file mode 100644
index 000..1fec93d
--- /dev/null
+++ b/src/base/type_traits.hh
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2022 Arteris, Inc. and its applicable licensors and
+ * affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS  
IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,  
THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  
PURPOSE

+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF  
THE

+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __BASE_TYPETRAITS_HH__
+#define __BASE_TYPETRAITS_HH__
+
+#include 
+#include 
+
+namespace gem5
+{
+
+/*
+ * Type traits that enable inspecting the signature of a member function  
based

+ * on a pointer to that function. Specifically, these type traits provide a
+ * class_t, a return_t and  a argsTuple_t alias that correspond  
respectively to
+ * the class that the function is a member of, the return type of the  
member

+ * function and the list of parameters types packed in a tuple. Convenience
+ * Convenience template aliases are also provided.
+ *
+ * Example, assuming "struct Struct {void foo(int, bool);};":
+ *- MemberFunctionClass_t<::foo> is Struct.
+ *- MemberFunctionReturn_t<::foo> is void.
+ *- MemberFunctionArgsTuple_t<::foo> is std::tuple.
+ */
+
+template
+struct MemberFunctionSignature;
+template
+struct MemberFunctionSignature
+{
+using class_t = C;
+using return_t = R;
+using argsTuple_t = std::tuple;
+};
+template
+struct MemberFunctionSignature
+{
+using class_t = std::add_const_t;
+using return_t = R;
+using argsTuple_t = std::tuple;
+};
+template
+struct MemberFunctionSignature
+{
+using class_t = std::add_volatile_t;
+using return_t = R;
+using argsTuple_t = std::tuple;
+};
+template
+struct MemberFunctionSignature
+{
+using class_t = std::add_cv_t;
+using return_t = R;
+using argsTuple_t = std::tuple;
+};
+template
+using MemberFunctionClass_t =
+typename MemberFunctionSignature::class_t;
+
+template
+using MemberFunctionReturn_t =
+typename MemberFunctionSignature::return_t;
+
+template
+using MemberFunctionArgsTuple_t =
+typename MemberFunctionSignature::argsTuple_t;
+
+} // namespace gem5
+
+#endif // __BASE_TYPETRAITS_HH__

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67652?usp=email
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: I41dd41056f507016219d6111d25c8cb4c2ad3439
Gerrit-Change-Number: 67652
Gerrit-PatchSet: 4
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: kokoro 
Gerrit-CC: Jason Lowe-Power 
Gerrit-MessageType: merged

[gem5-dev] [S] Change in gem5/gem5[develop]: dev-amdgpu: Patch forgotten port after mem port owner deprecation

2023-02-07 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67631?usp=email )


Change subject: dev-amdgpu: Patch forgotten port after mem port owner  
deprecation

..

dev-amdgpu: Patch forgotten port after mem port owner deprecation

Change-Id: I82f88b8962d9f04521e549ca1383c42f2b5b3ffc
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67631
Maintainer: Bobby Bruce 
Reviewed-by: Jason Lowe-Power 
Maintainer: Jason Lowe-Power 
Tested-by: kokoro 
Reviewed-by: Bobby Bruce 
---
M src/mem/ruby/system/GPUCoalescer.cc
M src/mem/ruby/system/GPUCoalescer.hh
2 files changed, 18 insertions(+), 3 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, but someone else must approve; Looks  
good to me, approved

  kokoro: Regressions pass
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved




diff --git a/src/mem/ruby/system/GPUCoalescer.cc  
b/src/mem/ruby/system/GPUCoalescer.cc

index a0808fa..8bde3f7 100644
--- a/src/mem/ruby/system/GPUCoalescer.cc
+++ b/src/mem/ruby/system/GPUCoalescer.cc
@@ -190,7 +190,7 @@
  false, Event::Progress_Event_Pri),
   uncoalescedTable(this),
   deadlockCheckEvent([this]{ wakeup(); }, "GPUCoalescer deadlock  
check"),

-  gmTokenPort(name() + ".gmTokenPort", this)
+  gmTokenPort(name() + ".gmTokenPort")
 {
 m_store_waiting_on_load_cycles = 0;
 m_store_waiting_on_store_cycles = 0;
diff --git a/src/mem/ruby/system/GPUCoalescer.hh  
b/src/mem/ruby/system/GPUCoalescer.hh

index 1120947..dd28855 100644
--- a/src/mem/ruby/system/GPUCoalescer.hh
+++ b/src/mem/ruby/system/GPUCoalescer.hh
@@ -216,9 +216,9 @@
 class GMTokenPort : public TokenResponsePort
 {
   public:
-GMTokenPort(const std::string& name, ClockedObject *owner,
+GMTokenPort(const std::string& name,
 PortID id = InvalidPortID)
-: TokenResponsePort(name, owner, id)
+: TokenResponsePort(name, id)
 { }
 ~GMTokenPort() { }


--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67631?usp=email
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: I82f88b8962d9f04521e549ca1383c42f2b5b3ffc
Gerrit-Change-Number: 67631
Gerrit-PatchSet: 2
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Matthew Poremba 
Gerrit-Reviewer: kokoro 
Gerrit-CC: Jason Lowe-Power 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: mem-ruby: Optimize enum to string conversion in SLICC

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67676?usp=email )



Change subject: mem-ruby: Optimize enum to string conversion in SLICC
..

mem-ruby: Optimize enum to string conversion in SLICC

The result was previously returned in a brand new std::string every
time. std::strings are now cached in a static const array and returned
by const reference.

Change-Id: I5ef6e3ef94898bc606e29b950caef9ab32935da2
---
M src/mem/slicc/ast/EnumDeclAST.py
M src/mem/slicc/ast/StateDeclAST.py
M src/mem/slicc/symbols/Type.py
3 files changed, 24 insertions(+), 16 deletions(-)



diff --git a/src/mem/slicc/ast/EnumDeclAST.py  
b/src/mem/slicc/ast/EnumDeclAST.py

index 5ffc8bb..25fd124 100644
--- a/src/mem/slicc/ast/EnumDeclAST.py
+++ b/src/mem/slicc/ast/EnumDeclAST.py
@@ -66,7 +66,7 @@
 # Add the implicit State_to_string method - FIXME, this is a bit  
dirty

 func_id = "%s_to_string" % t.c_ident

-pairs = {"external": "yes"}
+pairs = {"external": "yes", "return_by_const_ref": "yes"}
 func = Func(
 self.symtab,
 func_id + "_" + t.c_ident,
diff --git a/src/mem/slicc/ast/StateDeclAST.py  
b/src/mem/slicc/ast/StateDeclAST.py

index f6e5d6e..ae50b82 100644
--- a/src/mem/slicc/ast/StateDeclAST.py
+++ b/src/mem/slicc/ast/StateDeclAST.py
@@ -65,7 +65,7 @@
 # Add the implicit State_to_string method - FIXME, this is a bit  
dirty

 func_id = "%s_to_string" % t.c_ident

-pairs = {"external": "yes"}
+pairs = {"external": "yes", "return_by_const_ref": "yes"}
 func = Func(
 self.symtab,
 func_id + "_" + t.ident,
diff --git a/src/mem/slicc/symbols/Type.py b/src/mem/slicc/symbols/Type.py
index a0bcd7b..797ced5 100644
--- a/src/mem/slicc/symbols/Type.py
+++ b/src/mem/slicc/symbols/Type.py
@@ -582,7 +582,7 @@
 ${{self.c_ident}} string_to_${{self.c_ident}}(const ::std::string& str);

 // Code to convert state to a string
-::std::string ${{self.c_ident}}_to_string(const ${{self.c_ident}}& obj);
+const ::std::string& ${{self.c_ident}}_to_string(const ${{self.c_ident}}&  
obj);


 // Code to increment an enumeration type
 ${{self.c_ident}} ++(${{self.c_ident}} );
@@ -735,29 +735,24 @@
 }

 // Code to convert state to a string
-std::string
+const std::string&
 ${{self.c_ident}}_to_string(const ${{self.c_ident}}& obj)
 {
-switch(obj) {
+static const std::array lut = {
 """
 )
-
-# For each field
+code.indent()
 code.indent()
 for enum in self.enums.values():
-code("  case ${{self.c_ident}}_${{enum.ident}}:")
-code('return "${{enum.ident}}";')
+code('"${{enum.ident}}",')
 code.dedent()
+code("};")
+code("return lut.at(obj);")
+code.dedent()
+code("}")

-# Trailer
 code(
 """
-  default:
-panic("Invalid range for type ${{self.c_ident}}");
-}
-// Appease the compiler since this function has a return value
-return "";
-}

 // Code to convert from a string to the enumeration
 ${{self.c_ident}}

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67676?usp=email
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: I5ef6e3ef94898bc606e29b950caef9ab32935da2
Gerrit-Change-Number: 67676
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: mem-ruby: Optimize MachineType_base_number calculation

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67674?usp=email )



Change subject: mem-ruby: Optimize MachineType_base_number calculation
..

mem-ruby: Optimize MachineType_base_number calculation

Values returned by MachineType_base_number can be computed once and
for all after ellaboration. Thus, they are stored in local static
variables and the initialization logic is guarded by a once-flag. The
function is now a simple switch during subsequent calls.

Change-Id: If93628851322566e58015c16267093640f526926
---
M src/mem/slicc/symbols/Type.py
1 file changed, 47 insertions(+), 26 deletions(-)



diff --git a/src/mem/slicc/symbols/Type.py b/src/mem/slicc/symbols/Type.py
index a8735a7..a0bcd7b 100644
--- a/src/mem/slicc/symbols/Type.py
+++ b/src/mem/slicc/symbols/Type.py
@@ -863,35 +863,42 @@
  */
 int
 ${{self.c_ident}}_base_number(const ${{self.c_ident}}& obj)
-{
-int base = 0;
-switch(obj) {
-"""
-)
-
-# For each field
+{""")
+ev = list(self.enums.values())
 code.indent()
-code("  case ${{self.c_ident}}_NUM:")
-for enum in reversed(list(self.enums.values())):
-# Check if there is a defined machine with this type
-if enum.primary:
-code(
-"base +=  
${{enum.ident}}_Controller::getNumControllers();"

-)
-else:
-code("base += 0;")
-code("[[fallthrough]];")
-code("  case ${{self.c_ident}}_${{enum.ident}}:")
-code("break;")
+# Caching hack. Controller instance counts are global and  
constant

+# anyway so why not abusing that by caching all values here ?
+# Caching is usefull as this function is called frequently  
during a

+# simulation (especially for MachineType).
+code("static bool initialized{false};")
+for e in ev:
+code("static int ${{self.c_ident}}_${{e.ident}}_base;")
+code("if (GEM5_UNLIKELY(!initialized)) {")
+code.indent()
+code("initialized = true;")
+for e0, e1 in zip(ev[:-1], ev[1:]):
+code("${{self.c_ident}}_${{e1.ident}}_base = ")
+code.indent()
+code("${{self.c_ident}}_${{e0.ident}}_base +")
+code("AbstractController::controllerCount("
+"${{self.c_ident}}_${{e0.ident}});")
+code.dedent()
 code.dedent()
+code("}")

-code(
-"""
-  default:
-panic("Invalid range for type ${{self.c_ident}}");
-}
-
-return base;
+code("switch(obj) {")
+code.indent()
+for enum in self.enums.values():
+code("case ${{self.c_ident}}_${{enum.ident}}: "
+"  return ${{self.c_ident}}_${{enum.ident}}_base;")
+code("case ${{self.c_ident}}_NUM: "
+ "return ${{self.c_ident}}_${{ev[-1].ident}}_base;")
+code('default: panic("Invalid range for type  
${{self.c_ident}}:"'

+ '" %d", int(obj));')
+code.dedent()
+code("}")
+code.dedent()
+code("""
 }

 /** \\brief returns the total number of components for each machine

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67674?usp=email
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: If93628851322566e58015c16267093640f526926
Gerrit-Change-Number: 67674
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: mem-ruby: Define AbstractController::controllerCount static func

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67673?usp=email )



Change subject: mem-ruby: Define AbstractController::controllerCount static  
func

..

mem-ruby: Define AbstractController::controllerCount static func

It does the same as getNumControllers() which is local to each machine
type.  controllerCount is accessible from everywhere based on enum
value instead of static type.

Change-Id: I486d772b3e195827fc82b72e3d8e5c93a8a637c8
---
M src/mem/ruby/slicc_interface/AbstractController.cc
M src/mem/ruby/slicc_interface/AbstractController.hh
M src/mem/slicc/symbols/StateMachine.py
3 files changed, 29 insertions(+), 2 deletions(-)



diff --git a/src/mem/ruby/slicc_interface/AbstractController.cc  
b/src/mem/ruby/slicc_interface/AbstractController.cc

index f7b01cf..2affadd 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.cc
+++ b/src/mem/ruby/slicc_interface/AbstractController.cc
@@ -53,6 +53,8 @@
 namespace ruby
 {

+std::map AbstractController::controllerCounts;
+
 AbstractController::AbstractController(const Params )
 : ClockedObject(p), Consumer(this), m_version(p.version),
   m_clusterID(p.cluster_id),
@@ -470,6 +472,12 @@
 }
 }

+uint32_t
+AbstractController::controllerCount(MachineType mt) {
+controllerCounts.try_emplace(mt, 0);
+return controllerCounts[mt];
+}
+
 bool
 AbstractController::MemoryPort::recvTimingResp(PacketPtr pkt)
 {
diff --git a/src/mem/ruby/slicc_interface/AbstractController.hh  
b/src/mem/ruby/slicc_interface/AbstractController.hh

index f483412..7d21351 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.hh
+++ b/src/mem/ruby/slicc_interface/AbstractController.hh
@@ -90,6 +90,8 @@
 NodeID getVersion() const { return m_machineID.getNum(); }
 MachineType getType() const { return m_machineID.getType(); }

+static uint32_t controllerCount(MachineType);
+
 void initNetworkPtr(Network* net_ptr) { m_net_ptr = net_ptr; }

 // return instance name
@@ -377,6 +379,8 @@
 bool m_waiting_mem_retry;
 bool m_mem_ctrl_waiting_retry;

+static std::map controllerCounts;
+
 /**
  * Port that forwards requests and receives responses from the
  * memory controller.
diff --git a/src/mem/slicc/symbols/StateMachine.py  
b/src/mem/slicc/symbols/StateMachine.py

index b5af9ca..c963ac2 100644
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -678,8 +678,10 @@
 for (int event = 0; event < ${ident}_Event_NUM; event++) {
 m_event_counters[event] = 0;
 }
-"""
-)
+
+controllerCounts.try_emplace(MachineType_${ident}, 0);
+++controllerCounts[MachineType_${ident}];
+""")
 code.dedent()
 code(
 """

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67673?usp=email
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: I486d772b3e195827fc82b72e3d8e5c93a8a637c8
Gerrit-Change-Number: 67673
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: mem-ruby: Add return_by_const_ref attribute to SLICC functions

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67675?usp=email )



Change subject: mem-ruby: Add return_by_const_ref attribute to SLICC  
functions

..

mem-ruby: Add return_by_const_ref attribute to SLICC functions

Change-Id: Ib7c12ca8072b6de04b6ea0252d76120e9be698cd
---
M src/mem/slicc/symbols/Func.py
1 file changed, 13 insertions(+), 0 deletions(-)



diff --git a/src/mem/slicc/symbols/Func.py b/src/mem/slicc/symbols/Func.py
index 4d25413..a536331 100644
--- a/src/mem/slicc/symbols/Func.py
+++ b/src/mem/slicc/symbols/Func.py
@@ -64,6 +64,8 @@
 void_type = self.symtab.find("void", Type)
 if "return_by_ref" in self and self.return_type != void_type:
 return_type += "&"
+elif "return_by_const_ref" in self and self.return_type !=  
void_type:

+return_type = f'const {return_type}&'
 elif "return_by_pointer" in self and self.return_type != void_type:
 return_type += "*"

@@ -117,6 +119,8 @@
 return_type = self.return_type.c_ident
 if "return_by_ref" in self and self.return_type != void_type:
 return_type += "&"
+elif "return_by_const_ref" in self and self.return_type !=  
void_type:

+return_type = f'const {return_type}&'
 if "return_by_pointer" in self and self.return_type != void_type:
 return_type += "*"


--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67675?usp=email
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: Ib7c12ca8072b6de04b6ea0252d76120e9be698cd
Gerrit-Change-Number: 67675
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: mem-ruby: Remove useless friendship between Link and Topology

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67671?usp=email )



Change subject: mem-ruby: Remove useless friendship between Link and  
Topology

..

mem-ruby: Remove useless friendship between Link and Topology

Change-Id: Ib652907054913ed72798e282a47d88c085fbd952
---
M src/mem/ruby/network/BasicLink.hh
1 file changed, 9 insertions(+), 4 deletions(-)



diff --git a/src/mem/ruby/network/BasicLink.hh  
b/src/mem/ruby/network/BasicLink.hh

index 08ae76c..ff41bff 100644
--- a/src/mem/ruby/network/BasicLink.hh
+++ b/src/mem/ruby/network/BasicLink.hh
@@ -77,8 +77,6 @@
   public:
 PARAMS(BasicExtLink);
 BasicExtLink(const Params );
-
-friend class Topology;
 };

 class BasicIntLink : public BasicLink
@@ -86,8 +84,6 @@
   public:
 PARAMS(BasicIntLink);
 BasicIntLink(const Params );
-
-friend class Topology;
 };

 } // namespace ruby

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67671?usp=email
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: Ib652907054913ed72798e282a47d88c085fbd952
Gerrit-Change-Number: 67671
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: mem-ruby: Add NodeID<->MachineID conversion funcs to MachineID

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67672?usp=email )



Change subject: mem-ruby: Add NodeID<->MachineID conversion funcs to  
MachineID

..

mem-ruby: Add NodeID<->MachineID conversion funcs to MachineID

This is a convenience function that enables convertion from global
NodeID to MachineID and vice-versa. If the provided node ID does not
convert to a machine ID (e.g., this is a switch), an error is
triggered.

Change-Id: I345d9de92f44638ed0908f3f7a889db01c60ba7b
---
M src/mem/ruby/common/MachineID.hh
1 file changed, 38 insertions(+), 0 deletions(-)



diff --git a/src/mem/ruby/common/MachineID.hh  
b/src/mem/ruby/common/MachineID.hh

index 949e59c..bda3ca7 100644
--- a/src/mem/ruby/common/MachineID.hh
+++ b/src/mem/ruby/common/MachineID.hh
@@ -67,6 +67,30 @@
 NodeID getNum() const { return num; }

 bool isValid() const { return type != MachineType_NUM; }
+
+NodeID toGlobalNodeID() const {
+return MachineType_base_number(getType()) + getNum();
+}
+
+static MachineID fromGlobalNodeID(NodeID id) {
+// inverse of toGlobalNodeID. Retrieves the global nodeID interval  
that
+// the argument belongs to, i.e., it's machine type. Then compute  
the
+// ofset of the argument in that interval, i.e., the version of  
that

+// machine.
+auto baseID = 0;
+auto machineTypeEnd = static_cast(MachineType_NUM);
+gem5_assert(machineTypeEnd > 0);
+for (int mt = 0; mt < machineTypeEnd; mt++) {
+auto mtNext = static_cast(mt+1);
+auto nextBaseID = MachineType_base_number(mtNext);
+if (id <= nextBaseID) {
+return {static_cast(mt), id - baseID};
+}
+baseID = nextBaseID;
+}
+throw std::runtime_error(
+"Invalid NodeID for conversion to  MachineID");
+}
 };

 inline std::string

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67672?usp=email
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: I345d9de92f44638ed0908f3f7a889db01c60ba7b
Gerrit-Change-Number: 67672
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: mem-ruby: Improve SLICC struct types generated print functions

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67668?usp=email )



Change subject: mem-ruby: Improve SLICC struct types generated print  
functions

..

mem-ruby: Improve SLICC struct types generated print functions

Import stl_helpers::operator<< in the printing function generated by
SLICC to benefit from operator<< helped types. This specifically
improves message printing.

Change-Id: I1e152d5c10fc328ebd527b75e4a9597330bf16be
---
M src/mem/slicc/symbols/Type.py
1 file changed, 15 insertions(+), 0 deletions(-)



diff --git a/src/mem/slicc/symbols/Type.py b/src/mem/slicc/symbols/Type.py
index c519026..d4c1cbe 100644
--- a/src/mem/slicc/symbols/Type.py
+++ b/src/mem/slicc/symbols/Type.py
@@ -450,6 +450,7 @@
 #include 
 #include 

+#include "base/stl_helpers.hh"
 #include "mem/ruby/protocol/${{self.c_ident}}.hh"
 #include "mem/ruby/system/RubySystem.hh"

@@ -463,6 +464,7 @@
 void
 ${{self.c_ident}}::print(std::ostream& out) const
 {
+using stl_helpers::operator<<;
 out << "[${{self.c_ident}}: ";
 """
 )

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67668?usp=email
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: I1e152d5c10fc328ebd527b75e4a9597330bf16be
Gerrit-Change-Number: 67668
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: base: Generalize findLsbSet to std::bitset

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67670?usp=email )



Change subject: base: Generalize findLsbSet to std::bitset
..

base: Generalize findLsbSet to std::bitset

Change-Id: I2ec59ab9cda2243666def09e3414d8ef75197d49
---
M src/base/bitfield.hh
1 file changed, 63 insertions(+), 26 deletions(-)



diff --git a/src/base/bitfield.hh b/src/base/bitfield.hh
index 288c5ca..645a77b 100644
--- a/src/base/bitfield.hh
+++ b/src/base/bitfield.hh
@@ -41,9 +41,11 @@
 #ifndef __BASE_BITFIELD_HH__
 #define __BASE_BITFIELD_HH__

+#include 
 #include 
 #include 
 #include 
+#include 
 #include 

 namespace gem5
@@ -289,38 +291,64 @@

 /**
  * Returns the bit position of the LSB that is set in the input
+ * That function will either use a builting that exploit a "count trailing
+ * zeros" instruction or use a bit-fidling algorithm explained bellow.
  *
  * @ingroup api_bitfield
  */
 constexpr int
-findLsbSet(uint64_t val)
+findLsbSet(uint64_t val) {
+if (val == 0) return 64;
+#ifndef __has_builtin
+#define __has_builtin(foo) 0
+#endif
+#if defined(__GNUC__) || \
+(defined(__clang__) && __has_builtin(__builtin_ctz))
+if constexpr (sizeof(unsigned long long) == sizeof(val)) {
+return __builtin_ctzll(val);
+}
+#endif
+// Create a mask with trailing zeros flipped to 1, lsbset flipped to 0  
and

+// the rest unchanged. This effectively is equivalent to doing -1.
+// e.g.: 0101000 - 1 = 0100111
+auto mask = val - 1;
+// This will create a mask of ones from lsb set to last bit
+// e.g.: 0101000 ^ 0100111 = 
+auto masked = val ^ mask;
+// Shift that mask to that there is a 1 where there was 0 after the  
lsb set

+// before
+// e.g.:  >> 1 = 0111 (val is 0101000 in the example)
+auto ones = masked >> 1;
+// Number of bit set is the lsb set. This operation should be  
optimized by

+// the compiler without unsing intrinsics.
+return std::bitset<64>(ones).count();
+}
+
+template
+constexpr int
+findLsbSet(std::bitset bs)
 {
-int lsb = 0;
-if (!val)
-return sizeof(val) * 8;
-if (!bits(val, 31, 0)) {
-lsb += 32;
-val >>= 32;
+if constexpr (N <= 64) {
+return findLsbSet(bs.to_ullong());
+} else {
+if (bs.none()) return N;
+// Mask of ones
+constexpr std::bitset  
mask(std::numeric_limits::max());

+// Is the lsb set in the rightmost 64 bits ?
+auto nextQword{bs & mask};
+int i{0};
+while (nextQword.none()) {
+// If yes, shift by 64 bits and repeat
+i += 64;
+bs >>= 64;
+nextQword = bs & mask;
+}
+// If yes, account for the the i 64-bit shifts and add the  
remaining
+// using the 4 bit implementation. Store in intermediate variable  
to

+// ensure valid conversion from ullong to uint64_t.
+uint64_t remaining{nextQword.to_ullong()};
+return i + findLsbSet(remaining);
 }
-if (!bits(val, 15, 0)) {
-lsb += 16;
-val >>= 16;
-}
-if (!bits(val, 7, 0)) {
-lsb += 8;
-val >>= 8;
-}
-if (!bits(val, 3, 0)) {
-lsb += 4;
-val >>= 4;
-}
-if (!bits(val, 1, 0)) {
-lsb += 2;
-val >>= 2;
-}
-if (!bits(val, 0, 0))
-lsb += 1;
-return lsb;
 }

 /**

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67670?usp=email
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: I2ec59ab9cda2243666def09e3414d8ef75197d49
Gerrit-Change-Number: 67670
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: mem-ruby: Better support of external types in SLICC

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67669?usp=email )



Change subject: mem-ruby: Better support of external types in SLICC
..

mem-ruby: Better support of external types in SLICC

It is now possible to import external C++ types to SLICC without
enforcing name matching between the SLICC type, the C++ type and the
header name/location.  Also, struct members can now be defaulted
(assignment, as currently supported) or constructed.

Change-Id: I2230dbf4293c7b3747eef937d98a29f93630f07b
---
M src/mem/slicc/symbols/SymbolTable.py
M src/mem/slicc/symbols/Type.py
2 files changed, 59 insertions(+), 28 deletions(-)



diff --git a/src/mem/slicc/symbols/SymbolTable.py  
b/src/mem/slicc/symbols/SymbolTable.py

index 4b06be5..a332a44 100644
--- a/src/mem/slicc/symbols/SymbolTable.py
+++ b/src/mem/slicc/symbols/SymbolTable.py
@@ -143,7 +143,10 @@

 for symbol in self.sym_vec:
 if isinstance(symbol, Type) and not symbol.isPrimitive:
-code('#include "mem/ruby/protocol/${{symbol.c_ident}}.hh"')
+if 'header' in symbol:
+code(f'#include "{symbol["header"]}"')
+else:
+ 
code('#include "mem/ruby/protocol/${{symbol.c_ident}}.hh"')


 code.write(path, "Types.hh")

diff --git a/src/mem/slicc/symbols/Type.py b/src/mem/slicc/symbols/Type.py
index d4c1cbe..a8735a7 100644
--- a/src/mem/slicc/symbols/Type.py
+++ b/src/mem/slicc/symbols/Type.py
@@ -50,7 +50,11 @@
 ):
 super().__init__(symtab, ident, location, type, code, pairs,  
machine)

 self.init_code = init_code
-self.real_c_type = self.type.c_ident
+self.real_c_type = (
+self.type.c_ident
+if "external_name" not in self.type
+else self.type["external_name"]
+)
 if "template" in pairs:
 self.real_c_type += pairs["template"]

@@ -65,7 +69,9 @@
 class Type(Symbol):
 def __init__(self, table, ident, location, pairs, machine=None):
 super().__init__(table, ident, location, pairs)
-self.c_ident = ident
+self.c_ident = (
+ident if "external_name" not in pairs else  
pairs["external_name"]

+)
 self.abstract_ident = ""
 if machine:
 if self.isExternal or self.isPrimitive:
@@ -234,7 +240,9 @@
 )

 for dm in self.data_members.values():
-if not dm.type.isPrimitive:
+if "header" in dm.type:
+code(f'#include "{dm.type["header"]}"')
+elif not dm.type.isPrimitive:
 code('#include "mem/ruby/protocol/$0.hh"', dm.type.c_ident)

 parent = ""
@@ -259,29 +267,33 @@
 )

 if self.isMessage:
-code("(Tick curTime) : %s(curTime) {" % self["interface"])
+code("\t(Tick curTime): %s(curTime)" % self["interface"])
+firstInitChar = ","
 else:
-code("()\n\t\t{")
+code("\t()")
+firstInitChar = ":"

 code.indent()
-if not self.isGlobal:
-code.indent()
+if not self.isGlobal and self.data_members:
+init = []
 for dm in self.data_members.values():
 ident = dm.ident
 if "default" in dm:
 # look for default value
-code(
-'m_$ident = ${{dm["default"]}}; // default for  
this field'

-)
+init.append(f'm_{ident}{{{dm["default"]}}}')
 elif "default" in dm.type:
 # Look for the type default
-tid = dm.real_c_type
-code('m_$ident = ${{dm.type["default"]}};')
-code(" // default value of $tid")
+init.append(f'm_{ident}{{{dm.type["default"]}}}')
+elif "constructor" in dm:
+init.append(f'm_{ident}{{{dm["constructor"]}}}')
+elif "constructor" in dm.type:
+init.append(f'm_{ident}{{{dm.type["constructor"]}}}')
 else:
-code("// m_$ident has no default")
+init.append(f"m_{ident}{{}}")
+code.indent()
+code(firstInitChar + ",\n".join(init) + "\n")
 code.dedent()
-code("}")
+code("{}")

 #  Copy constructor 
 code("${{self.c_ident}}(const ${{self.c_ident}}&) = default;")
@@ -297,27 +309,29 @@
 "const %s& local_%s" % (dm.real_c_type, dm.ident)
 for dm in self.data_members.values()
 ]
-params = ", ".join(params)
-
 if self.isMessage:
-params = "const Tick curTime, " + params
+params.insert(0, "const Tick curTime")
+ 

[gem5-dev] [S] Change in gem5/gem5[develop]: base: Enable stl_helpers::operator<< in _formatString

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67667?usp=email )



Change subject: base: Enable stl_helpers::operator<< in _formatString
..

base: Enable stl_helpers::operator<< in _formatString

The string format (%s) eventually relies on bare operator<< to
display any type T. This gives the opportunity to use the helpers in
stl_helpers. This patch enables printing enums, pairs, tuples,
vectors, maps and others in a PRINTF debug macro without any extra
manual operation.

Change-Id: I8ac85133ebadcb95354598c1cfe687d8fffb89e2
---
M src/base/cprintf_formats.hh
1 file changed, 18 insertions(+), 0 deletions(-)



diff --git a/src/base/cprintf_formats.hh b/src/base/cprintf_formats.hh
index 02ba496..b2cb841 100644
--- a/src/base/cprintf_formats.hh
+++ b/src/base/cprintf_formats.hh
@@ -33,6 +33,8 @@
 #include 
 #include 

+#include "base/stl_helpers.hh"
+
 namespace gem5
 {

@@ -220,6 +222,7 @@
 static inline void
 _formatString(std::ostream , const T , Format )
 {
+using stl_helpers::operator<<;
 if (fmt.width > 0) {
 std::stringstream foo;
 foo << data;

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67667?usp=email
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: I8ac85133ebadcb95354598c1cfe687d8fffb89e2
Gerrit-Change-Number: 67667
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: python: Fix namespaced enums params code generation

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67662?usp=email )



Change subject: python: Fix namespaced enums params code generation
..

python: Fix namespaced enums params code generation

The wrapper_name parameter was not properly handled. Enums were always
generated in the enums namespace even if required differently by
wrapper_name.

Change-Id: I366846ce39dfe10effc2cc145e7772a3fd171b92
---
M build_tools/enum_cc.py
M src/python/m5/params.py
2 files changed, 18 insertions(+), 7 deletions(-)



diff --git a/build_tools/enum_cc.py b/build_tools/enum_cc.py
index 5d82b40..fbf0f51 100644
--- a/build_tools/enum_cc.py
+++ b/build_tools/enum_cc.py
@@ -96,10 +96,8 @@
 """
 )
 else:
-code(
-"""namespace enums
-{"""
-)
+code('''namespace ${wrapper_name}
+{''')
 code.indent(1)
 code("const char *${name}Strings[Num_${name}] =")

@@ -112,7 +110,7 @@

 if not enum.wrapper_is_struct and not enum.is_class:
 code.dedent(1)
-code("} // namespace enums")
+code('} // namespace ${wrapper_name}')

 code("} // namespace gem5")

diff --git a/src/python/m5/params.py b/src/python/m5/params.py
index e76380b..1350d6f 100644
--- a/src/python/m5/params.py
+++ b/src/python/m5/params.py
@@ -1463,8 +1463,8 @@
 if cls.is_class:
 cls.cxx_type = "%s" % name
 else:
-cls.cxx_type = "enums::%s" % name
-
+scope = init_dict.get('wrapper_name', 'enums')
+cls.cxx_type = f"{scope}::{name}"
 super().__init__(name, bases, init_dict)



--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67662?usp=email
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: I366846ce39dfe10effc2cc145e7772a3fd171b92
Gerrit-Change-Number: 67662
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: base: Provide several hash implementation for common types

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67663?usp=email )



Change subject: base: Provide several hash implementation for common types
..

base: Provide several hash implementation for common types

These types include std::pair, std::tuple, all iterable types and any
composition of these. Convenience hash factory and computation
functions are also provided.

These functions are in the stl_helpers namespace and must not move to
::std which would cause undefined behaviour. This is because
specialization of std templates for std or native types (or
composition of these) is undefined behaviour. This inconvenience can't
be circumvented for generic code. Users are free to bring these hash
implementations to namespace std after specialization for their own
non-std and non-native types.

Change-Id: Ifd0f0b64e5421d5d44890eb25428cc9c53484eb3
---
M src/base/stl_helpers.hh
1 file changed, 126 insertions(+), 0 deletions(-)



diff --git a/src/base/stl_helpers.hh b/src/base/stl_helpers.hh
index d12f266..07aceb1 100644
--- a/src/base/stl_helpers.hh
+++ b/src/base/stl_helpers.hh
@@ -31,6 +31,7 @@

 #include 
 #include 
+#include 
 #include 
 #include 

@@ -76,6 +77,110 @@
 return out;
 }

+namespace hash_impl {
+// iterable type trait
+template 
+constexpr bool is_iterable = false;
+
+template 
+constexpr bool is_iterable())),
+decltype(end(std::declval()))>> = true;
+
+// std::hash-enabled type trait
+template 
+constexpr bool is_std_hash_enabled = false;
+template 
+constexpr bool is_std_hash_enabled())>> = true;
+
+// Hash combination function stollen from boost::hash_combine
+// Has the reputation to be a decent all-rounder.
+template
+size_t hash_combine(const T& h, const U&... tail) {
+if constexpr (sizeof...(U) == 0) {
+return h;
+} else {
+auto h1 = hash_combine(tail...);
+return h ^ (h1 + 0x9e3779b9ull + (h << 6) + (h >> 2));
+}
+}
+
+// SFINAE-enabled hash functor
+template
+struct hash;
+
+// Reuse std::hash whenever possible
+template
+struct hash>>: std::hash
+{};
+
+// Enable type deduction for hash object construction
+template
+constexpr auto make_hash_for(const T&) {
+return hash();
+}
+
+// Compute a hash without the hassle of constructing a hash functor
+template
+constexpr auto hash_value(const T& v) {
+return make_hash_for(v)(v);
+}
+
+// Hash for tuple
+template
+struct hash>
+{
+constexpr size_t operator()(const std::tuple& t) const {
+if constexpr (sizeof...(T) == 0) {
+return 0;
+} else {
+return std::apply([&](const auto&... e){
+   return hash_combine(hash_value(e)...);
+}, t);
+}
+}
+};
+
+// Hash for pairs (based on hash for 2-uple)
+template
+struct hash>
+{
+constexpr size_t operator()(const std::pair& p) const {
+return hash_value(std::tie(p.first, p.second));
+}
+};
+
+// Hash for any iterable of stl_helpers::hash-enabled types.
+template
+struct hash>>
+{
+constexpr size_t operator()(const T& t) const {
+if (begin(t) == end(t)) return 0;
+auto b = begin(t);
+auto e = end(t);
+return std::accumulate(next(b), e, hash_value(*b),
+[](const auto& acc, const auto& val) {
+return hash_combine(acc, hash_value(val));
+});
+}
+};
+
+template
+constexpr bool is_hash_enabled = false;
+
+template 
+constexpr bool is_hash_enabled()(std::declval()))>> = true;
+
+} // namespace hash_impl
+
+// Export useful hash_impl functions
+using hash_impl::hash;
+using hash_impl::make_hash_for;
+using hash_impl::hash_value;
+using hash_impl::is_hash_enabled;
+
 } // namespace stl_helpers
 } // namespace gem5


--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67663?usp=email
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: Ifd0f0b64e5421d5d44890eb25428cc9c53484eb3
Gerrit-Change-Number: 67663
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: mem-ruby: Fix of an address bug in MESI_Two_Level-dir.sm

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67661?usp=email )



Change subject: mem-ruby: Fix of an address bug in MESI_Two_Level-dir.sm
..

mem-ruby: Fix of an address bug in MESI_Two_Level-dir.sm

Physical access address and line address were mixed up in
qw_queueMemoryWBRequest_partial

Change-Id: I0b238ffc59d2bb3de221d96905c75b7616eac964
---
M src/mem/ruby/protocol/MESI_Two_Level-dir.sm
1 file changed, 13 insertions(+), 1 deletion(-)



diff --git a/src/mem/ruby/protocol/MESI_Two_Level-dir.sm  
b/src/mem/ruby/protocol/MESI_Two_Level-dir.sm

index aa61424..4eca48f 100644
--- a/src/mem/ruby/protocol/MESI_Two_Level-dir.sm
+++ b/src/mem/ruby/protocol/MESI_Two_Level-dir.sm
@@ -365,7 +365,7 @@
  desc="Queue off-chip writeback request") {
 peek(requestNetwork_in, RequestMsg) {
   enqueue(memQueue_out, MemoryMsg, to_mem_ctrl_latency) {
-out_msg.addr := address;
+out_msg.addr := tbe.PhysicalAddress;
 out_msg.Type := MemoryRequestType:MEMORY_WB;
 out_msg.Sender := machineID;
 out_msg.MessageSize := MessageSizeType:Writeback_Data;

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67661?usp=email
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: I0b238ffc59d2bb3de221d96905c75b7616eac964
Gerrit-Change-Number: 67661
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: base: stl_hlp::unordered_{map,set} with stl_hlp::hash by default

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67664?usp=email )



Change subject: base: stl_hlp::unordered_{map,set} with stl_hlp::hash by  
default

..

base: stl_hlp::unordered_{map,set} with stl_hlp::hash by default

Change-Id: Iad01d7fa6ff6293a2d931ba79ad3550c6e44
---
M src/base/stl_helpers.hh
1 file changed, 31 insertions(+), 0 deletions(-)



diff --git a/src/base/stl_helpers.hh b/src/base/stl_helpers.hh
index 07aceb1..f14f109 100644
--- a/src/base/stl_helpers.hh
+++ b/src/base/stl_helpers.hh
@@ -33,6 +33,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 

 #include "base/compiler.hh"
@@ -181,6 +183,26 @@
 using hash_impl::hash_value;
 using hash_impl::is_hash_enabled;

+/*
+ * Provide unordered_map and unordered_set with stl_helpers::hash  
functions.
+ * These aliases enable clean use of stl_helpers::hash as default Hash  
template

+ * parameter.
+ */
+template<
+typename Key,
+typename T,
+typename Hash = hash,
+typename KeyEqual = std::equal_to,
+typename Allocator = std::allocator< std::pair >>
+using unordered_map = std::unordered_mapAllocator>;

+
+template<
+typename Key,
+typename Hash = hash,
+typename KeyEqual = std::equal_to,
+typename Allocator = std::allocator>
+using unordered_set = std::unordered_set;
+
 } // namespace stl_helpers
 } // namespace gem5


--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67664?usp=email
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: Iad01d7fa6ff6293a2d931ba79ad3550c6e44
Gerrit-Change-Number: 67664
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: base: Provide stl_helpers::operator<< for more types

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67666?usp=email )



Change subject: base: Provide stl_helpers::operator<< for more types
..

base: Provide stl_helpers::operator<< for more types

This operator can be safely brought in scope when needed with "using
stl_helpers::operator<<".

In order to provide a specialization for operator<< with
stl_helpers-enabled types without loosing the hability to use it with
other types, a dual-dispatch mechanism is used. The only entry point
in the system is through a primary dispatch function that won't
resolve for non-helped types. Then, recursive calls go through the
secondary dispatch interface that sort between helped and non-helped
types. Helped typed will enter the system back through the primary
dispatch interface while other types will look for operator<< through
regular lookup, especially ADL.

Change-Id: I1609dd6e85e25764f393458d736ec228e025da32
---
M src/base/stl_helpers.hh
1 file changed, 104 insertions(+), 28 deletions(-)



diff --git a/src/base/stl_helpers.hh b/src/base/stl_helpers.hh
index f14f109..c26270a 100644
--- a/src/base/stl_helpers.hh
+++ b/src/base/stl_helpers.hh
@@ -38,6 +38,7 @@
 #include 

 #include "base/compiler.hh"
+#include "magic_enum/magic_enum.hh"

 namespace gem5
 {
@@ -45,38 +46,91 @@
 namespace stl_helpers
 {

-template 
-struct IsHelpedContainer : public std::false_type {};
+namespace opExtract_impl {

-template 
-struct IsHelpedContainer> : public std::true_type {};
-
-template 
-constexpr bool IsHelpedContainerV = IsHelpedContainer::value;
-
-/**
- * Write out all elements in an stl container as a space separated
- * list enclosed in square brackets
- *
- * @ingroup api_base_utils
+/*
+ * In order to provide a specialization for operator<< with  
stl_helpers-enabled

+ * types
+ * without loosing the hability to use it with other types, a dual-dispatch
+ * mechanism is used. The only entry point in the system is through a  
primary
+ * dispatch function that won't resolve for non-helped types. Then,  
recursive
+ * calls go through the secondary dispatch interface that sort between  
helped
+ * and non-helped types. Helped typed will enter the system back through  
the

+ * primary dispatch interface while other types will look for operator<<
+ * through regular lookup, especially ADL.
  */

-template 
-std::enable_if_t, std::ostream &>
-operator<<(std::ostream& out, const T )
+template
+std::ostream&
+opExtractSecDisp(std::ostream& os, const T& v);
+
+template 
+std::enable_if_t,
+std::ostream&>
+opExtractPrimDisp(std::ostream& os, const E& e)
 {
-out << "[ ";
-bool first = true;
-auto printer = [, ](const auto ) {
-if (first)
-out << elem;
-else
-out << " " << elem;
-};
-std::for_each(t.begin(), t.end(), printer);
-out << " ]";
-out << std::flush;
-return out;
+return os << magic_enum::enum_name(e);
+}
+
+template 
+std::ostream&
+opExtractPrimDisp(std::ostream& os, const std::tuple& p)
+{
+std::apply([&](auto&&... e) {
+std::size_t n{0};
+os << '(';
+((opExtractSecDisp(os, e) << (++n !=  
sizeof...(T) ? ", " : "")), ...);

+os << ')';
+}, p);
+return os;
+}
+
+template 
+std::ostream&
+opExtractPrimDisp(std::ostream& os, const std::pair& p)
+{
+return opExtractPrimDisp(os, std::tie(p.first, p.second));
+}
+
+template 
+std::ostream&
+opExtractPrimDisp(std::ostream& os, const std::vector& v)
+{
+os << "[ ";
+for (auto& e: v) {
+os << e << ' ';
+}
+return os << ']';
+}
+
+template 
+constexpr bool isOpExtractHelped = false;
+
+template 
+constexpr bool isOpExtractHelped(),
+  std::declval()))>> = true;
+
+template
+std::ostream&
+opExtractSecDisp(std::ostream& os, const T& v)
+{
+if constexpr (isOpExtractHelped) {
+return opExtractPrimDisp(os, v);
+} else {
+return os << v;
+}
+}
+
+} // namespace opExtract_impl
+
+// Add "using stl_helpers::operator<<" in the scope where you want to use  
it.

+template
+std::enable_if_t, std::ostream&>
+operator<<(std::ostream& os, const T& v)
+{
+return opExtract_impl::opExtractPrimDisp(os, v);
 }

 namespace hash_impl {

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67666?usp=email
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: I1609dd6e85e25764f393458d736ec228e025da32
Gerrit-Change-Number: 67666
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: sim: Deprecate EventWrapper in favour of MemberEventWrapper

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67654?usp=email )



Change subject: sim: Deprecate EventWrapper in favour of MemberEventWrapper
..

sim: Deprecate EventWrapper in favour of MemberEventWrapper

Change-Id: I87363fb36cd998e7f0afeb25381e5b230a15b493
---
M src/sim/eventq.hh
1 file changed, 11 insertions(+), 1 deletion(-)



diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index 3eefbd3..36b2245 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -1105,7 +1105,8 @@
 };

 template 
-using EventWrapper = MemberEventWrapper;
+using EventWrapper [[deprecated("Use MemberEventWrapper instead")]]
+= MemberEventWrapper;

 class EventFunctionWrapper : public Event
 {

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67654?usp=email
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: I87363fb36cd998e7f0afeb25381e5b230a15b493
Gerrit-Change-Number: 67654
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: mem-ruby: Switch to dequeueMemRspQueue() in all Ruby protocols

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67659?usp=email )



Change subject: mem-ruby: Switch to dequeueMemRspQueue() in all Ruby  
protocols

..

mem-ruby: Switch to dequeueMemRspQueue() in all Ruby protocols

Change-Id: I33bca345d985618e3fca62e9ddd5bcc3ad8226a3
---
M src/learning_gem5/part3/MSI-dir.sm
M src/mem/ruby/protocol/MESI_Two_Level-dir.sm
M src/mem/ruby/protocol/MI_example-dir.sm
M src/mem/ruby/protocol/MOESI_AMD_Base-Region-dir.sm
M src/mem/ruby/protocol/MOESI_AMD_Base-dir.sm
M src/mem/ruby/protocol/MOESI_AMD_Base-probeFilter.sm
M src/mem/ruby/protocol/MOESI_CMP_directory-dir.sm
M src/mem/ruby/protocol/MOESI_CMP_token-dir.sm
M src/mem/ruby/protocol/MOESI_hammer-dir.sm
M src/mem/ruby/protocol/RubySlicc_Defines.sm
M src/mem/ruby/protocol/chi/CHI-mem.sm
11 files changed, 21 insertions(+), 10 deletions(-)



diff --git a/src/learning_gem5/part3/MSI-dir.sm  
b/src/learning_gem5/part3/MSI-dir.sm

index ca5ea3e..70d9601 100644
--- a/src/learning_gem5/part3/MSI-dir.sm
+++ b/src/learning_gem5/part3/MSI-dir.sm
@@ -448,7 +448,7 @@
 }

 action(popMemQueue, "pM", desc="Pop the memory queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
 }

 // Stalling actions
diff --git a/src/mem/ruby/protocol/MESI_Two_Level-dir.sm  
b/src/mem/ruby/protocol/MESI_Two_Level-dir.sm

index 9d69755..aa61424 100644
--- a/src/mem/ruby/protocol/MESI_Two_Level-dir.sm
+++ b/src/mem/ruby/protocol/MESI_Two_Level-dir.sm
@@ -299,7 +299,7 @@
   }

   action(l_popMemQueue, "q", desc="Pop off-chip request queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   action(kd_wakeUpDependents, "kd", desc="wake-up dependents") {
diff --git a/src/mem/ruby/protocol/MI_example-dir.sm  
b/src/mem/ruby/protocol/MI_example-dir.sm

index 11d2862..bbaa7d0 100644
--- a/src/mem/ruby/protocol/MI_example-dir.sm
+++ b/src/mem/ruby/protocol/MI_example-dir.sm
@@ -523,7 +523,7 @@
   }

   action(l_popMemQueue, "q", desc="Pop off-chip request queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   // TRANSITIONS
diff --git a/src/mem/ruby/protocol/MOESI_AMD_Base-Region-dir.sm  
b/src/mem/ruby/protocol/MOESI_AMD_Base-Region-dir.sm

index f16c257..ec8ffe6 100644
--- a/src/mem/ruby/protocol/MOESI_AMD_Base-Region-dir.sm
+++ b/src/mem/ruby/protocol/MOESI_AMD_Base-Region-dir.sm
@@ -1397,7 +1397,7 @@
   }

   action(pm_popMemQueue, "pm", desc="pop mem queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   action(pt_popTriggerQueue, "pt", desc="pop trigger queue") {
diff --git a/src/mem/ruby/protocol/MOESI_AMD_Base-dir.sm  
b/src/mem/ruby/protocol/MOESI_AMD_Base-dir.sm

index 3b38e3b..4dd03a1 100644
--- a/src/mem/ruby/protocol/MOESI_AMD_Base-dir.sm
+++ b/src/mem/ruby/protocol/MOESI_AMD_Base-dir.sm
@@ -1169,7 +1169,7 @@
   }

   action(pm_popMemQueue, "pm", desc="pop mem queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   action(pt_popTriggerQueue, "pt", desc="pop trigger queue") {
diff --git a/src/mem/ruby/protocol/MOESI_AMD_Base-probeFilter.sm  
b/src/mem/ruby/protocol/MOESI_AMD_Base-probeFilter.sm

index 8608608..5e815a7 100644
--- a/src/mem/ruby/protocol/MOESI_AMD_Base-probeFilter.sm
+++ b/src/mem/ruby/protocol/MOESI_AMD_Base-probeFilter.sm
@@ -1103,7 +1103,7 @@
   }

   action(pm_popMemQueue, "pm", desc="pop mem queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   action(pt_popTriggerQueue, "pt", desc="pop trigger queue") {
diff --git a/src/mem/ruby/protocol/MOESI_CMP_directory-dir.sm  
b/src/mem/ruby/protocol/MOESI_CMP_directory-dir.sm

index 3b4a801..f21400c 100644
--- a/src/mem/ruby/protocol/MOESI_CMP_directory-dir.sm
+++ b/src/mem/ruby/protocol/MOESI_CMP_directory-dir.sm
@@ -598,7 +598,7 @@
   }

   action(q_popMemQueue, "q", desc="Pop off-chip request queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   action(qf_queueMemoryFetchRequest, "qf", desc="Queue off-chip fetch  
request") {
diff --git a/src/mem/ruby/protocol/MOESI_CMP_token-dir.sm  
b/src/mem/ruby/protocol/MOESI_CMP_token-dir.sm

index 97ea292..7f2bdf9 100644
--- a/src/mem/ruby/protocol/MOESI_CMP_token-dir.sm
+++ b/src/mem/ruby/protocol/MOESI_CMP_token-dir.sm
@@ -821,7 +821,7 @@
   }

   action(l_popMemQueue, "q", desc="Pop off-chip request queue") {
-memQueue_in.dequeue(clockEdge());
+dequeueMemRespQueue();
   }

   action(r_bounceResponse, "r", desc="Bounce response to starving  
processor") {
diff --git a/src/mem/ruby/protocol/MOESI_hammer-dir.sm  
b/src/mem/ruby/protocol/MOESI_hammer-dir.sm

index 8fd447f..833ccd3 100644
--- a/src/mem/ruby/protocol/MOESI_hammer-dir.sm
+++ b/src/mem/ruby/protocol/MOESI_hammer-dir.sm
@@ -1141,7 +1141,7 @@
   }

   action(l_popMemQueue, "q", desc="Pop off-chip request queue") {
-

[gem5-dev] [S] Change in gem5/gem5[develop]: sim: Deprecate pointer version of MemberEventWrapper constructor

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67656?usp=email )



Change subject: sim: Deprecate pointer version of MemberEventWrapper  
constructor

..

sim: Deprecate pointer version of MemberEventWrapper constructor

It makes no sense to initialize such event with nullptr. Favor the
reference version for safer behavior.

Change-Id: I695f41362a56aca98ceb52d49cf84be43f1465a2
---
M src/sim/eventq.hh
1 file changed, 20 insertions(+), 7 deletions(-)



diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index 36b2245..a719030 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -1082,18 +1082,19 @@
 static_assert(std::is_same_v,  
std::tuple<>>);


 public:
+[[deprecated("Use reference version of this constructor instead")]]
 MemberEventWrapper(T *object, bool del = false, Priority p =  
Default_Pri):

-Event(p),
-Named(object->name() + ".wrapped_event"),
-mObject(object)
+MemberEventWrapper{*object, del, p}
+{}
+
+MemberEventWrapper(T , bool del = false, Priority p =  
Default_Pri):

+Event{p},
+Named{object.name() + ".wrapped_event"},
+mObject{}
 {
 if (del) setFlags(AutoDelete);
 }

-MemberEventWrapper(T , bool del = false, Priority p =  
Default_Pri):

-MemberEventWrapper(, del, p)
-{}
-
 void process() {
 gem5_assert(mObject);
 (mObject->*F)();

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67656?usp=email
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: I695f41362a56aca98ceb52d49cf84be43f1465a2
Gerrit-Change-Number: 67656
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: stdlib: Add missing imports to complex_generator.py

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67651?usp=email )



Change subject: stdlib: Add missing imports to complex_generator.py
..

stdlib: Add missing imports to complex_generator.py

Change-Id: I1f8488726c953efe8eb85e30a698ee33088585e7
---
M src/python/gem5/components/processors/complex_generator.py
1 file changed, 12 insertions(+), 0 deletions(-)



diff --git a/src/python/gem5/components/processors/complex_generator.py  
b/src/python/gem5/components/processors/complex_generator.py

index b113640..fb24a70 100644
--- a/src/python/gem5/components/processors/complex_generator.py
+++ b/src/python/gem5/components/processors/complex_generator.py
@@ -27,6 +27,9 @@
 from ...utils.override import overrides
 from .complex_generator_core import ComplexGeneratorCore
 from .abstract_generator import AbstractGenerator
+from .abstract_processor import AbstractProcessor
+from ..boards.abstract_board import AbstractBoard
+from ..boards.mem_mode import MemMode

 from typing import Iterator, List, Any


--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67651?usp=email
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: I1f8488726c953efe8eb85e30a698ee33088585e7
Gerrit-Change-Number: 67651
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: configs: Fix default CustomMesh for use with Garnet

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67660?usp=email )



Change subject: configs: Fix default CustomMesh for use with Garnet
..

configs: Fix default CustomMesh for use with Garnet

Garnet routers do not support 0 latency switches. Use 1 instead if the
network is garnet.

Change-Id: I09841a01eaf413bee0a1629307ecff0ae2bda948
---
M configs/topologies/CustomMesh.py
1 file changed, 15 insertions(+), 1 deletion(-)



diff --git a/configs/topologies/CustomMesh.py  
b/configs/topologies/CustomMesh.py

index 088e4b9..2f0b2f3 100644
--- a/configs/topologies/CustomMesh.py
+++ b/configs/topologies/CustomMesh.py
@@ -171,7 +171,8 @@
 def _createRNFRouter(self, mesh_router):
 # Create a zero-latency router bridging node controllers
 # and the mesh router
-node_router = self._Router(router_id=len(self._routers), latency=0)
+node_router = self._Router(router_id=len(self._routers),
+latency=self.node_router_latency)
 self._routers.append(node_router)

 # connect node_router <-> mesh router
@@ -270,6 +271,7 @@
 self._ExtLink = ExtLink
 self._Router = Router

+self.node_router_latency = 1 if options.network == 'garnet' else 0
 if hasattr(options, "router_link_latency"):
 self._router_link_latency = options.router_link_latency
 self._node_link_latency = options.node_link_latency

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67660?usp=email
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: I09841a01eaf413bee0a1629307ecff0ae2bda948
Gerrit-Change-Number: 67660
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: mem-ruby: AbstractController can send retry req to mem controller

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67658?usp=email )



Change subject: mem-ruby: AbstractController can send retry req to mem  
controller

..

mem-ruby: AbstractController can send retry req to mem controller

Prior to this patch, when a memory controller was failing at sending a
response to AbstractController, it would not wakeup until the next
request. This patch gives the opportunity to Ruby models to notify
memory response buffer dequeue so that AbstractController can send a
retry request if necessary.

A dequeueMemRspQueue function has been added AbstractController to
automate the dequeue+notify operation.

Note that models that don't notify AbstractController will continue
working as before.

Change-Id: I261bb4593c126208c98825e54f538638d818d16b
---
M src/mem/ruby/slicc_interface/AbstractController.cc
M src/mem/ruby/slicc_interface/AbstractController.hh
2 files changed, 74 insertions(+), 7 deletions(-)



diff --git a/src/mem/ruby/slicc_interface/AbstractController.cc  
b/src/mem/ruby/slicc_interface/AbstractController.cc

index 2d10422..f7b01cf 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.cc
+++ b/src/mem/ruby/slicc_interface/AbstractController.cc
@@ -62,8 +62,10 @@
   m_buffer_size(p.buffer_size), m_recycle_latency(p.recycle_latency),
   m_mandatory_queue_latency(p.mandatory_queue_latency),
   m_waiting_mem_retry(false),
+  m_mem_ctrl_waiting_retry(false),
   memoryPort(csprintf("%s.memory", name()), this),
   addrRanges(p.addr_ranges.begin(), p.addr_ranges.end()),
+  mRetryRespEvent{*this, false},
   stats(this)
 {
 if (m_version == 0) {
@@ -367,11 +369,17 @@
 return num_functional_writes + 1;
 }

-void
+bool
 AbstractController::recvTimingResp(PacketPtr pkt)
 {
-assert(getMemRespQueue());
-assert(pkt->isResponse());
+auto* memRspQueue = getMemRespQueue();
+gem5_assert(memRspQueue);
+gem5_assert(pkt->isResponse());
+
+if (!memRspQueue->areNSlotsAvailable(1, curTick())) {
+m_mem_ctrl_waiting_retry = true;
+return false;
+}

 std::shared_ptr msg =  
std::make_shared(clockEdge());

 (*msg).m_addr = pkt->getAddr();
@@ -395,8 +403,9 @@
 panic("Incorrect packet type received from memory controller!");
 }

-getMemRespQueue()->enqueue(msg, clockEdge(), cyclesToTicks(Cycles(1)));
+memRspQueue->enqueue(msg, clockEdge(), cyclesToTicks(Cycles(1)));
 delete pkt;
+return true;
 }

 Tick
@@ -438,11 +447,33 @@
 }


+void
+AbstractController::memRespQueueDequeued() {
+if (m_mem_ctrl_waiting_retry && !mRetryRespEvent.scheduled()) {
+schedule(mRetryRespEvent, clockEdge(Cycles{1}));
+}
+}
+
+void
+AbstractController::dequeueMemRespQueue() {
+auto* q = getMemRespQueue();
+gem5_assert(q);
+q->dequeue(clockEdge());
+memRespQueueDequeued();
+}
+
+void
+AbstractController::sendRetryRespToMem() {
+if (m_mem_ctrl_waiting_retry) {
+m_mem_ctrl_waiting_retry = false;
+memoryPort.sendRetryResp();
+}
+}
+
 bool
 AbstractController::MemoryPort::recvTimingResp(PacketPtr pkt)
 {
-controller->recvTimingResp(pkt);
-return true;
+return controller->recvTimingResp(pkt);
 }

 void
diff --git a/src/mem/ruby/slicc_interface/AbstractController.hh  
b/src/mem/ruby/slicc_interface/AbstractController.hh

index a5ab5c2..f483412 100644
--- a/src/mem/ruby/slicc_interface/AbstractController.hh
+++ b/src/mem/ruby/slicc_interface/AbstractController.hh
@@ -61,6 +61,7 @@
 #include "mem/ruby/system/CacheRecorder.hh"
 #include "params/RubyController.hh"
 #include "sim/clocked_object.hh"
+#include "sim/eventq.hh"

 namespace gem5
 {
@@ -100,6 +101,16 @@
 virtual MessageBuffer* getMandatoryQueue() const = 0;
 virtual MessageBuffer* getMemReqQueue() const = 0;
 virtual MessageBuffer* getMemRespQueue() const = 0;
+virtual void memReqQueueDequeued() {};
+virtual void memRespQueueEnqueued() {};
+
+// That function must be called by controller when dequeuing mem resp  
queue

+// for memory controller to receive the retry request in time
+void memRespQueueDequeued();
+// Or that function can be called to perform both dequeue and  
notification

+// at once.
+void dequeueMemRespQueue();
+
 virtual AccessPermission getAccessPermission(const Addr ) = 0;

 virtual void print(std::ostream & out) const = 0;
@@ -165,7 +176,7 @@
 Port (const std::string _name,
   PortID idx=InvalidPortID);

-void recvTimingResp(PacketPtr pkt);
+bool recvTimingResp(PacketPtr pkt);
 Tick recvAtomic(PacketPtr pkt);

 const AddrRangeList () const { return addrRanges; }
@@ -364,6 +375,7 @@
 Cycles m_recycle_latency;
 const Cycles m_mandatory_queue_latency;
 bool m_waiting_mem_retry;
+bool m_mem_ctrl_waiting_retry;

 /**
  * Port that 

[gem5-dev] [M] Change in gem5/gem5[develop]: sim: Switch from EventWrapper to MemberEventWrapper after deprec

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67655?usp=email )



Change subject: sim: Switch from EventWrapper to MemberEventWrapper after  
deprec

..

sim: Switch from EventWrapper to MemberEventWrapper after deprec

Change-Id: I25c81787d522a0dd063112b6727669da46e0f0e7
---
M src/arch/sparc/isa.hh
M src/base/remote_gdb.hh
M src/dev/arm/smmu_v3.hh
M src/dev/arm/smmu_v3_deviceifc.hh
M src/dev/arm/smmu_v3_proc.cc
M src/mem/qos/mem_sink.hh
M src/sim/power_domain.hh
M src/systemc/core/kernel.hh
M src/systemc/core/scheduler.hh
M util/systemc/systemc_within_gem5/systemc_simple_object/feeder.hh
10 files changed, 28 insertions(+), 24 deletions(-)



diff --git a/src/arch/sparc/isa.hh b/src/arch/sparc/isa.hh
index 22bfba4..dee71d6 100644
--- a/src/arch/sparc/isa.hh
+++ b/src/arch/sparc/isa.hh
@@ -133,13 +133,13 @@
 void processSTickCompare();
 void processHSTickCompare();

-typedef EventWrapper TickCompareEvent;
+typedef MemberEventWrapper<::processTickCompare> TickCompareEvent;
 TickCompareEvent *tickCompare = nullptr;

-typedef EventWrapper STickCompareEvent;
+typedef MemberEventWrapper<::processSTickCompare>  
STickCompareEvent;

 STickCompareEvent *sTickCompare = nullptr;

-typedef EventWrapper  
HSTickCompareEvent;
+typedef MemberEventWrapper<::processHSTickCompare>  
HSTickCompareEvent;

 HSTickCompareEvent *hSTickCompare = nullptr;

 static const int NumGlobalRegs = 8;
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index 1c5cd9c..7981a13 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -274,8 +274,8 @@

 BaseGdbRegCache *regCachePtr = nullptr;

-EventWrapper connectEvent;
-EventWrapper  disconnectEvent;
+MemberEventWrapper<::connect> connectEvent;
+MemberEventWrapper<::detach>  disconnectEvent;

 class TrapEvent : public Event
 {
@@ -308,7 +308,7 @@

 // Single step.
 void singleStep();
-EventWrapper  
singleStepEvent;

+MemberEventWrapper<::singleStep> singleStepEvent;

 void clearSingleStep();
 void setSingleStep();
diff --git a/src/dev/arm/smmu_v3.hh b/src/dev/arm/smmu_v3.hh
index 25b91ff..8721352 100644
--- a/src/dev/arm/smmu_v3.hh
+++ b/src/dev/arm/smmu_v3.hh
@@ -167,7 +167,7 @@
 SMMUAction runProcessTiming(SMMUProcess *proc, PacketPtr pkt);

 void processCommands();
-EventWrapper processCommandsEvent;
+MemberEventWrapper<::processCommands> processCommandsEvent;

 void processCommand(const SMMUCommand );

diff --git a/src/dev/arm/smmu_v3_deviceifc.hh  
b/src/dev/arm/smmu_v3_deviceifc.hh

index c4ffa37..3152f8a 100644
--- a/src/dev/arm/smmu_v3_deviceifc.hh
+++ b/src/dev/arm/smmu_v3_deviceifc.hh
@@ -114,9 +114,7 @@
 bool atsDeviceNeedsRetry;

 SMMUDeviceRetryEvent sendDeviceRetryEvent;
-EventWrapper<
-SMMUv3DeviceInterface,
-::atsSendDeviceRetry>  
atsSendDeviceRetryEvent;
+MemberEventWrapper<::atsSendDeviceRetry>  
atsSendDeviceRetryEvent;


 Port& getPort(const std::string , PortID id) override;

diff --git a/src/dev/arm/smmu_v3_proc.cc b/src/dev/arm/smmu_v3_proc.cc
index 2cf2cf9..ef3db5d 100644
--- a/src/dev/arm/smmu_v3_proc.cc
+++ b/src/dev/arm/smmu_v3_proc.cc
@@ -199,8 +199,7 @@
 void
 SMMUProcess::scheduleWakeup(Tick when)
 {
-auto *ep = new EventWrapper<
-SMMUProcess, ::wakeup> (this, true);
+auto *ep = new MemberEventWrapper<::wakeup> (this, true);

 smmu.schedule(ep, when);
 }
diff --git a/src/mem/qos/mem_sink.hh b/src/mem/qos/mem_sink.hh
index d2310c6..bd42a9a 100644
--- a/src/mem/qos/mem_sink.hh
+++ b/src/mem/qos/mem_sink.hh
@@ -222,9 +222,7 @@
 void processNextReqEvent();

 /** Event wrapper to schedule next request handler function */
-EventWrapper<
-MemSinkCtrl,
-::processNextReqEvent> nextReqEvent;
+MemberEventWrapper<::processNextReqEvent> nextReqEvent;

 /**
  * Check if the read queue has room for more entries
diff --git a/src/sim/power_domain.hh b/src/sim/power_domain.hh
index 96233e4..1264d8f 100644
--- a/src/sim/power_domain.hh
+++ b/src/sim/power_domain.hh
@@ -151,7 +151,7 @@
 /**
  * Event to update the power states of the followers
  */
-EventWrapper
+MemberEventWrapper<::setFollowerPowerStates>
 pwrStateUpdateEvent;

   protected:
diff --git a/src/systemc/core/kernel.hh b/src/systemc/core/kernel.hh
index 9dba903..ec47569 100644
--- a/src/systemc/core/kernel.hh
+++ b/src/systemc/core/kernel.hh
@@ -65,7 +65,7 @@
   private:
 static void stopWork();

-gem5::EventWrapper t0Event;
+gem5::MemberEventWrapper<::t0Handler> t0Event;
 };

 extern Kernel *kernel;
diff --git a/src/systemc/core/scheduler.hh b/src/systemc/core/scheduler.hh
index 6eabb56..49ad6c6 100644
--- a/src/systemc/core/scheduler.hh
+++ b/src/systemc/core/scheduler.hh
@@ -465,13 +465,13 @@
 }

 

[gem5-dev] [S] Change in gem5/gem5[develop]: sim: Use ref constructor of MemberEventWrapper everywhere

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67657?usp=email )



Change subject: sim: Use ref constructor of MemberEventWrapper everywhere
..

sim: Use ref constructor of MemberEventWrapper everywhere

Change-Id: I77989aa7318142634c771c558293138e7b1e8e51
---
M src/arch/sparc/isa.cc
M src/arch/sparc/ua2005.cc
M src/base/remote_gdb.cc
M src/dev/arm/smmu_v3.cc
M src/dev/arm/smmu_v3_deviceifc.cc
M src/dev/arm/smmu_v3_proc.cc
M src/mem/qos/mem_sink.cc
M src/systemc/core/kernel.cc
M src/systemc/core/scheduler.cc
9 files changed, 27 insertions(+), 18 deletions(-)



diff --git a/src/arch/sparc/isa.cc b/src/arch/sparc/isa.cc
index 38b3d1c..e7807c2 100644
--- a/src/arch/sparc/isa.cc
+++ b/src/arch/sparc/isa.cc
@@ -953,15 +953,15 @@
 UNSERIALIZE_SCALAR(hstick_cmp);

 if (tick_cmp) {
-tickCompare = new TickCompareEvent(this);
+tickCompare = new TickCompareEvent(*this);
 schedule(tickCompare, tick_cmp);
 }
 if (stick_cmp)  {
-sTickCompare = new STickCompareEvent(this);
+sTickCompare = new STickCompareEvent(*this);
 schedule(sTickCompare, stick_cmp);
 }
 if (hstick_cmp)  {
-hSTickCompare = new HSTickCompareEvent(this);
+hSTickCompare = new HSTickCompareEvent(*this);
 schedule(hSTickCompare, hstick_cmp);
 }
 }
diff --git a/src/arch/sparc/ua2005.cc b/src/arch/sparc/ua2005.cc
index 3f5372a..45cc9d7 100644
--- a/src/arch/sparc/ua2005.cc
+++ b/src/arch/sparc/ua2005.cc
@@ -107,7 +107,7 @@

   case MISCREG_TICK_CMPR:
 if (tickCompare == NULL)
-tickCompare = new TickCompareEvent(this);
+tickCompare = new TickCompareEvent(*this);
 setMiscRegNoEffect(miscReg, val);
 if ((tick_cmpr & ~mask(63)) && tickCompare->scheduled())
 cpu->deschedule(tickCompare);
@@ -122,7 +122,7 @@

   case MISCREG_STICK_CMPR:
 if (sTickCompare == NULL)
-sTickCompare = new STickCompareEvent(this);
+sTickCompare = new STickCompareEvent(*this);
 setMiscRegNoEffect(miscReg, val);
 if ((stick_cmpr & ~mask(63)) && sTickCompare->scheduled())
 cpu->deschedule(sTickCompare);
@@ -193,7 +193,7 @@

   case MISCREG_HSTICK_CMPR:
 if (hSTickCompare == NULL)
-hSTickCompare = new HSTickCompareEvent(this);
+hSTickCompare = new HSTickCompareEvent(*this);
 setMiscRegNoEffect(miscReg, val);
 if ((hstick_cmpr & ~mask(63)) && hSTickCompare->scheduled())
 cpu->deschedule(hSTickCompare);
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index 43f53d1..dd37a35 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -393,7 +393,7 @@
 BaseRemoteGDB::BaseRemoteGDB(System *_system, int _port) :
 incomingConnectionEvent(nullptr), incomingDataEvent(nullptr),
 _port(_port), fd(-1), sys(_system),
-connectEvent(this), disconnectEvent(this), trapEvent(this),
+connectEvent(*this), disconnectEvent(*this), trapEvent(this),
 singleStepEvent(*this)
 {}

diff --git a/src/dev/arm/smmu_v3.cc b/src/dev/arm/smmu_v3.cc
index 41f7424e..8ce8bd9 100644
--- a/src/dev/arm/smmu_v3.cc
+++ b/src/dev/arm/smmu_v3.cc
@@ -100,7 +100,7 @@
 deviceInterfaces(params.device_interfaces),
 commandExecutor(name() + ".cmd_exec", *this),
 regsMap(params.reg_map),
-processCommandsEvent(this)
+processCommandsEvent(*this)
 {
 fatal_if(regsMap.size() != SMMU_REG_SIZE,
 "Invalid register map size: %#x different than SMMU_REG_SIZE  
= %#x\n",
diff --git a/src/dev/arm/smmu_v3_deviceifc.cc  
b/src/dev/arm/smmu_v3_deviceifc.cc

index 166b85d..0966150 100644
--- a/src/dev/arm/smmu_v3_deviceifc.cc
+++ b/src/dev/arm/smmu_v3_deviceifc.cc
@@ -78,7 +78,7 @@
 deviceNeedsRetry(false),
 atsDeviceNeedsRetry(false),
 sendDeviceRetryEvent(*this),
-atsSendDeviceRetryEvent(this)
+atsSendDeviceRetryEvent(*this)
 {}

 void
diff --git a/src/dev/arm/smmu_v3_proc.cc b/src/dev/arm/smmu_v3_proc.cc
index ef3db5d..f0c2633 100644
--- a/src/dev/arm/smmu_v3_proc.cc
+++ b/src/dev/arm/smmu_v3_proc.cc
@@ -199,7 +199,7 @@
 void
 SMMUProcess::scheduleWakeup(Tick when)
 {
-auto *ep = new MemberEventWrapper<::wakeup> (this, true);
+auto *ep = new MemberEventWrapper<::wakeup> (*this, true);

 smmu.schedule(ep, when);
 }
diff --git a/src/mem/qos/mem_sink.cc b/src/mem/qos/mem_sink.cc
index b6b77ca..66b9451 100644
--- a/src/mem/qos/mem_sink.cc
+++ b/src/mem/qos/mem_sink.cc
@@ -60,7 +60,7 @@
 readBufferSize(p.read_buffer_size),
 writeBufferSize(p.write_buffer_size), port(name() + ".port", *this),
 interface(p.interface),
-retryRdReq(false), retryWrReq(false), nextRequest(0),  
nextReqEvent(this),
+retryRdReq(false), retryWrReq(false), nextRequest(0),  
nextReqEvent(*this),

 stats(this)
 {
 // Resize 

[gem5-dev] [M] Change in gem5/gem5[develop]: base: Create a gem5 type_traits.hh header

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67652?usp=email )



Change subject: base: Create a gem5 type_traits.hh header
..

base: Create a gem5 type_traits.hh header

That header currently contains type traits that derive the class, the
return type and the arguments of a member function from a pointer to
that member function.

Change-Id: I41dd41056f507016219d6111d25c8cb4c2ad3439
---
A src/base/type_traits.hh
1 file changed, 108 insertions(+), 0 deletions(-)



diff --git a/src/base/type_traits.hh b/src/base/type_traits.hh
new file mode 100644
index 000..bd9db9c
--- /dev/null
+++ b/src/base/type_traits.hh
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2022 Arteris, Inc. and its applicable licensors and
+ * affiliates.
+ * All rights reserved.
+ * This license is licensed under the Gem5 license.
+ *
+ * The license below extends only to copyright in the software and shall  
not be
+ * construed as granting a license to any other intellectual property  
including

+ * but not limited to intellectual property relating to a hardware
+ * implementation of the functionality of the software licensed  
hereunder.  You
+ * may use the software subject to the license terms below provided that  
you
+ * ensure that this notice is replicated unmodified and in its entirety in  
all
+ * distributions of the software, modified or unmodified, in source code  
or in

+ * binary form.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS  
IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,  
THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  
PURPOSE

+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF  
THE

+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __BASE_TYPETRAITS_HH__
+#define __BASE_TYPETRAITS_HH__
+
+#include 
+#include 
+
+namespace gem5
+{
+
+template
+struct MemberFunctionSignature;
+template
+struct MemberFunctionSignature
+{
+using class_t = C;
+using return_t = R;
+using argsTuple_t = std::tuple;
+};
+template
+struct MemberFunctionSignature
+{
+using class_t = std::add_const_t;
+using return_t = R;
+using argsTuple_t = std::tuple;
+};
+template
+struct MemberFunctionSignature
+{
+using class_t = std::add_volatile_t;
+using return_t = R;
+using argsTuple_t = std::tuple;
+};
+template
+struct MemberFunctionSignature
+{
+using class_t = std::add_cv_t;
+using return_t = R;
+using argsTuple_t = std::tuple;
+};
+template
+using MemberFunctionClass_t =
+typename MemberFunctionSignature::class_t;
+
+template
+using MemberFunctionReturn_t =
+typename MemberFunctionSignature::return_t;
+
+template
+using MemberFunctionArgsTuple_t =
+typename MemberFunctionSignature::argsTuple_t;
+
+
+
+} // namespace gem5
+
+#endif // __BASE_TYPETRAITS_HH__

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67652?usp=email
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: I41dd41056f507016219d6111d25c8cb4c2ad3439
Gerrit-Change-Number: 67652
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: sim: Define a new MemberEventWrapper event class

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67653?usp=email )



Change subject: sim: Define a new MemberEventWrapper event class
..

sim: Define a new MemberEventWrapper event class

This new event class simplifies the use of EventWrapper and aims at
superseeding it. EventWrapper has been redefined in terms of
MemberEventWrapper.

MemberEventWrapper makes use of the new type traits to simplify
template parameterization and encourage its use over SimpleEvent that
often wraps a lambda that merely calls a member function.

Change-Id: Ie59e4c51705b9c2b2faa27097678d7d85f5b99c6
---
M src/sim/eventq.hh
1 file changed, 42 insertions(+), 21 deletions(-)



diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index 62495bf..3eefbd3 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -46,7 +46,9 @@

 #include "base/debug.hh"
 #include "base/flags.hh"
+#include "base/named.hh"
 #include "base/trace.hh"
+#include "base/type_traits.hh"
 #include "base/types.hh"
 #include "base/uncontended_mutex.hh"
 #include "debug/Event.hh"
@@ -1071,38 +1073,40 @@
 void setCurTick(Tick newVal) { eventq->setCurTick(newVal); }
 };

-template 
-class EventWrapper : public Event
+template 
+class MemberEventWrapper: public Event, public Named
 {
-  private:
-T *object;
+using T = MemberFunctionClass_t;
+using R = MemberFunctionReturn_t;
+static_assert(std::is_same_v);
+static_assert(std::is_same_v,  
std::tuple<>>);


-  public:
-EventWrapper(T *obj, bool del = false, Priority p = Default_Pri)
-: Event(p), object(obj)
+public:
+MemberEventWrapper(T *object, bool del = false, Priority p =  
Default_Pri):

+Event(p),
+Named(object->name() + ".wrapped_event"),
+mObject(object)
 {
-if (del)
-setFlags(AutoDelete);
+if (del) setFlags(AutoDelete);
 }

-EventWrapper(T , bool del = false, Priority p = Default_Pri)
-: Event(p), object()
-{
-if (del)
-setFlags(AutoDelete);
-}
+MemberEventWrapper(T , bool del = false, Priority p =  
Default_Pri):

+MemberEventWrapper(, del, p)
+{}

-void process() { (object->*F)(); }
-
-const std::string
-name() const
-{
-return object->name() + ".wrapped_event";
+void process() {
+gem5_assert(mObject);
+(mObject->*F)();
 }

 const char *description() const { return "EventWrapped"; }
+private:
+T *mObject = nullptr;
 };

+template 
+using EventWrapper = MemberEventWrapper;
+
 class EventFunctionWrapper : public Event
 {
   private:

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67653?usp=email
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: Ie59e4c51705b9c2b2faa27097678d7d85f5b99c6
Gerrit-Change-Number: 67653
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: dev-amdgpu: Patch forgotten port after mem port owner deprecation

2023-02-06 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67631?usp=email )



Change subject: dev-amdgpu: Patch forgotten port after mem port owner  
deprecation

..

dev-amdgpu: Patch forgotten port after mem port owner deprecation

Change-Id: I82f88b8962d9f04521e549ca1383c42f2b5b3ffc
---
M src/mem/ruby/system/GPUCoalescer.cc
M src/mem/ruby/system/GPUCoalescer.hh
2 files changed, 12 insertions(+), 3 deletions(-)



diff --git a/src/mem/ruby/system/GPUCoalescer.cc  
b/src/mem/ruby/system/GPUCoalescer.cc

index a0808fa..8bde3f7 100644
--- a/src/mem/ruby/system/GPUCoalescer.cc
+++ b/src/mem/ruby/system/GPUCoalescer.cc
@@ -190,7 +190,7 @@
  false, Event::Progress_Event_Pri),
   uncoalescedTable(this),
   deadlockCheckEvent([this]{ wakeup(); }, "GPUCoalescer deadlock  
check"),

-  gmTokenPort(name() + ".gmTokenPort", this)
+  gmTokenPort(name() + ".gmTokenPort")
 {
 m_store_waiting_on_load_cycles = 0;
 m_store_waiting_on_store_cycles = 0;
diff --git a/src/mem/ruby/system/GPUCoalescer.hh  
b/src/mem/ruby/system/GPUCoalescer.hh

index 1120947..dd28855 100644
--- a/src/mem/ruby/system/GPUCoalescer.hh
+++ b/src/mem/ruby/system/GPUCoalescer.hh
@@ -216,9 +216,9 @@
 class GMTokenPort : public TokenResponsePort
 {
   public:
-GMTokenPort(const std::string& name, ClockedObject *owner,
+GMTokenPort(const std::string& name,
 PortID id = InvalidPortID)
-: TokenResponsePort(name, owner, id)
+: TokenResponsePort(name, id)
 { }
 ~GMTokenPort() { }


--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67631?usp=email
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: I82f88b8962d9f04521e549ca1383c42f2b5b3ffc
Gerrit-Change-Number: 67631
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: base: Turn all logging.hh macros into expression kind

2023-02-02 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67336?usp=email )


 (

8 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.

 )Change subject: base: Turn all logging.hh macros into expression kind
..

base: Turn all logging.hh macros into expression kind

In the previous version, the body of several macros was a statement
(do{...} while(0);) and not an expression. In the new version, all
macros are expressions. Expressions can be used everywhere a statement
is expected and in other locations as well.

For instance, expressions can be used with the comma operator. When
doing generic programming, the comma operator helps manipulating
parameter packs.  With a statement-based implementation,
(gem5_assert(args > 0), ...) could not be written while perfectly
sound.

Also, (c1 ?  a : c2 ?  b : (gem5_assert(c3), c)) is a usefull
expression to assert completeness of cascaded conditions that cannot
be easily and efficiently achieved without an expression kind of
assertion.

Change-Id: Ia0efeb15e6deda6b90529a6f0e00ebe2e9b5d2a0
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67336
Maintainer: Bobby Bruce 
Tested-by: kokoro 
Reviewed-by: Bobby Bruce 
---
M src/base/logging.hh
1 file changed, 99 insertions(+), 55 deletions(-)

Approvals:
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/base/logging.hh b/src/base/logging.hh
index 22fd2a8..f66423f 100644
--- a/src/base/logging.hh
+++ b/src/base/logging.hh
@@ -138,9 +138,10 @@
 const char *prefix;
 };

-
-#define base_message(logger, ...) \
-logger.print(::gem5::Logger::Loc(__FILE__, __LINE__), __VA_ARGS__)
+#define base_message(logger, ...)   \
+[ = logger](const auto&... args) {  \
+log.print(::gem5::Logger::Loc(__FILE__, __LINE__), args...);\
+}(__VA_ARGS__)

 /*
  * Only print the message the first time this expression is
@@ -150,19 +151,29 @@
  * would have resulted in a different message thoes messages would be
  * supressed.
  */
-#define base_message_once(...) do { \
-static bool once = false;   \
-if (!once) {\
-base_message(__VA_ARGS__);  \
-once = true;\
-}   \
-} while (0)
+#define base_message_once(logger, ...)  \
+[ = logger](const auto&... args) {  \
+static bool once{false};\
+if (GEM5_UNLIKELY(!once)) { \
+once = true;\
+base_message(log, args...); \
+}   \
+}(__VA_ARGS__)

-#define exit_message(logger, ...)   \
-do {\
-base_message(logger, __VA_ARGS__);  \
-logger.exit_helper();   \
-} while (0)
+/*
+ * logger.exit_helper() can't be called inside the lambda for now as the
+ * lambda's operator() can't be [[noreturn]]. As a result, exit_message  
and it'
+ * s derivative cannot be used in functions without also specifying a  
return

+ * value, which is inconvenient if not impossible.
+ */
+
+#define exit_message(logger, ...)   \
+(   \
+[ = logger](const auto&... args) {  \
+base_message(log, args...); \
+}(__VA_ARGS__), \
+logger.exit_helper()\
+)

 /**
  * This implements a cprintf based panic() function.  panic() should
@@ -200,13 +211,13 @@
  *
  * @ingroup api_logger
  */
-#define panic_if(cond, ...)  \
-do { \
-if (GEM5_UNLIKELY(cond)) { \
-panic("panic condition " # cond " occurred: %s", \
-  ::gem5::csprintf(__VA_ARGS__));\
-}\
-} while (0)
+#define panic_if(cond, ...) \
+(   \
+GEM5_UNLIKELY(static_cast(cond)) ?\
+panic("panic condition " # cond " occurred: %s",\
+::gem5::csprintf(__VA_ARGS__)) :\
+void(0) \
+)


 /**
@@ -222,13 +233,13 @@
  *
  * @ingroup api_logger
  */
-#define fatal_if(cond, ...) \
-do {\
-if 

[gem5-dev] [M] Change in gem5/gem5[develop]: mem: Deprecate RequestPort and ResponsePort owner ref member

2023-02-02 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67551?usp=email )


Change subject: mem: Deprecate RequestPort and ResponsePort owner ref member
..

mem: Deprecate RequestPort and ResponsePort owner ref member

The reference can be bound to an invalid object (*nullptr) in
situations where no proper owner SimObject can be provided to the port
constructor. This rightfully triggers a UBSAN warning.

Also, these two classes do not make use of the owner reference member
themselves and expose it as a protected member reference to
subclasses. This desing has several drawbacks: requires the reference
to owner to travel the class hierarchy up and down, loosing its true
static type in the process ; non-private member variable should not be
part of the API of such fundamental classes, if only for
maintainability ; a reference bound from a nullable pointer is a lying
API as it hides the optional aspect of ownership.

Note that the reference to invalid object can't be properly fixed until
the complete removal of the owner reference. This patch lays the path
toward that fix.

Change-Id: I8b42bc57d7826656726f7708492c43366f20633a
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67551
Reviewed-by: Bobby Bruce 
Tested-by: kokoro 
Maintainer: Bobby Bruce 
Reviewed-by: Jason Lowe-Power 
Maintainer: Jason Lowe-Power 
---
M src/mem/port.cc
M src/mem/port.hh
2 files changed, 86 insertions(+), 11 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, but someone else must approve; Looks  
good to me, approved

  kokoro: Regressions pass
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved




diff --git a/src/mem/port.cc b/src/mem/port.cc
index 18793d4..e36323f 100644
--- a/src/mem/port.cc
+++ b/src/mem/port.cc
@@ -120,9 +120,23 @@
 /**
  * Request port
  */
-RequestPort::RequestPort(const std::string& name, SimObject* _owner,
-PortID _id) : Port(name, _id), _responsePort(),
-owner(*_owner)
+[[deprecated]]
+RequestPort::RequestPort(const std::string& name,
+ SimObject* _owner,
+ PortID _id):
+Port(name, _id), _responsePort(), owner{*_owner}
+{
+}
+
+/*** FIXME:
+ * The owner reference member is going through a deprecation path. In the
+ * meantime, it must be initialized but no valid reference is available  
here.
+ * Using 1 instead of nullptr prevents warning upon dereference. It should  
be

+ * OK until definitive removal of owner.
+ */
+RequestPort::RequestPort(const std::string& name, PortID _id) :
+Port(name, _id), _responsePort(),
+owner{*reinterpret_cast(1)}
 {
 }

@@ -175,9 +189,30 @@
 /**
  * Response port
  */
-ResponsePort::ResponsePort(const std::string& name, SimObject* _owner,
-PortID id) : Port(name, id), _requestPort(),
-defaultBackdoorWarned(false), owner(*_owner)
+
+[[deprecated]]
+ResponsePort::ResponsePort(const std::string& name,
+   SimObject* _owner,
+   PortID _id):
+Port(name, _id),
+_requestPort(),
+defaultBackdoorWarned(false),
+owner{*_owner}
+{
+}
+
+
+/*** FIXME:
+ * The owner reference member is going through a deprecation path. In the
+ * meantime, it must be initialized but no valid reference is available  
here.
+ * Using 1 instead of nullptr prevents warning upon dereference. It should  
be

+ * OK until definitive removal of owner.
+ */
+ResponsePort::ResponsePort(const std::string& name, PortID id) :
+Port(name, id),
+_requestPort(),
+defaultBackdoorWarned(false),
+owner{*reinterpret_cast(1)}
 {
 }

diff --git a/src/mem/port.hh b/src/mem/port.hh
index fb0f4b8..0d61787 100644
--- a/src/mem/port.hh
+++ b/src/mem/port.hh
@@ -86,8 +86,13 @@
 SimObject 

   public:
+[[deprecated("RequestPort ownership is deprecated. "
+ "Owner should now be registered in derived classes.")]]
 RequestPort(const std::string& name, SimObject* _owner,
-   PortID id=InvalidPortID);
+PortID id=InvalidPortID);
+
+RequestPort(const std::string& name, PortID id=InvalidPortID);
+
 virtual ~RequestPort();

 /**
@@ -266,9 +271,7 @@
 class [[deprecated]] MasterPort : public RequestPort
 {
   public:
-MasterPort(const std::string& name, SimObject* _owner,
-   PortID id=InvalidPortID) : RequestPort(name, _owner, id)
-   {}
+using RequestPort::RequestPort;
 };

 /**
@@ -294,8 +297,13 @@
 SimObject& owner;

   public:
+[[deprecated("ResponsePort ownership is deprecated. "
+ "Owner should now be registered in derived classes.")]]
 ResponsePort(const std::string& name, SimObject* _owner,
-  PortID id=InvalidPortID);
+ PortID id=InvalidPortID);
+
+ResponsePort(const std::string& name, PortID id=InvalidPortID);
+
 virtual ~ResponsePort();

 /**

--
To view, 

[gem5-dev] [M] Change in gem5/gem5[develop]: base: Strengthen safe_cast and make it work for reference types

2023-02-02 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67453?usp=email )


Change subject: base: Strengthen safe_cast and make it work for reference  
types

..

base: Strengthen safe_cast and make it work for reference types

safe_cast now supports the exact same types as dynamic_cast would. In
particular, it now supports l-value references and rejects r-value
references.

The non-debug version has also been updated to make it build only in
the same cases as the debug version of safe_cast would.

Change-Id: I86692561c169b1ad063000c990a52ea80c6637ca
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67453
Reviewed-by: Giacomo Travaglini 
Maintainer: Giacomo Travaglini 
Tested-by: kokoro 
---
M src/base/cast.hh
1 file changed, 47 insertions(+), 5 deletions(-)

Approvals:
  Giacomo Travaglini: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/base/cast.hh b/src/base/cast.hh
index cdc3c62..01464d9 100644
--- a/src/base/cast.hh
+++ b/src/base/cast.hh
@@ -30,6 +30,8 @@
 #define __BASE_CAST_HH__

 #include 
+#include 
+#include "base/logging.hh"

 namespace gem5
 {
@@ -44,10 +46,20 @@

 template 
 inline T
-safe_cast(U ptr)
+safe_cast(U&& ref_or_ptr)
 {
-T ret = dynamic_cast(ptr);
-assert(ret);
+/*
+ * srd::forward used in conjunction with forwarding references  
(template T
+ * + T&&) ensures that dynamic_cast will see the exact same type that  
was

+ * passed to safe_cast (a.k.a., perfect forwarding).
+ *
+ * Not using std::forward would make safe_cast compile with references  
to

+ * temporary objects and thus return a dangling reference.
+ */
+T ret = dynamic_cast(std::forward(ref_or_ptr));
+if constexpr (std::is_pointer_v) {
+gem5_assert(ret);
+}
 return ret;
 }

@@ -59,9 +71,19 @@

 template 
 inline T
-safe_cast(U ptr)
+safe_cast(U&& ref_or_ptr)
 {
-return static_cast(ptr);
+/*
+ * safe_cast should be reserved to polymorphic types while static_cast  
is
+ * also allowed for non-polymorphic types. It could make safe_cast  
able to

+ * compile in a non-debug build and fail in a debug build.
+ */
+static_assert(std::is_polymorphic_v<
+std::remove_pointer_t<
+std::remove_reference_t<
+U>>
+>);
+return static_cast(std::forward(ref_or_ptr));
 }

 #endif

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67453?usp=email
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: I86692561c169b1ad063000c990a52ea80c6637ca
Gerrit-Change-Number: 67453
Gerrit-PatchSet: 4
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Giacomo Travaglini 
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


[gem5-dev] [M] Change in gem5/gem5[develop]: base: Enable non-copiable types in gem5_assert message formatting

2023-02-02 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67335?usp=email )


 (

7 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.
 )Change subject: base: Enable non-copiable types in gem5_assert message  
formatting

..

base: Enable non-copiable types in gem5_assert message formatting

Previous implementation was taking string formatting arguments by value,
which requires copiability or movability. Took the oportunity to scope
the helper functions inside the macro using lambdas.

Change-Id: I2cefc18df1e99b70e60e64588df61eb72a3e5166
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67335
Tested-by: kokoro 
Maintainer: Bobby Bruce 
Reviewed-by: Bobby Bruce 
---
M src/base/logging.hh
M src/base/logging.test.cc
2 files changed, 32 insertions(+), 21 deletions(-)

Approvals:
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/base/logging.hh b/src/base/logging.hh
index 8949b0c..22fd2a8 100644
--- a/src/base/logging.hh
+++ b/src/base/logging.hh
@@ -43,7 +43,6 @@

 #include 
 #include 
-#include 
 #include 

 #include "base/compiler.hh"
@@ -289,24 +288,10 @@
 #define NDEBUG_DEFINED 0
 #endif

-template 
-inline std::string
-_assertMsg(const std::string , Args... args)
-{
-return std::string(": ") + csprintf(format, args...);
-}
-
-inline const char *
-_assertMsg()
-{
-return "";
-}
-
 /**
  * The assert macro will function like a normal assert, but will use panic
  * instead of straight abort(). This allows to perform some cleaning up in
- * ExitLogger::exit() before calling abort(). This macro will not check its
- * condition in fast builds, but it must still be valid code.
+ * ExitLogger::exit() before calling abort().
  *
  * @param cond Condition that is checked; if false -> panic
  * @param ...  Printf-based format string with arguments, extends printout.
@@ -315,11 +300,17 @@
  *
  * @ingroup api_logger
  */
-#define gem5_assert(cond, ...) \
-do { \
-if (GEM5_UNLIKELY(!NDEBUG_DEFINED && !static_cast(cond))) { \
-panic("assert(" #cond ") failed%s", _assertMsg(__VA_ARGS__)); \
-} \
+#define gem5_assert(cond, ...)  \
+do {\
+GEM5_UNLIKELY(NDEBUG_DEFINED || static_cast(cond)) ?  \
+void(0) :   \
+[](const auto&... args) {   \
+auto msg = [&]{ \
+if constexpr (sizeof...(args) == 0) return "";  \
+else return std::string(": ") + csprintf(args...);  \
+};  \
+panic("assert(" #cond ") failed%s", msg()); \
+}(__VA_ARGS__); \
 } while (0)
 /** @} */ // end of api_logger

diff --git a/src/base/logging.test.cc b/src/base/logging.test.cc
index 38cc605..5d10f6e 100644
--- a/src/base/logging.test.cc
+++ b/src/base/logging.test.cc
@@ -553,6 +553,9 @@
 gem5_assert(true, "message\n");
 ASSERT_DEATH(gem5_assert(false, "message\n"), ::testing::HasSubstr(
 "panic: assert(false) failed: message\nMemory Usage:"));
+ASSERT_DEATH(gem5_assert(false, "%s, %s!\n", "Hello", "World"),
+::testing::HasSubstr(
+"panic: assert(false) failed: Hello, World!\nMemory Usage:"));
 gem5_assert(true);
 ASSERT_DEATH(gem5_assert(false), ::testing::HasSubstr(
 "panic: assert(false) failed\nMemory Usage:"));

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67335?usp=email
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: I2cefc18df1e99b70e60e64588df61eb72a3e5166
Gerrit-Change-Number: 67335
Gerrit-PatchSet: 14
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Jason Lowe-Power 
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


[gem5-dev] [S] Change in gem5/gem5[develop]: sim: Suppress deleted operator= warn in Sys::Threads::const_it

2023-02-02 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67454?usp=email )


 (

5 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.
 )Change subject: sim: Suppress deleted operator= warn in  
Sys::Threads::const_it

..

sim: Suppress deleted operator= warn in Sys::Threads::const_it

Swapping the reference member to threads for a pointer restores
trivial copiablity and movability.

Change-Id: I18d3a5b908d8575aef198f457b85060aa202bd5f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67454
Reviewed-by: Giacomo Travaglini 
Maintainer: Giacomo Travaglini 
Tested-by: kokoro 
---
M src/sim/system.hh
1 file changed, 22 insertions(+), 9 deletions(-)

Approvals:
  Giacomo Travaglini: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/sim/system.hh b/src/sim/system.hh
index 1d179e9..d2725c3 100644
--- a/src/sim/system.hh
+++ b/src/sim/system.hh
@@ -152,19 +152,16 @@
 class const_iterator
 {
   private:
-const Threads 
+Threads const* threads;
 int pos;

 friend class Threads;

 const_iterator(const Threads &_threads, int _pos) :
-threads(_threads), pos(_pos)
+threads(&_threads), pos(_pos)
 {}

   public:
-const_iterator(const const_iterator &) = default;
-const_iterator  = (const const_iterator &) = default;
-
 using iterator_category = std::forward_iterator_tag;
 using value_type = ThreadContext *;
 using difference_type = int;
@@ -181,16 +178,16 @@
 const_iterator
 operator ++ (int)
 {
-return const_iterator(threads, pos++);
+return const_iterator(*threads, pos++);
 }

-reference operator * () { return threads.thread(pos).context; }
-pointer operator -> () { return (pos).context; }
+reference operator * () { return threads->thread(pos).context;  
}
+pointer operator -> () { return >thread(pos).context;  
}


 bool
 operator == (const const_iterator ) const
 {
-return  ==  && pos == other.pos;
+return threads == other.threads && pos == other.pos;
 }

 bool

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67454?usp=email
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: I18d3a5b908d8575aef198f457b85060aa202bd5f
Gerrit-Change-Number: 67454
Gerrit-PatchSet: 10
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Giacomo Travaglini 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Jason Lowe-Power 
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


[gem5-dev] [S] Change in gem5/gem5[develop]: tests: Make the GTestException type accessible to unit tests

2023-02-02 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67455?usp=email )


 (

1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the  
submitted one.
 )Change subject: tests: Make the GTestException type accessible to unit  
tests

..

tests: Make the GTestException type accessible to unit tests

Change-Id: I654589a3d90377657393d98e75c0697ba0e72c76
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67455
Reviewed-by: Bobby Bruce 
Reviewed-by: Jason Lowe-Power 
Tested-by: kokoro 
Maintainer: Jason Lowe-Power 
---
M src/base/gtest/logging.hh
M src/base/gtest/logging_mock.cc
2 files changed, 22 insertions(+), 8 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, but someone else must approve; Looks  
good to me, approved

  kokoro: Regressions pass
  Bobby Bruce: Looks good to me, approved




diff --git a/src/base/gtest/logging.hh b/src/base/gtest/logging.hh
index 12d4e5a..1d5a39c 100644
--- a/src/base/gtest/logging.hh
+++ b/src/base/gtest/logging.hh
@@ -32,6 +32,14 @@
 namespace gem5
 {

+// This custom exception type will help prevent fatal exceptions from being
+// caught by other code in gem5 and let them escape to the gtest framework.
+// Unfortunately that results in a somewhat confusing message about an  
unknown
+// exception being thrown after the panic/fatal message has been printed,  
but

+// there will at least be some indication what went wrong.
+struct GTestException
+{};
+
 class GTestLogOutput : public std::ostringstream
 {
   private:
diff --git a/src/base/gtest/logging_mock.cc b/src/base/gtest/logging_mock.cc
index 101374e..07a20ea 100644
--- a/src/base/gtest/logging_mock.cc
+++ b/src/base/gtest/logging_mock.cc
@@ -36,14 +36,6 @@

 namespace {

-// This custom exception type will help prevent fatal exceptions from being
-// caught by other code in gem5 and let them escape to the gtest framework.
-// Unfortunately that results in a somewhat confusing message about an  
unknown
-// exception being thrown after the panic/fatal message has been printed,  
but

-// there will at least be some indication what went wrong.
-struct GTestException
-{};
-
 class GTestLogger : public Logger
 {
   public:

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67455?usp=email
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: I654589a3d90377657393d98e75c0697ba0e72c76
Gerrit-Change-Number: 67455
Gerrit-PatchSet: 3
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Jason Lowe-Power 
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


[gem5-dev] [M] Change in gem5/gem5[develop]: mem: Deprecate RequestPort and ResponsePort owner ref member

2023-02-02 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67551?usp=email )



Change subject: mem: Deprecate RequestPort and ResponsePort owner ref member
..

mem: Deprecate RequestPort and ResponsePort owner ref member

The reference can be bound to an invalid object (*nullptr) in
situations where no proper owner SimObject can be provided to the port
constructor. This rightfully triggers a UBSAN warning.

Also, these two classes do not make use of the owner reference member
themselves and expose it as a protected member reference to
subclasses. This desing has several drawbacks: requires the reference
to owner to travel the class hierarchy up and down, loosing its true
static type in the process ; non-private member variable should not be
part of the API of such fundamental classes, if only for
maintainability ; a reference bound from a nullable pointer is a lying
API as it hides the optional aspect of ownership.

Note that the reference to invalid object can't be properly fixed until
the complete removal of the owner reference. This patch lays the path
toward that fix.

Change-Id: I8b42bc57d7826656726f7708492c43366f20633a
---
M src/mem/port.cc
M src/mem/port.hh
2 files changed, 79 insertions(+), 11 deletions(-)



diff --git a/src/mem/port.cc b/src/mem/port.cc
index 18793d4..36a32f9 100644
--- a/src/mem/port.cc
+++ b/src/mem/port.cc
@@ -120,9 +120,22 @@
 /**
  * Request port
  */
-RequestPort::RequestPort(const std::string& name, SimObject* _owner,
-PortID _id) : Port(name, _id), _responsePort(),
-owner(*_owner)
+[[deprecated]]
+RequestPort::RequestPort(const std::string& name,
+ SimObject* _owner,
+ PortID _id):
+Port(name, _id), _responsePort(), owner{*_owner}
+{
+}
+
+/*** FIXME:
+ * The owner reference member is going through a deprecation path. In the
+ * meantime, it must be initialized but no valid reference is available  
here.

+ * Let's trigger a big dirty warning until definitive owner member removal.
+ */
+RequestPort::RequestPort(const std::string& name, PortID _id) :
+Port(name, _id), _responsePort(),
+owner{*static_cast(nullptr)}
 {
 }

@@ -175,9 +188,28 @@
 /**
  * Response port
  */
-ResponsePort::ResponsePort(const std::string& name, SimObject* _owner,
-PortID id) : Port(name, id), _requestPort(),
-defaultBackdoorWarned(false), owner(*_owner)
+
+[[deprecated]]
+ResponsePort::ResponsePort(const std::string& name,
+   SimObject* _owner,
+   PortID _id):
+Port(name, _id),
+_requestPort(),
+defaultBackdoorWarned(false),
+owner{*_owner}
+{
+}
+
+/*** FIXME:
+ * The owner reference member is going through a deprecation path. In the
+ * meantime, it must be initialized but no valid reference is available  
here.

+ * Let's trigger a big dirty warning until definitive owner member removal.
+ */
+ResponsePort::ResponsePort(const std::string& name, PortID id) :
+Port(name, id),
+_requestPort(),
+defaultBackdoorWarned(false),
+owner{*static_cast(nullptr)}
 {
 }

diff --git a/src/mem/port.hh b/src/mem/port.hh
index fb0f4b8..c16eb1d 100644
--- a/src/mem/port.hh
+++ b/src/mem/port.hh
@@ -86,8 +86,13 @@
 SimObject 

   public:
+[[deprecated("RequestPort ownership is deprecated. "
+ "Owner should now be registered in derived classes.")]]
 RequestPort(const std::string& name, SimObject* _owner,
-   PortID id=InvalidPortID);
+PortID id=InvalidPortID);
+
+RequestPort(const std::string& name, PortID id=InvalidPortID);
+
 virtual ~RequestPort();

 /**
@@ -266,9 +271,9 @@
 class [[deprecated]] MasterPort : public RequestPort
 {
   public:
-MasterPort(const std::string& name, SimObject* _owner,
-   PortID id=InvalidPortID) : RequestPort(name, _owner, id)
-   {}
+MasterPort(const std::string& name, PortID id=InvalidPortID) :
+RequestPort(name, id)
+{}
 };

 /**
@@ -294,8 +299,13 @@
 SimObject& owner;

   public:
+[[deprecated("ResponsePort ownership is deprecated. "
+ "Owner should now be registered in derived classes.")]]
 ResponsePort(const std::string& name, SimObject* _owner,
-  PortID id=InvalidPortID);
+ PortID id=InvalidPortID);
+
+ResponsePort(const std::string& name, PortID id=InvalidPortID);
+
 virtual ~ResponsePort();

 /**

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67551?usp=email
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: I8b42bc57d7826656726f7708492c43366f20633a
Gerrit-Change-Number: 67551
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange

[gem5-dev] [S] Change in gem5/gem5[develop]: scons: Link tcmalloc_minimal by default instead of tcmalloc

2023-02-01 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67431?usp=email )


Change subject: scons: Link tcmalloc_minimal by default instead of tcmalloc
..

scons: Link tcmalloc_minimal by default instead of tcmalloc

tcmalloc triggers asan while tcmalloc_minimal does not. The feature
difference is not significant for regular gem5 use.

Jira issue: https://gem5.atlassian.net/browse/GEM5-1312

Change-Id: I410a26d2ecdf422c456d44276d9e7ec60582b8cc
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67431
Maintainer: Bobby Bruce 
Tested-by: kokoro 
Reviewed-by: Bobby Bruce 
---
M SConstruct
1 file changed, 20 insertions(+), 2 deletions(-)

Approvals:
  kokoro: Regressions pass
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved




diff --git a/SConstruct b/SConstruct
index 2e525a3..6abbb51 100755
--- a/SConstruct
+++ b/SConstruct
@@ -609,9 +609,9 @@

 if not GetOption('without_tcmalloc'):
 with gem5_scons.Configure(env) as conf:
-if conf.CheckLib('tcmalloc'):
+if conf.CheckLib('tcmalloc_minimal'):
 conf.env.Append(CCFLAGS=conf.env['TCMALLOC_CCFLAGS'])
-elif conf.CheckLib('tcmalloc_minimal'):
+elif conf.CheckLib('tcmalloc'):
 conf.env.Append(CCFLAGS=conf.env['TCMALLOC_CCFLAGS'])
 else:
 warning("You can get a 12% performance improvement by "

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67431?usp=email
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: I410a26d2ecdf422c456d44276d9e7ec60582b8cc
Gerrit-Change-Number: 67431
Gerrit-PatchSet: 2
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Gabriel B. 
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


[gem5-dev] [S] Change in gem5/gem5[develop]: tests: Make the GTestException type accessible to unit tests

2023-01-25 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67455?usp=email )



Change subject: tests: Make the GTestException type accessible to unit tests
..

tests: Make the GTestException type accessible to unit tests

Change-Id: I654589a3d90377657393d98e75c0697ba0e72c76
---
M src/base/gtest/logging.hh
M src/base/gtest/logging_mock.cc
2 files changed, 17 insertions(+), 8 deletions(-)



diff --git a/src/base/gtest/logging.hh b/src/base/gtest/logging.hh
index 12d4e5a..1d5a39c 100644
--- a/src/base/gtest/logging.hh
+++ b/src/base/gtest/logging.hh
@@ -32,6 +32,14 @@
 namespace gem5
 {

+// This custom exception type will help prevent fatal exceptions from being
+// caught by other code in gem5 and let them escape to the gtest framework.
+// Unfortunately that results in a somewhat confusing message about an  
unknown
+// exception being thrown after the panic/fatal message has been printed,  
but

+// there will at least be some indication what went wrong.
+struct GTestException
+{};
+
 class GTestLogOutput : public std::ostringstream
 {
   private:
diff --git a/src/base/gtest/logging_mock.cc b/src/base/gtest/logging_mock.cc
index 101374e..07a20ea 100644
--- a/src/base/gtest/logging_mock.cc
+++ b/src/base/gtest/logging_mock.cc
@@ -36,14 +36,6 @@

 namespace {

-// This custom exception type will help prevent fatal exceptions from being
-// caught by other code in gem5 and let them escape to the gtest framework.
-// Unfortunately that results in a somewhat confusing message about an  
unknown
-// exception being thrown after the panic/fatal message has been printed,  
but

-// there will at least be some indication what went wrong.
-struct GTestException
-{};
-
 class GTestLogger : public Logger
 {
   public:

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67455?usp=email
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: I654589a3d90377657393d98e75c0697ba0e72c76
Gerrit-Change-Number: 67455
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: scons: Raise bin size limit for sanitized builds.

2023-01-25 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67451?usp=email )


Change subject: scons: Raise bin size limit for sanitized builds.
..

scons: Raise bin size limit for sanitized builds.

Sanitizers can enlarge binary size drammatically, north of 2GB. This
can prevent successful linkage due to symbol relocation outside from
the 2GB region allocated by the small x86_64 code model that is
enabled by default (32-bit relative offset limitation). Switching to
the medium model in x86_64 enables 64-bit relative offset for large
objects (>64KB by default) while sticking to 32-bit relative
addressing for code and smaller objects. Note this comes at a
potential performance cost so it should not be enabled in all cases.
This should still be a very happy medium for non-perf-critical
sanitized builds.

Jira issue: https://gem5.atlassian.net/browse/GEM5-1313

Change-Id: I9aceacfcda99cc29c8fb24b7c69aaab019ce97fd
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67451
Tested-by: kokoro 
Reviewed-by: Jason Lowe-Power 
Maintainer: Jason Lowe-Power 
---
M SConstruct
1 file changed, 66 insertions(+), 0 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/SConstruct b/SConstruct
index e08c2984..43ca3ac 100755
--- a/SConstruct
+++ b/SConstruct
@@ -290,6 +290,17 @@
 if main['GCC'] + main['CLANG'] > 1:
 error('Two compilers enabled at once?')

+# Find the gem5 binary target architecture (usually host architecture). The
+# "Target: " is consistent accross gcc and clang at the time of
+# writting this.
+bin_target_arch = readCommand([main['CXX'], '--verbose'], exception=False)
+main["BIN_TARGET_ARCH"] = (
+"x86_64"
+if bin_target_arch.find("Target: x86_64") != -1
+else "aarch64"
+if bin_target_arch.find("Target: aarch64") != -1
+else "unknown"
+)

 
 #
@@ -516,6 +527,35 @@
 env.Append(CCFLAGS=['-fsanitize=%s' % sanitizers,
  '-fno-omit-frame-pointer'],
 LINKFLAGS='-fsanitize=%s' % sanitizers)
+if main["BIN_TARGET_ARCH"] == "x86_64":
+# Sanitizers can enlarge binary size drammatically, north  
of

+# 2GB.  This can prevent successful linkage due to symbol
+# relocation outside from the 2GB region allocated by the  
small
+# x86_64 code model that is enabled by default (32-bit  
relative
+# offset limitation).  Switching to the medium model in  
x86_64
+# enables 64-bit relative offset for large objects (>64KB  
by

+# default) while sticking to 32-bit relative addressing for
+# code and smaller objects. Note this comes at a potential
+# performance cost so it should not be enabled in all  
cases.

+# This should still be a very happy medium for
+# non-perf-critical sanitized builds.
+env.Append(CCFLAGS='-mcmodel=medium')
+env.Append(LINKFLAGS='-mcmodel=medium')
+elif main["BIN_TARGET_ARCH"] == "aarch64":
+# aarch64 default code model is small but with different
+# constrains than for x86_64. With aarch64, the small code
+# model enables 4GB distance between symbols. This is
+# sufficient for the largest ALL/gem5.debug target with all
+# sanitizers enabled at the time of writting this. Note  
that
+# the next aarch64 code model is "large" which prevents  
dynamic

+# linkage so it should be avoided when possible.
+pass
+else:
+warning(
+"Unknown code model options for your architecture. "
+"Linkage might fail for larger binaries "
+"(e.g., ALL/gem5.debug with sanitizers enabled)."
+)
 else:
 warning("Don't know how to enable %s sanitizer(s) for your "
 "compiler." % sanitizers)

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67451?usp=email
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: I9aceacfcda99cc29c8fb24b7c69aaab019ce97fd
Gerrit-Change-Number: 67451
Gerrit-PatchSet: 2
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Jason Lowe-Power 
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


[gem5-dev] [S] Change in gem5/gem5[develop]: sim: System::Threads::const_iterator copy ops explicitely deleted

2023-01-24 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67454?usp=email )



Change subject: sim: System::Threads::const_iterator copy ops explicitely  
deleted

..

sim: System::Threads::const_iterator copy ops explicitely deleted

Change-Id: I18d3a5b908d8575aef198f457b85060aa202bd5f
---
M src/sim/system.hh
1 file changed, 11 insertions(+), 2 deletions(-)



diff --git a/src/sim/system.hh b/src/sim/system.hh
index d691fb8..e1865f8 100644
--- a/src/sim/system.hh
+++ b/src/sim/system.hh
@@ -162,8 +162,8 @@
 {}

   public:
-const_iterator(const const_iterator &) = default;
-const_iterator  = (const const_iterator &) = default;
+const_iterator(const const_iterator &) = delete;
+const_iterator  = (const const_iterator &) = delete;

 using iterator_category = std::forward_iterator_tag;
 using value_type = ThreadContext *;

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67454?usp=email
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: I18d3a5b908d8575aef198f457b85060aa202bd5f
Gerrit-Change-Number: 67454
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: mem-ruby: Fix nullptr deref with base Port classes

2023-01-24 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67452?usp=email )



Change subject: mem-ruby: Fix nullptr deref with base Port classes
..

mem-ruby: Fix nullptr deref with base Port classes

Change-Id: I29214278c3dd4829c89a6f7c93214b8123912e74
---
M src/arch/arm/table_walker.cc
M src/cpu/simple/atomic.cc
M src/mem/cache/base.cc
M src/mem/port.cc
M src/mem/port.hh
M src/mem/ruby/system/RubyPort.cc
M src/sim/port.cc
M src/sim/port.hh
8 files changed, 106 insertions(+), 64 deletions(-)



diff --git a/src/arch/arm/table_walker.cc b/src/arch/arm/table_walker.cc
index bbf102d..8e16e9b 100644
--- a/src/arch/arm/table_walker.cc
+++ b/src/arch/arm/table_walker.cc
@@ -234,7 +234,7 @@
   Addr size, Tick delay)
 {
 if (state->event) {
-owner.schedule(state->event, curTick() + delay);
+owner().schedule(state->event, curTick() + delay);
 }
 delete state;
 }
diff --git a/src/cpu/simple/atomic.cc b/src/cpu/simple/atomic.cc
index d6638b3..770bbf4 100644
--- a/src/cpu/simple/atomic.cc
+++ b/src/cpu/simple/atomic.cc
@@ -281,7 +281,7 @@
 __func__, pkt->getAddr(), pkt->cmdString());

 // X86 ISA: Snooping an invalidation for monitor/mwait
-AtomicSimpleCPU *cpu = (AtomicSimpleCPU *)();
+AtomicSimpleCPU *cpu = (AtomicSimpleCPU *)(());

 for (ThreadID tid = 0; tid < cpu->numThreads; tid++) {
 if (cpu->getCpuAddrMonitor(tid)->doMonitor(pkt)) {
@@ -312,7 +312,7 @@
 __func__, pkt->getAddr(), pkt->cmdString());

 // X86 ISA: Snooping an invalidation for monitor/mwait
-AtomicSimpleCPU *cpu = (AtomicSimpleCPU *)();
+AtomicSimpleCPU *cpu = (AtomicSimpleCPU *)(());
 for (ThreadID tid = 0; tid < cpu->numThreads; tid++) {
 if (cpu->getCpuAddrMonitor(tid)->doMonitor(pkt)) {
 cpu->wakeup(tid);
diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc
index cf6c9fe..cbf4bea 100644
--- a/src/mem/cache/base.cc
+++ b/src/mem/cache/base.cc
@@ -150,7 +150,7 @@
 // if we already scheduled a retry in this cycle, but it has not yet
 // happened, cancel it
 if (sendRetryEvent.scheduled()) {
-owner.deschedule(sendRetryEvent);
+owner().deschedule(sendRetryEvent);
 DPRINTF(CachePort, "Port descheduled retry\n");
 mustSendRetry = true;
 }
@@ -164,7 +164,7 @@
 blocked = false;
 if (mustSendRetry) {
 // @TODO: need to find a better time (next cycle?)
-owner.schedule(sendRetryEvent, curTick() + 1);
+owner().schedule(sendRetryEvent, curTick() + 1);
 }
 }

diff --git a/src/mem/port.cc b/src/mem/port.cc
index 18793d4..316a76a 100644
--- a/src/mem/port.cc
+++ b/src/mem/port.cc
@@ -121,8 +121,7 @@
  * Request port
  */
 RequestPort::RequestPort(const std::string& name, SimObject* _owner,
-PortID _id) : Port(name, _id), _responsePort(),
-owner(*_owner)
+PortID _id) : Port(name, _owner, _id),  
_responsePort()

 {
 }

@@ -176,8 +175,8 @@
  * Response port
  */
 ResponsePort::ResponsePort(const std::string& name, SimObject* _owner,
-PortID id) : Port(name, id), _requestPort(),
-defaultBackdoorWarned(false), owner(*_owner)
+PortID id) : Port(name, _owner, id), _requestPort(),
+defaultBackdoorWarned(false)
 {
 }

diff --git a/src/mem/port.hh b/src/mem/port.hh
index fb0f4b8..fe5a12a 100644
--- a/src/mem/port.hh
+++ b/src/mem/port.hh
@@ -82,9 +82,6 @@
   private:
 ResponsePort *_responsePort;

-  protected:
-SimObject 
-
   public:
 RequestPort(const std::string& name, SimObject* _owner,
PortID id=InvalidPortID);
@@ -290,9 +287,6 @@

 bool defaultBackdoorWarned;

-  protected:
-SimObject& owner;
-
   public:
 ResponsePort(const std::string& name, SimObject* _owner,
   PortID id=InvalidPortID);
diff --git a/src/mem/ruby/system/RubyPort.cc  
b/src/mem/ruby/system/RubyPort.cc

index 48f655d..28055e2 100644
--- a/src/mem/ruby/system/RubyPort.cc
+++ b/src/mem/ruby/system/RubyPort.cc
@@ -171,12 +171,12 @@
 bool
 RubyPort::PioRequestPort::recvTimingResp(PacketPtr pkt)
 {
-RubyPort *rp = static_cast();
+RubyPort& rp = safe_cast(owner());
 DPRINTF(RubyPort, "Response for address: 0x%#x\n", pkt->getAddr());

 // send next cycle
-rp->pioResponsePort.schedTimingResp(
-pkt, curTick() + rp->m_ruby_system->clockPeriod());
+rp.pioResponsePort.schedTimingResp(
+pkt, curTick() + rp.m_ruby_system->clockPeriod());
 return true;
 }

@@ -199,8 +199,8 @@
 pkt->getAddr(), port->name());

 // attempt to send the response in the next cycle
-RubyPort *rp = static_cast();
-port->schedTimingResp(pkt, curTick() +  
rp->m_ruby_system->clockPeriod());

+RubyPort& rp = safe_cast(owner());
+port->schedTimingResp(pkt, curTick() +  
rp.m_ruby_system->clockPeriod());


 return true;
 }
@@ 

[gem5-dev] [S] Change in gem5/gem5[develop]: base: Fix safe_cast for reference types

2023-01-24 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67453?usp=email )



Change subject: base: Fix safe_cast for reference types
..

base: Fix safe_cast for reference types

Change-Id: I86692561c169b1ad063000c990a52ea80c6637ca
---
M src/base/cast.hh
1 file changed, 18 insertions(+), 5 deletions(-)



diff --git a/src/base/cast.hh b/src/base/cast.hh
index cdc3c62..9c29c94 100644
--- a/src/base/cast.hh
+++ b/src/base/cast.hh
@@ -30,6 +30,8 @@
 #define __BASE_CAST_HH__

 #include 
+#include 
+#include "base/logging.hh"

 namespace gem5
 {
@@ -44,10 +46,12 @@

 template 
 inline T
-safe_cast(U ptr)
+safe_cast(U&& ptr)
 {
-T ret = dynamic_cast(ptr);
-assert(ret);
+T ret = dynamic_cast(std::forward(ptr));
+if constexpr (std::is_pointer_v) {
+gem5_assert(ret);
+}
 return ret;
 }

@@ -59,9 +63,9 @@

 template 
 inline T
-safe_cast(U ptr)
+safe_cast(U&& ptr)
 {
-return static_cast(ptr);
+return static_cast(std::forward(ptr));
 }

 #endif

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67453?usp=email
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: I86692561c169b1ad063000c990a52ea80c6637ca
Gerrit-Change-Number: 67453
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: scons: Raise bin size limit for sanitized builds.

2023-01-24 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67451?usp=email )



Change subject: scons: Raise bin size limit for sanitized builds.
..

scons: Raise bin size limit for sanitized builds.

Sanitizers can enlarge binary size drammatically, north of 2GB. This
can prevent successful linkage due to symbol relocation outside from
the 2GB region allocated by the small x86_64 code model that is
enabled by default (32-bit relative offset limitation). Switching to
the medium model in x86_64 enables 64-bit relative offset for large
objects (>64KB by default) while sticking to 32-bit relative
addressing for code and smaller objects. Note this comes at a
potential performance cost so it should not be enabled in all cases.
This should still be a very happy medium for non-perf-critical
sanitized builds.

Jira issue: https://gem5.atlassian.net/browse/GEM5-1313

Change-Id: I9aceacfcda99cc29c8fb24b7c69aaab019ce97fd
---
M SConstruct
1 file changed, 62 insertions(+), 0 deletions(-)



diff --git a/SConstruct b/SConstruct
index e08c2984..43ca3ac 100755
--- a/SConstruct
+++ b/SConstruct
@@ -290,6 +290,17 @@
 if main['GCC'] + main['CLANG'] > 1:
 error('Two compilers enabled at once?')

+# Find the gem5 binary target architecture (usually host architecture). The
+# "Target: " is consistent accross gcc and clang at the time of
+# writting this.
+bin_target_arch = readCommand([main['CXX'], '--verbose'], exception=False)
+main["BIN_TARGET_ARCH"] = (
+"x86_64"
+if bin_target_arch.find("Target: x86_64") != -1
+else "aarch64"
+if bin_target_arch.find("Target: aarch64") != -1
+else "unknown"
+)

 
 #
@@ -516,6 +527,35 @@
 env.Append(CCFLAGS=['-fsanitize=%s' % sanitizers,
  '-fno-omit-frame-pointer'],
 LINKFLAGS='-fsanitize=%s' % sanitizers)
+if main["BIN_TARGET_ARCH"] == "x86_64":
+# Sanitizers can enlarge binary size drammatically, north  
of

+# 2GB.  This can prevent successful linkage due to symbol
+# relocation outside from the 2GB region allocated by the  
small
+# x86_64 code model that is enabled by default (32-bit  
relative
+# offset limitation).  Switching to the medium model in  
x86_64
+# enables 64-bit relative offset for large objects (>64KB  
by

+# default) while sticking to 32-bit relative addressing for
+# code and smaller objects. Note this comes at a potential
+# performance cost so it should not be enabled in all  
cases.

+# This should still be a very happy medium for
+# non-perf-critical sanitized builds.
+env.Append(CCFLAGS='-mcmodel=medium')
+env.Append(LINKFLAGS='-mcmodel=medium')
+elif main["BIN_TARGET_ARCH"] == "aarch64":
+# aarch64 default code model is small but with different
+# constrains than for x86_64. With aarch64, the small code
+# model enables 4GB distance between symbols. This is
+# sufficient for the largest ALL/gem5.debug target with all
+# sanitizers enabled at the time of writting this. Note  
that
+# the next aarch64 code model is "large" which prevents  
dynamic

+# linkage so it should be avoided when possible.
+pass
+else:
+warning(
+"Unknown code model options for your architecture. "
+"Linkage might fail for larger binaries "
+"(e.g., ALL/gem5.debug with sanitizers enabled)."
+)
 else:
 warning("Don't know how to enable %s sanitizer(s) for your "
 "compiler." % sanitizers)

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67451?usp=email
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: I9aceacfcda99cc29c8fb24b7c69aaab019ce97fd
Gerrit-Change-Number: 67451
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: scons: Link tcmalloc_minimal by default instead of tcmalloc

2023-01-20 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67431?usp=email )



Change subject: scons: Link tcmalloc_minimal by default instead of tcmalloc
..

scons: Link tcmalloc_minimal by default instead of tcmalloc

tcmalloc triggers asan while tcmalloc_minimal does not. The feature
difference is not significant for regular gem5 use.

Jira issue: https://gem5.atlassian.net/browse/GEM5-1312

Change-Id: I410a26d2ecdf422c456d44276d9e7ec60582b8cc
---
M SConstruct
1 file changed, 16 insertions(+), 2 deletions(-)



diff --git a/SConstruct b/SConstruct
index e08c2984..4b53299 100755
--- a/SConstruct
+++ b/SConstruct
@@ -567,9 +567,9 @@

 if not GetOption('without_tcmalloc'):
 with gem5_scons.Configure(env) as conf:
-if conf.CheckLib('tcmalloc'):
+if conf.CheckLib('tcmalloc_minimal'):
 conf.env.Append(CCFLAGS=conf.env['TCMALLOC_CCFLAGS'])
-elif conf.CheckLib('tcmalloc_minimal'):
+elif conf.CheckLib('tcmalloc'):
 conf.env.Append(CCFLAGS=conf.env['TCMALLOC_CCFLAGS'])
 else:
 warning("You can get a 12% performance improvement by "

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67431?usp=email
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: I410a26d2ecdf422c456d44276d9e7ec60582b8cc
Gerrit-Change-Number: 67431
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [M] Change in gem5/gem5[develop]: base: base: Turn all logging.hh macros into expression kind

2023-01-20 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67336?usp=email )



Change subject: base: base: Turn all logging.hh macros into expression kind
..

base: base: Turn all logging.hh macros into expression kind

In the previous version, the body of several macros was a statement
(do{...} while(0);) and not an expression. In the new version, all macros
are expressions. Expressions can be used everywhere a statement is expected
and in other locations as well.

For instance, expressions can be used with the comma operator. When doing
generic programming, the comma operator helps manipulating parameter packs.
With a statement-based implementation, (gem5_assert(args > 0), ...) could
not be written while perfectly sound.

Also, (c1 ?  a : c2 ?  b : (gem5_assert(c3), c)) is a usefull expression to
assert completeness of cascaded conditions that cannot be easily and
efficiently achieved without an expression kind of assertion.

Change-Id: Ia0efeb15e6deda6b90529a6f0e00ebe2e9b5d2a0
---
M src/base/logging.hh
1 file changed, 91 insertions(+), 51 deletions(-)



diff --git a/src/base/logging.hh b/src/base/logging.hh
index 95bb20d..c4e7b8e 100644
--- a/src/base/logging.hh
+++ b/src/base/logging.hh
@@ -138,9 +138,12 @@
 const char *prefix;
 };

+#define THIS_LINE_LOC ::gem5::Logger::Loc(__FILE__, __LINE__)

-#define base_message(logger, ...) \
-logger.print(::gem5::Logger::Loc(__FILE__, __LINE__), __VA_ARGS__)
+#define base_message(logger, ...)   \
+[ = logger](const auto&... args) {  \
+log.print(THIS_LINE_LOC, args...);  \
+}(__VA_ARGS__)

 /*
  * Only print the message the first time this expression is
@@ -150,19 +153,29 @@
  * would have resulted in a different message thoes messages would be
  * supressed.
  */
-#define base_message_once(...) do { \
-static bool once = false;   \
-if (!once) {\
-base_message(__VA_ARGS__);  \
-once = true;\
-}   \
-} while (0)
+#define base_message_once(logger, ...)  \
+[ = logger](const auto&... args) {  \
+static bool once{false};\
+if (GEM5_UNLIKELY(!once)) { \
+once = true;\
+base_message(log, args...); \
+}   \
+}(__VA_ARGS__)  \

-#define exit_message(logger, ...)   \
-do {\
-base_message(logger, __VA_ARGS__);  \
-logger.exit_helper();   \
-} while (0)
+/*
+ * logger.exit_helper() can't be called inside the lambda for now as the
+ * lambda's operator() can't be [[noreturn]]. As a result, exit_message  
and it'
+ * s derivative cannot be used in functions without also specifying a  
return

+ * value, which is inconvenient if not impossible.
+ */
+
+#define exit_message(logger, ...)   \
+(   \
+[ = logger](const auto&... args) {  \
+base_message(log, args...); \
+}(__VA_ARGS__), \
+logger.exit_helper()\
+)

 /**
  * This implements a cprintf based panic() function.  panic() should
@@ -200,13 +213,13 @@
  *
  * @ingroup api_logger
  */
-#define panic_if(cond, ...)  \
-do { \
-if (GEM5_UNLIKELY(cond)) { \
-panic("panic condition " # cond " occurred: %s", \
-  ::gem5::csprintf(__VA_ARGS__));\
-}\
-} while (0)
+#define panic_if(cond, ...) \
+[cdt = static_cast(cond)](const auto&... args) {  \
+if (GEM5_UNLIKELY(cdt)) {   \
+panic("panic condition " # cond " occurred: %s",\
+::gem5::csprintf(args...)); \
+}   \
+}(__VA_ARGS__)  \


 /**
@@ -223,12 +236,12 @@
  * @ingroup api_logger
  */
 #define fatal_if(cond, ...) \
-do {\
-if (GEM5_UNLIKELY(cond)) {\
+[cdt = static_cast(cond)](const auto&... args) {  \
+if (GEM5_UNLIKELY(cdt)) {   \
 fatal("fatal condition " # cond " occurred: %s",\
-

[gem5-dev] [S] Change in gem5/gem5[develop]: python: Fix deprecated decorator

2023-01-19 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67334?usp=email )


Change subject: python: Fix deprecated decorator
..

python: Fix deprecated decorator

The deprecation message was firing during the decoration process instead of  
firing upon first call to deprecated function. The message now fires only  
if the deprected function is called.


Change-Id: I2d510eb24884fdba0123e71e8472db68ae9d2ce4
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67334
Maintainer: Jason Lowe-Power 
Reviewed-by: Jason Lowe-Power 
Reviewed-by: Daniel Carvalho 
Tested-by: kokoro 
Reviewed-by: Richard Cooper 
---
M src/python/m5/util/__init__.py
1 file changed, 23 insertions(+), 2 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  Richard Cooper: Looks good to me, approved
  kokoro: Regressions pass
  Daniel Carvalho: Looks good to me, but someone else must approve




diff --git a/src/python/m5/util/__init__.py b/src/python/m5/util/__init__.py
index bc4ab4a..5ae4875 100644
--- a/src/python/m5/util/__init__.py
+++ b/src/python/m5/util/__init__.py
@@ -108,8 +108,12 @@
 message += f" Prefer {replacement} instead."
 logger(message)

-notifyDeprecation()
-return func
+@wraps(func)
+def wrapper(*args, **kwargs):
+notifyDeprecation()
+return func(*args, **kwargs)
+
+return wrapper

 return decorator


--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67334?usp=email
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: I2d510eb24884fdba0123e71e8472db68ae9d2ce4
Gerrit-Change-Number: 67334
Gerrit-PatchSet: 4
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Andreas Sandberg 
Gerrit-Reviewer: Daniel Carvalho 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Richard Cooper 
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


[gem5-dev] [M] Change in gem5/gem5[develop]: base: Enable non-copiable types in gem5_assert message formatting

2023-01-19 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67335?usp=email )



Change subject: base: Enable non-copiable types in gem5_assert message  
formatting

..

base: Enable non-copiable types in gem5_assert message formatting

Also:
  - Removed useless inclusion of tuple in logging.h.
  - Turn the bode of gem5_assert into an expression.
  - Added a unit test with formatted assert failure message.

In the previous definition of gem5_assert, the body was a statement (do{}
while(0);) and not an expression. Note that the new definition follows the
same style as GNU assert. Expressions can be used in more situations than
statements.

For instance, expressions can be used with the comma operator. When doing
generic programming, the comma operator helps manipulating parameter
packs.With the previous structure, (gem5_assert(args > 0), ...) could not
be written while perfectly sound and more readable than the current
alternative: assert(((args> 0) && ...)).

Also, (c1 ? a : c2 ?  b : gem5_assert(c3), c) is a usefull expression to
assert completeness of cascaded conditions that cannot be easily achieved
without an expression kind of assertion.

Change-Id: I2cefc18df1e99b70e60e64588df61eb72a3e5166
---
M src/base/logging.hh
M src/base/logging.test.cc
2 files changed, 45 insertions(+), 22 deletions(-)



diff --git a/src/base/logging.hh b/src/base/logging.hh
index 8949b0c..0e81ffe 100644
--- a/src/base/logging.hh
+++ b/src/base/logging.hh
@@ -43,7 +43,6 @@

 #include 
 #include 
-#include 
 #include 

 #include "base/compiler.hh"
@@ -289,24 +288,10 @@
 #define NDEBUG_DEFINED 0
 #endif

-template 
-inline std::string
-_assertMsg(const std::string , Args... args)
-{
-return std::string(": ") + csprintf(format, args...);
-}
-
-inline const char *
-_assertMsg()
-{
-return "";
-}
-
 /**
  * The assert macro will function like a normal assert, but will use panic
  * instead of straight abort(). This allows to perform some cleaning up in
- * ExitLogger::exit() before calling abort(). This macro will not check its
- * condition in fast builds, but it must still be valid code.
+ * ExitLogger::exit() before calling abort().
  *
  * @param cond Condition that is checked; if false -> panic
  * @param ...  Printf-based format string with arguments, extends printout.
@@ -315,12 +300,18 @@
  *
  * @ingroup api_logger
  */
-#define gem5_assert(cond, ...) \
-do { \
-if (GEM5_UNLIKELY(!NDEBUG_DEFINED && !static_cast(cond))) { \
-panic("assert(" #cond ") failed%s", _assertMsg(__VA_ARGS__)); \
-} \
-} while (0)
+#define gem5_assert(cond, ...)  \
+(   \
+GEM5_UNLIKELY(NDEBUG_DEFINED || static_cast(cond)) ?  \
+void(0):\
+[](const auto&... args) {   \
+auto msg = [&]{ \
+if constexpr (sizeof...(args) == 0) return "";  \
+else return std::string(": ") + csprintf(args...);  \
+};  \
+panic("assert(" #cond ") failed%s", msg()); \
+}(__VA_ARGS__)  \
+)
 /** @} */ // end of api_logger

 #define chatty_assert(...) \
diff --git a/src/base/logging.test.cc b/src/base/logging.test.cc
index 38cc605..5d10f6e 100644
--- a/src/base/logging.test.cc
+++ b/src/base/logging.test.cc
@@ -553,6 +553,9 @@
 gem5_assert(true, "message\n");
 ASSERT_DEATH(gem5_assert(false, "message\n"), ::testing::HasSubstr(
 "panic: assert(false) failed: message\nMemory Usage:"));
+ASSERT_DEATH(gem5_assert(false, "%s, %s!\n", "Hello", "World"),
+::testing::HasSubstr(
+"panic: assert(false) failed: Hello, World!\nMemory Usage:"));
 gem5_assert(true);
 ASSERT_DEATH(gem5_assert(false), ::testing::HasSubstr(
 "panic: assert(false) failed\nMemory Usage:"));

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67335?usp=email
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: I2cefc18df1e99b70e60e64588df61eb72a3e5166
Gerrit-Change-Number: 67335
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: util-m5: Fix deprecated decorator

2023-01-19 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/67334?usp=email )



Change subject: util-m5: Fix deprecated decorator
..

util-m5: Fix deprecated decorator

The deprecation message was firing during the decoration process instead of
firing upon first call to deprecated function. The message now fires only if
the deprected function is called.

Change-Id: I2d510eb24884fdba0123e71e8472db68ae9d2ce4
---
M src/python/m5/util/__init__.py
1 file changed, 19 insertions(+), 2 deletions(-)



diff --git a/src/python/m5/util/__init__.py b/src/python/m5/util/__init__.py
index bc4ab4a..5ae4875 100644
--- a/src/python/m5/util/__init__.py
+++ b/src/python/m5/util/__init__.py
@@ -108,8 +108,12 @@
 message += f" Prefer {replacement} instead."
 logger(message)

-notifyDeprecation()
-return func
+@wraps(func)
+def wrapper(*args, **kwargs):
+notifyDeprecation()
+return func(*args, **kwargs)
+
+return wrapper

 return decorator


--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/67334?usp=email
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: I2d510eb24884fdba0123e71e8472db68ae9d2ce4
Gerrit-Change-Number: 67334
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: ext-testlib: Support str-convertible args in gem5_verify_config

2023-01-03 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/66893?usp=email )


Change subject: ext-testlib: Support str-convertible args in  
gem5_verify_config

..

ext-testlib: Support str-convertible args in gem5_verify_config

gem5_verify_config dit not support string-convertible args due to log_call()
not trying to call str() on them. This patch maps str() on the command
paramters.

It is now possible to pass native integers or even string-like types like
pathlib.Path as arguments without manually converting them to string.

Change-Id: Ifa987f5f1a20f17c8710e1a36d99d424e4c9ce6c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/66893
Reviewed-by: Bobby Bruce 
Maintainer: Bobby Bruce 
Tested-by: kokoro 
---
M ext/testlib/helper.py
1 file changed, 28 insertions(+), 1 deletion(-)

Approvals:
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/ext/testlib/helper.py b/ext/testlib/helper.py
index ed6e325..ea102f2 100644
--- a/ext/testlib/helper.py
+++ b/ext/testlib/helper.py
@@ -149,7 +149,14 @@
 if isinstance(command, str):
 cmdstr = command
 else:
-cmdstr = ' '.join(command)
+try:
+command = list(map(str, command))
+cmdstr = " ".join(command)
+except TypeError as e:
+logger.trace(
+"Argument  must be an iterable of  
string-convertible types"

+)
+raise e

 logger_callback = logger.trace
 logger.trace('Logging call to command: %s' % cmdstr)

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/66893?usp=email
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: Ifa987f5f1a20f17c8710e1a36d99d424e4c9ce6c
Gerrit-Change-Number: 66893
Gerrit-PatchSet: 2
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Hoa Nguyen 
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


[gem5-dev] [S] Change in gem5/gem5[develop]: ext-testlib: Improve error reporting when test definition fails

2023-01-03 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/66892?usp=email )


Change subject: ext-testlib: Improve error reporting when test definition  
fails

..

ext-testlib: Improve error reporting when test definition fails

The error reason is now reported as an element in the XML testing result
summary.

Change-Id: I18b84422bb9580709cf1c5f2a14a5cbb0caf1876
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/66892
Reviewed-by: Bobby Bruce 
Maintainer: Bobby Bruce 
Tested-by: kokoro 
---
M ext/testlib/result.py
1 file changed, 37 insertions(+), 10 deletions(-)

Approvals:
  Bobby Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/ext/testlib/result.py b/ext/testlib/result.py
index 5c60342..786febd 100644
--- a/ext/testlib/result.py
+++ b/ext/testlib/result.py
@@ -191,17 +191,23 @@
 def begin(self, file_):
 file_.write('<')
 file_.write(self.name)
-for attr in self.attributes:
-file_.write(' ')
-attr.write(file_)
+if hasattr(self, 'attributes'):
+for attr in self.attributes:
+file_.write(' ')
+attr.write(file_)
 file_.write('>')

 self.body(file_)

 def body(self, file_):
-for elem in self.elements:
-file_.write('\n')
-elem.write(file_)
+if hasattr(self, 'elements'):
+for elem in self.elements:
+file_.write('\n')
+elem.write(file_)
+if hasattr(self, 'content'):
+file_.write('\n')
+file_.write(
+xml.sax.saxutils.escape(self.content))
 file_.write('\n')

 def end(self, file_):
@@ -286,17 +292,22 @@
 ]

 if str(test_result.result) == 'Failed':
-self.elements.append(JUnitFailure('Test failed', 'ERROR'))
+self.elements.append(JUnitFailure(
+'Test failed',
+str(test_result.result.reason))
+)


 class JUnitFailure(XMLElement):
 name = 'failure'
-def __init__(self, message, fail_type):
+def __init__(self, message, cause):
 self.attributes = [
 XMLAttribute('message', message),
-XMLAttribute('type', fail_type),
 ]
-self.elements = []
+cause_element = XMLElement()
+cause_element.name = 'cause'
+cause_element.content = cause
+self.elements = [cause_element]


 class LargeFileElement(XMLElement):

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/66892?usp=email
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: I18b84422bb9580709cf1c5f2a14a5cbb0caf1876
Gerrit-Change-Number: 66892
Gerrit-PatchSet: 2
Gerrit-Owner: Gabriel B. 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Gabriel B. 
Gerrit-Reviewer: Hoa Nguyen 
Gerrit-Reviewer: kokoro 
Gerrit-CC: Jason Lowe-Power 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: ext-testlib: Improve error reporting when test definition fails

2023-01-03 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/66892?usp=email )



Change subject: ext-testlib: Improve error reporting when test definition  
fails

..

ext-testlib: Improve error reporting when test definition fails

The error reason is now reported as an element in the XML testing result
summary.

Change-Id: I18b84422bb9580709cf1c5f2a14a5cbb0caf1876
---
M ext/testlib/result.py
1 file changed, 33 insertions(+), 10 deletions(-)



diff --git a/ext/testlib/result.py b/ext/testlib/result.py
index 5c60342..786febd 100644
--- a/ext/testlib/result.py
+++ b/ext/testlib/result.py
@@ -191,17 +191,23 @@
 def begin(self, file_):
 file_.write('<')
 file_.write(self.name)
-for attr in self.attributes:
-file_.write(' ')
-attr.write(file_)
+if hasattr(self, 'attributes'):
+for attr in self.attributes:
+file_.write(' ')
+attr.write(file_)
 file_.write('>')

 self.body(file_)

 def body(self, file_):
-for elem in self.elements:
-file_.write('\n')
-elem.write(file_)
+if hasattr(self, 'elements'):
+for elem in self.elements:
+file_.write('\n')
+elem.write(file_)
+if hasattr(self, 'content'):
+file_.write('\n')
+file_.write(
+xml.sax.saxutils.escape(self.content))
 file_.write('\n')

 def end(self, file_):
@@ -286,17 +292,22 @@
 ]

 if str(test_result.result) == 'Failed':
-self.elements.append(JUnitFailure('Test failed', 'ERROR'))
+self.elements.append(JUnitFailure(
+'Test failed',
+str(test_result.result.reason))
+)


 class JUnitFailure(XMLElement):
 name = 'failure'
-def __init__(self, message, fail_type):
+def __init__(self, message, cause):
 self.attributes = [
 XMLAttribute('message', message),
-XMLAttribute('type', fail_type),
 ]
-self.elements = []
+cause_element = XMLElement()
+cause_element.name = 'cause'
+cause_element.content = cause
+self.elements = [cause_element]


 class LargeFileElement(XMLElement):

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/66892?usp=email
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: I18b84422bb9580709cf1c5f2a14a5cbb0caf1876
Gerrit-Change-Number: 66892
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: ext-testlib: Support str-convertible args in gem5_verify_config

2023-01-03 Thread Gabriel B. (Gerrit) via gem5-dev
Gabriel B. has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/66893?usp=email )



Change subject: ext-testlib: Support str-convertible args in  
gem5_verify_config

..

ext-testlib: Support str-convertible args in gem5_verify_config

gem5_verify_config dit not support string-convertible args due to log_call()
not trying to call str() on them. This patch maps str() on the command
paramters.

It is now possible to pass native integers or even string-like types like
pathlib.Path as arguments without manually converting them to string.

Change-Id: Ifa987f5f1a20f17c8710e1a36d99d424e4c9ce6c
---
M ext/testlib/helper.py
1 file changed, 24 insertions(+), 1 deletion(-)



diff --git a/ext/testlib/helper.py b/ext/testlib/helper.py
index ed6e325..ea102f2 100644
--- a/ext/testlib/helper.py
+++ b/ext/testlib/helper.py
@@ -149,7 +149,14 @@
 if isinstance(command, str):
 cmdstr = command
 else:
-cmdstr = ' '.join(command)
+try:
+command = list(map(str, command))
+cmdstr = " ".join(command)
+except TypeError as e:
+logger.trace(
+"Argument  must be an iterable of  
string-convertible types"

+)
+raise e

 logger_callback = logger.trace
 logger.trace('Logging call to command: %s' % cmdstr)

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/66893?usp=email
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: Ifa987f5f1a20f17c8710e1a36d99d424e4c9ce6c
Gerrit-Change-Number: 66893
Gerrit-PatchSet: 1
Gerrit-Owner: Gabriel B. 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org