gem5 v24.0.0.0
Loading...
Searching...
No Matches
root.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 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 * Copyright (c) 2011 Advanced Micro Devices, Inc.
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
51#ifndef __SIM_ROOT_HH__
52#define __SIM_ROOT_HH__
53
54#include "base/statistics.hh"
55#include "base/time.hh"
56#include "base/types.hh"
57#include "params/Root.hh"
58#include "sim/eventq.hh"
59#include "sim/globals.hh"
60#include "sim/sim_object.hh"
61
62namespace gem5
63{
64
65class Root : public SimObject
66{
67 private:
68 static Root *_root;
69
70 protected:
75
77
79
80 void timeSync();
82
83 public:
92 static Root *
94 {
95 assert(_root);
96 return _root;
97 }
98
99 public: // Global statistics
124
125 public:
126
128 bool timeSyncEnabled() const { return _enabled; }
130 const Time timeSyncPeriod() const { return _period; }
132 const Time timeSyncSpinThreshold() const { return _spinThreshold; }
133
135 void timeSyncEnable(bool en);
137 void timeSyncPeriod(Time newPeriod);
139 void timeSyncSpinThreshold(Time newThreshold);
140
142
143 // The int parameter is ignored, it's just so we can define a custom
144 // create() method.
145 Root(const Params &p, int);
146
149 void startup() override;
150
151 void serialize(CheckpointOut &cp) const override;
152 void unserialize(CheckpointIn &cp) override;
153};
154
160
161} // namespace gem5
162
163#endif // __SIM_ROOT_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Container for serializing global variables (not associated with any serialized object).
Definition globals.hh:55
EventFunctionWrapper syncEvent
Definition root.hh:81
Tick _periodTick
Definition root.hh:73
const Time timeSyncSpinThreshold() const
Retrieve the threshold for time remaining to spin wait.
Definition root.hh:132
Time lastTime
Definition root.hh:76
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition root.cc:205
Globals globals
Definition root.hh:78
bool timeSyncEnabled() const
Check whether time syncing is enabled.
Definition root.hh:128
Time _spinThreshold
Definition root.hh:74
void timeSync()
Definition root.cc:122
PARAMS(Root)
Time _period
Definition root.hh:72
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition root.cc:213
Root(const Params &p, int)
Definition root.cc:178
void timeSyncEnable(bool en)
Enable or disable time syncing.
Definition root.cc:143
const Time timeSyncPeriod() const
Retrieve the period for the sync event.
Definition root.hh:130
static Root * root()
Use this function to get a pointer to the single Root object in the simulation.
Definition root.hh:93
void startup() override
Schedule the timesync event at startup().
Definition root.cc:199
static Root * _root
Definition root.hh:68
bool _enabled
Definition root.hh:71
Abstract superclass for simulation objects.
SimObjectParams Params
A formula for statistics that is calculated when printed.
Statistics container.
Definition group.hh:93
Bitfield< 30 > en
Bitfield< 0 > p
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
Root::RootStats & rootStats
Global simulator statistics that are not associated with a specific SimObject.
Definition root.cc:57
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Tick
Tick count type.
Definition types.hh:58
Declaration of Statistics objects.
statistics::Value hostSeconds
Definition root.hh:108
statistics::Formula simSeconds
Definition root.hh:104
RootStats(const RootStats &)=delete
statistics::Value finalTick
Definition root.hh:106
void resetStats() override
Callback to reset stats.
Definition root.cc:107
statistics::Value simTicks
Definition root.hh:105
statistics::Formula hostTickRate
Definition root.hh:110
statistics::Value simFreq
Definition root.hh:107
RootStats & operator=(const RootStats &)=delete
static RootStats instance
Definition root.hh:113
statistics::Value hostMemory
Definition root.hh:111

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