Skip to content

Commit f297720

Browse files
committed
feat: add uniform probe class for signal trace
1 parent 7626663 commit f297720

File tree

8 files changed

+1597
-392
lines changed

8 files changed

+1597
-392
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2024 ARM Limited
3+
* All rights reserved
4+
*/
5+
6+
#include "decode_probe_example.hh"
7+
#include "cpu/bebopino/pipe_data.hh"
8+
9+
namespace gem5
10+
{
11+
12+
namespace bbino
13+
{
14+
15+
DecodeProbe::DecodeProbe(const Decode &decode_, const Pipeline &pipeline_)
16+
: decode(decode_),
17+
pipeline(pipeline_),
18+
collector("decode_probe")
19+
{
20+
setupProbes();
21+
}
22+
23+
void
24+
DecodeProbe::setupProbes()
25+
{
26+
// 读取decode的inputBuffer占用数量(thread 0)
27+
collector.registerSignal(
28+
"decode_input_occupancy",
29+
[this]() {
30+
// 访问decode的public成员inputBuffer,读取其占用数量
31+
size_t occupancy = decode.inputBuffer[0].occupancy();
32+
return SignalValue(static_cast<uint64_t>(occupancy));
33+
},
34+
SignalType::UINT64,
35+
"Number of instructions in decode input buffer"
36+
);
37+
}
38+
39+
} // namespace bbino
40+
} // namespace gem5
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright (c) 2024 ARM Limited
3+
* All rights reserved
4+
*
5+
* The license below extends only to copyright in the software and shall
6+
* not be construed as granting a license to any other intellectual
7+
* property including but not limited to intellectual property relating
8+
* to a hardware implementation of the functionality of the software
9+
* licensed hereunder. You may use the software subject to the license
10+
* terms below provided that you ensure that this notice is replicated
11+
* unmodified and in its entirety in all distributions of the software,
12+
* modified or unmodified, in source code or in binary form.
13+
*
14+
* Redistribution and use in source and binary forms, with or without
15+
* modification, are permitted provided that the following conditions are
16+
* met: redistributions of source code must retain the above copyright
17+
* notice, this list of conditions and the following disclaimer;
18+
* redistributions in binary form must reproduce the above copyright
19+
* notice, this list of conditions and the following disclaimer in the
20+
* documentation and/or other materials provided with the distribution;
21+
* neither the name of the copyright holders nor the names of its
22+
* contributors may be used to endorse or promote products derived from
23+
* this software without specific prior written permission.
24+
*
25+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36+
*/
37+
38+
/**
39+
* @file
40+
*
41+
* Example of using SignalCollector to probe decode stage uop information.
42+
* This demonstrates how to set up read-only signal collection from the
43+
* decode stage without modifying the decode implementation.
44+
*/
45+
46+
#ifndef __CPU_BEBOPINO_PROBE_DECODE_PROBE_EXAMPLE_HH__
47+
#define __CPU_BEBOPINO_PROBE_DECODE_PROBE_EXAMPLE_HH__
48+
49+
#include "signal_collector.hh"
50+
#include "cpu/bebopino/decode.hh"
51+
#include "cpu/bebopino/pipeline.hh"
52+
53+
namespace gem5
54+
{
55+
56+
namespace bbino
57+
{
58+
59+
/**
60+
* DecodeProbe - Example class showing how to use SignalCollector
61+
* to monitor decode stage uop information
62+
*/
63+
class DecodeProbe
64+
{
65+
private:
66+
/** Reference to the decode stage being monitored */
67+
const Decode &decode;
68+
69+
/** Reference to the pipeline */
70+
const Pipeline &pipeline;
71+
72+
/** Signal collector instance */
73+
SignalCollector collector;
74+
75+
public:
76+
/**
77+
* Constructor
78+
* @param decode_ Reference to decode stage
79+
* @param pipeline_ Reference to pipeline
80+
*/
81+
DecodeProbe(const Decode &decode_, const Pipeline &pipeline_);
82+
83+
/**
84+
* Initialize signal probes
85+
* This registers all the signals we want to collect
86+
*/
87+
void setupProbes();
88+
89+
/**
90+
* Collect signals for current cycle
91+
* Call this each cycle to sample all registered signals
92+
*/
93+
void collect() { collector.collect(); }
94+
95+
/**
96+
* Enable/disable collection
97+
*/
98+
void setEnabled(bool enable) { collector.setEnabled(enable); }
99+
100+
/**
101+
* Enable trace file output
102+
*/
103+
bool enableTrace(const std::string &file_path) {
104+
return collector.enableTrace(file_path);
105+
}
106+
107+
/**
108+
* Get the signal collector
109+
*/
110+
SignalCollector& getCollector() { return collector; }
111+
const SignalCollector& getCollector() const { return collector; }
112+
};
113+
114+
} // namespace bbino
115+
} // namespace gem5
116+
117+
#endif // __CPU_BEBOPINO_PROBE_DECODE_PROBE_EXAMPLE_HH__

0 commit comments

Comments
 (0)