gem5 v24.0.0.0
Loading...
Searching...
No Matches
pc_count_tracker_manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
30
31namespace gem5
32{
33
35 const PcCountTrackerManagerParams &p)
36 : SimObject(p)
37{
39 ifListNotEmpty = true;
40
41 for (int i = 0 ; i < p.targets.size() ; i++) {
42 // initialize the counter for the inputted PC Count pair
43 // unordered_map does not allow duplicate, so counter won't
44 // have duplicates
45 counter.insert(std::make_pair(p.targets[i].getPC(),0));
46 // store all the PC Count pair into the targetPair set
47 targetPair.insert(p.targets[i]);
48 }
50 "total %i PCs in counter\n", counter.size());
52 "all targets: \n%s", printAllTargets());
53}
54
55void
57{
58
59 if(ifListNotEmpty) {
60 int count = ++counter.find(pc)->second;
61 // increment the counter of the encountered PC address by 1
62
64 // update the current PC Count pair
65 if(targetPair.find(currentPair) != targetPair.end()) {
66 // if the current PC Count pair is one of the target pairs
68 "pc:%s encountered\n", currentPair.to_string());
69
70 exitSimLoopNow("simpoint starting point found");
71 // raise the SIMPOINT_BEGIN exit event
72
74 // erase the encountered PC Count pair from the target pairs
76 "There are %i targets remained\n", targetPair.size());
77 }
78
79 if(targetPair.empty()) {
80 // if all target PC Count pairs are encountered
82 "all targets are encountered.\n");
83 ifListNotEmpty = false;
84 }
85 }
86}
87
88}
#define DPRINTF(x,...)
Definition trace.hh:210
std::string to_string() const
String format.
bool ifListNotEmpty
when all the PC Count pairs in the targetPair are encountered, and the PCCOUNTTRACK_END exit event is...
std::unordered_map< Addr, int > counter
a counter that stores all the target PC addresses and the number of times the target PC has been exec...
PcCountTrackerManager(const PcCountTrackerManagerParams &params)
std::unordered_set< PcCountPair, PcCountPair::HashFunction > targetPair
a set that stores all the PC Count pairs that should raise an exit event at
PcCountPair currentPair
the current PC Count pair
std::string printAllTargets() const
this function print all targets
void checkCount(Addr pc)
this function is called when PcCountTrackerProbeListener finds a target PC
Abstract superclass for simulation objects.
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 4 > pc
Bitfield< 0 > p
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
void exitSimLoopNow(const std::string &message, int exit_code, Tick repeat, bool serialize)
Schedule an event as above, but make it high priority so it runs before any normal events which are s...
Definition sim_events.cc:99

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0