Ciro Santilli has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/37978 )
Change subject: configs: hack PMU in fs.py
......................................................................
configs: hack PMU in fs.py
Change-Id: I13b705183eb7c2e810594e9092325f0f2fee9485
---
M configs/example/fs.py
A src/arch/arm/PmuListener.py
M src/arch/arm/SConscript
A src/arch/arm/pmu_listener.cc
A src/arch/arm/pmu_listener.hh
5 files changed, 194 insertions(+), 0 deletions(-)
diff --git a/configs/example/fs.py b/configs/example/fs.py
index 229c50e..c0c50cf 100644
--- a/configs/example/fs.py
+++ b/configs/example/fs.py
@@ -233,6 +233,27 @@
MemConfig.config_mem(options, test_sys)
+ pmu_listeners = []
+ for cpu in test_sys.cpu:
+ if buildEnv['TARGET_ISA'] in "arm":
+ for isa in cpu.isa:
+ isa.pmu = ArmPMU(interrupt=ArmPPI(num=20))
+ isa.pmu.addArchEvents(
+ cpu=cpu, dtb=cpu.mmu.dtb, itb=cpu.mmu.itb,
+ icache=getattr(cpu, "icache", None),
+ dcache=getattr(cpu, "dcache", None),
+ l2cache=getattr(test_sys, "l2", None))
+ pmu_listeners.append(PmuListener(
+ cpu=cpu,
+ dtb=cpu.mmu.dtb,
+ itb=cpu.mmu.itb,
+ icache=getattr(cpu, "icache", None),
+ dcache=getattr(cpu, "dcache", None),
+ l2cache=getattr(test_sys, "l2", None),
+ bpred=getattr(cpu, "branchPred", None),
+ ))
+ test_sys.pmu_listeners = pmu_listeners
+
return test_sys
def build_drive_system(np):
diff --git a/src/arch/arm/PmuListener.py b/src/arch/arm/PmuListener.py
new file mode 100644
index 0000000..31c95fc
--- /dev/null
+++ b/src/arch/arm/PmuListener.py
@@ -0,0 +1,48 @@
+# Copyright (c) 2020 ARM Limited
+# All rights reserved.
+#
+# 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
+
+from m5.SimObject import *
+from m5.params import *
+
+class PmuListener(SimObject):
+ type = 'PmuListener'
+ cxx_class = 'ArmISA::PmuListener'
+ cxx_header = 'arch/arm/pmu_listener.hh'
+ cpu = Param.SimObject(NULL)
+ dtb = Param.SimObject(NULL)
+ itb = Param.SimObject(NULL)
+ icache = Param.SimObject(NULL)
+ dcache = Param.SimObject(NULL)
+ l2cache = Param.SimObject(NULL)
+ bpred = Param.SimObject(NULL)
diff --git a/src/arch/arm/SConscript b/src/arch/arm/SConscript
index 31e83a7..6cf250f 100644
--- a/src/arch/arm/SConscript
+++ b/src/arch/arm/SConscript
@@ -88,6 +88,7 @@
Source('pmu.cc')
Source('process.cc')
Source('qarma.cc')
+ Source('pmu_listener.cc')
Source('remote_gdb.cc')
Source('semihosting.cc')
Source('system.cc')
@@ -110,6 +111,7 @@
SimObject('ArmSystem.py')
SimObject('ArmTLB.py')
SimObject('ArmPMU.py')
+ SimObject('PmuListener.py')
DebugFlag('Arm')
DebugFlag('ArmTme', 'Transactional Memory Extension')
diff --git a/src/arch/arm/pmu_listener.cc b/src/arch/arm/pmu_listener.cc
new file mode 100644
index 0000000..05a1b43
--- /dev/null
+++ b/src/arch/arm/pmu_listener.cc
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2020 ARM Limited
+ * All rights reserved
+ *
+ * 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
+ */
+
+#include "arch/arm/pmu_listener.hh"
+
+#include <iostream>
+
+#include "params/PmuListener.hh"
+
+namespace ArmISA {
+PmuListener::PmuListener(const PmuListenerParams &p) : SimObject(p), p(p)
{};
+
+PmuListener::~PmuListener() {};
+
+void
+PmuListener::regProbeListeners()
+{
+ probeFunctions.emplace_back(new ProbeFunction<uint64_t>(
+ p.cpu, "ActiveCycles",
+ [](uint64_t arg){ std::cout << "ActiveCycles " << arg <<
std::endl; }
+ ));
+ if (p.bpred) {
+ probeFunctions.emplace_back(new ProbeFunction<uint64_t>(
+ p.bpred, "Misses",
+ [](uint64_t arg){ std::cout << "Misses " << arg << std::endl; }
+ ));
+ }
+};
+}
diff --git a/src/arch/arm/pmu_listener.hh b/src/arch/arm/pmu_listener.hh
new file mode 100644
index 0000000..032525b
--- /dev/null
+++ b/src/arch/arm/pmu_listener.hh
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2020 ARM Limited
+ * All rights reserved
+ *
+ * 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
+ */
+
+#include <functional>
+#include <memory>
+#include <vector>
+
+#include "sim/probe/probe.hh"
+
+class PmuListenerParams;
+
+template<class Arg>
+struct ProbeFunction : public ProbeListenerArgBase<Arg>
+{
+ std::function<void(Arg)> callback;
+ ProbeFunction(SimObject *obj, const std::string &name,
+ const std::function<void(Arg)> callback)
+ : ProbeListenerArgBase<Arg>(obj->getProbeManager(), name),
+ callback(callback) {}
+ void notify(const Arg &val) override { callback(val); }
+};
+
+namespace ArmISA {
+ class PmuListener : public SimObject {
+ std::vector<std::unique_ptr<ProbeFunction<uint64_t>>>
probeFunctions;
+ const PmuListenerParams &p;
+ public:
+ PmuListener(const PmuListenerParams &p);
+ ~PmuListener();
+ void regProbeListeners() override;
+ };
+}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/37978
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: I13b705183eb7c2e810594e9092325f0f2fee9485
Gerrit-Change-Number: 37978
Gerrit-PatchSet: 1
Gerrit-Owner: Ciro Santilli <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s