gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
31 namespace gem5
32 {
33 
35  const PcCountTrackerManagerParams &p)
36  : SimObject(p)
37 {
38  currentPair = PcCountPair(0,0);
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 
55 void
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 
73  targetPair.erase(currentPair);
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 }
gem5::PcCountTrackerManager::targetPair
std::unordered_set< PcCountPair, PcCountPair::HashFunction > targetPair
a set that stores all the PC Count pairs that should raise an exit event at
Definition: pc_count_tracker_manager.hh:63
gem5::PcCountPair::to_string
std::string to_string() const
String format.
Definition: pc_count_pair.hh:77
gem5::PcCountTrackerManager::checkCount
void checkCount(Addr pc)
this function is called when PcCountTrackerProbeListener finds a target PC
Definition: pc_count_tracker_manager.cc:56
gem5::exitSimLoopNow
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
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:67
gem5::PcCountTrackerManager::PcCountTrackerManager
PcCountTrackerManager(const PcCountTrackerManagerParams &params)
Definition: pc_count_tracker_manager.cc:34
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:210
gem5::X86ISA::count
count
Definition: misc.hh:710
gem5::PcCountTrackerManager::counter
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...
Definition: pc_count_tracker_manager.hh:57
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::PcCountTracker
Definition: pc_count_tracker.hh:41
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
pc_count_tracker_manager.hh
gem5::PcCountTrackerManager::printAllTargets
std::string printAllTargets() const
this function print all targets
Definition: pc_count_tracker_manager.hh:109
gem5::MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
gem5::PcCountTrackerManager::currentPair
PcCountPair currentPair
the current PC Count pair
Definition: pc_count_tracker_manager.hh:66
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::PcCountPair
Definition: pc_count_pair.hh:37
gem5::PcCountTrackerManager::ifListNotEmpty
bool ifListNotEmpty
when all the PC Count pairs in the targetPair are encountered, and the PCCOUNTTRACK_END exit event is...
Definition: pc_count_tracker_manager.hh:73

Generated on Sun Jul 30 2023 01:56:53 for gem5 by doxygen 1.8.17