gem5  v21.1.0.2
base.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013, 2016-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  * 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 #ifndef __CPU_TRAFFIC_GEN_BASE_HH__
39 #define __CPU_TRAFFIC_GEN_BASE_HH__
40 
41 #include <memory>
42 #include <tuple>
43 #include <unordered_map>
44 
45 #include "base/statistics.hh"
46 #include "enums/AddrMap.hh"
47 #include "mem/qport.hh"
48 #include "sim/clocked_object.hh"
49 
50 namespace gem5
51 {
52 
53 class BaseGen;
54 class StreamGen;
55 class System;
56 struct BaseTrafficGenParams;
57 
68 {
69  friend class BaseGen;
70 
71  protected: // Params
76  System *const system;
77 
82  const bool elasticReq;
83 
89 
90  private:
95  void recvReqRetry();
96 
97  void retryReq();
98 
99  bool recvTimingResp(PacketPtr pkt);
100 
102  void transition();
103 
108  void scheduleUpdate();
109 
113  void noProgress();
114 
119 
122 
125 
127 
128 
131  {
132  public:
133 
134  TrafficGenPort(const std::string& name, BaseTrafficGen& traffic_gen)
135  : RequestPort(name, &traffic_gen), trafficGen(traffic_gen)
136  { }
137 
138  protected:
139 
141 
143  { return trafficGen.recvTimingResp(pkt); }
144 
146 
148 
149  Tick recvAtomicSnoop(PacketPtr pkt) { return 0; }
150 
151  private:
152 
154 
155  };
156 
161  void update();
162 
165 
168 
171 
174 
180  {
181  assert(waitingResp.find(pkt->req) == waitingResp.end());
182  assert(pkt->needsResponse());
183 
184  waitingResp[pkt->req] = curTick();
185 
186  return (maxOutstandingReqs > 0) &&
187  (waitingResp.size() > maxOutstandingReqs);
188  }
189 
192 
193  protected: // Stats
195  std::unordered_map<RequestPtr,Tick> waitingResp;
196 
197  struct StatGroup : public statistics::Group
198  {
199  StatGroup(statistics::Group *parent);
200 
203 
206 
209 
212 
215 
218 
221 
224 
227 
230 
233 
236 
239 
242  } stats;
243 
244  public:
245  BaseTrafficGen(const BaseTrafficGenParams &p);
246 
247  ~BaseTrafficGen();
248 
249  Port &getPort(const std::string &if_name,
250  PortID idx=InvalidPortID) override;
251 
252  void init() override;
253 
254  DrainState drain() override;
255 
256  void serialize(CheckpointOut &cp) const override;
257  void unserialize(CheckpointIn &cp) override;
258 
259  public: // Generator factory methods
260  std::shared_ptr<BaseGen> createIdle(Tick duration);
261  std::shared_ptr<BaseGen> createExit(Tick duration);
262 
263  std::shared_ptr<BaseGen> createLinear(
264  Tick duration,
265  Addr start_addr, Addr end_addr, Addr blocksize,
266  Tick min_period, Tick max_period,
267  uint8_t read_percent, Addr data_limit);
268 
269  std::shared_ptr<BaseGen> createRandom(
270  Tick duration,
271  Addr start_addr, Addr end_addr, Addr blocksize,
272  Tick min_period, Tick max_period,
273  uint8_t read_percent, Addr data_limit);
274 
275  std::shared_ptr<BaseGen> createDram(
276  Tick duration,
277  Addr start_addr, Addr end_addr, Addr blocksize,
278  Tick min_period, Tick max_period,
279  uint8_t read_percent, Addr data_limit,
280  unsigned int num_seq_pkts, unsigned int page_size,
281  unsigned int nbr_of_banks, unsigned int nbr_of_banks_util,
282  enums::AddrMap addr_mapping,
283  unsigned int nbr_of_ranks);
284 
285  std::shared_ptr<BaseGen> createDramRot(
286  Tick duration,
287  Addr start_addr, Addr end_addr, Addr blocksize,
288  Tick min_period, Tick max_period,
289  uint8_t read_percent, Addr data_limit,
290  unsigned int num_seq_pkts, unsigned int page_size,
291  unsigned int nbr_of_banks, unsigned int nbr_of_banks_util,
292  enums::AddrMap addr_mapping,
293  unsigned int nbr_of_ranks,
294  unsigned int max_seq_count_per_rank);
295 
296  std::shared_ptr<BaseGen> createHybrid(
297  Tick duration,
298  Addr start_addr_dram, Addr end_addr_dram, Addr blocksize_dram,
299  Addr start_addr_nvm, Addr end_addr_nvm, Addr blocksize_nvm,
300  Tick min_period, Tick max_period,
301  uint8_t read_percent, Addr data_limit,
302  unsigned int num_seq_pkts_dram, unsigned int page_size_dram,
303  unsigned int nbr_of_banks_dram, unsigned int nbr_of_banks_util_dram,
304  unsigned int num_seq_pkts_nvm, unsigned int buffer_size_nvm,
305  unsigned int nbr_of_banks_nvm, unsigned int nbr_of_banks_util_nvm,
306  enums::AddrMap addr_mapping,
307  unsigned int nbr_of_ranks_dram,
308  unsigned int nbr_of_ranks_nvm,
309  uint8_t nvm_percent);
310 
311  std::shared_ptr<BaseGen> createNvm(
312  Tick duration,
313  Addr start_addr, Addr end_addr, Addr blocksize,
314  Tick min_period, Tick max_period,
315  uint8_t read_percent, Addr data_limit,
316  unsigned int num_seq_pkts, unsigned int buffer_size,
317  unsigned int nbr_of_banks, unsigned int nbr_of_banks_util,
318  enums::AddrMap addr_mapping,
319  unsigned int nbr_of_ranks);
320 
321  std::shared_ptr<BaseGen> createStrided(
322  Tick duration,
323  Addr start_addr, Addr end_addr, Addr blocksize,
324  Addr stride_size, int gen_id,
325  Tick min_period, Tick max_period,
326  uint8_t read_percent, Addr data_limit);
327 
328  std::shared_ptr<BaseGen> createTrace(
329  Tick duration,
330  const std::string& trace_file, Addr addr_offset);
331 
332  protected:
333  void start();
334 
335  virtual std::shared_ptr<BaseGen> nextGenerator() = 0;
336 
341 
343  std::shared_ptr<BaseGen> activeGenerator;
344 
346  std::unique_ptr<StreamGen> streamGenerator;
347 };
348 
349 } // namespace gem5
350 
351 #endif //__CPU_TRAFFIC_GEN_BASE_HH__
gem5::statistics::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1927
gem5::BaseTrafficGen::createLinear
std::shared_ptr< BaseGen > createLinear(Tick duration, Addr start_addr, Addr end_addr, Addr blocksize, Tick min_period, Tick max_period, uint8_t read_percent, Addr data_limit)
Definition: base.cc:384
gem5::curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:252
gem5::Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:111
gem5::BaseTrafficGen::TrafficGenPort::recvTimingResp
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: base.hh:142
gem5::BaseTrafficGen::StatGroup::retryTicks
statistics::Scalar retryTicks
Count the time incurred from back-pressure.
Definition: base.hh:211
gem5::BaseTrafficGen::StatGroup::totalWriteLatency
statistics::Scalar totalWriteLatency
Total num of ticks write reqs took to complete
Definition: base.hh:223
gem5::Packet::req
RequestPtr req
A pointer to the original request.
Definition: packet.hh:366
gem5::BaseTrafficGen::retryPkt
PacketPtr retryPkt
Packet waiting to be sent.
Definition: base.hh:167
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::BaseTrafficGen::StatGroup::bytesRead
statistics::Scalar bytesRead
Count the number of bytes read.
Definition: base.hh:214
gem5::BaseTrafficGen::createIdle
std::shared_ptr< BaseGen > createIdle(Tick duration)
Definition: base.cc:370
gem5::BaseTrafficGen::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: base.cc:152
gem5::BaseTrafficGen::noProgressEvent
EventFunctionWrapper noProgressEvent
Event to keep track of our progress, or lack thereof.
Definition: base.hh:118
gem5::statistics::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2536
gem5::BaseTrafficGen::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: base.cc:104
gem5::BaseTrafficGen::blockedWaitingResp
bool blockedWaitingResp
Set when we blocked waiting for outstanding reqs.
Definition: base.hh:173
gem5::InvalidPortID
const PortID InvalidPortID
Definition: types.hh:253
gem5::BaseTrafficGen::drain
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
Definition: base.cc:113
gem5::BaseTrafficGen::StatGroup::totalWrites
statistics::Scalar totalWrites
Count the number writes.
Definition: base.hh:229
gem5::BaseTrafficGen::createHybrid
std::shared_ptr< BaseGen > createHybrid(Tick duration, Addr start_addr_dram, Addr end_addr_dram, Addr blocksize_dram, Addr start_addr_nvm, Addr end_addr_nvm, Addr blocksize_nvm, Tick min_period, Tick max_period, uint8_t read_percent, Addr data_limit, unsigned int num_seq_pkts_dram, unsigned int page_size_dram, unsigned int nbr_of_banks_dram, unsigned int nbr_of_banks_util_dram, unsigned int num_seq_pkts_nvm, unsigned int buffer_size_nvm, unsigned int nbr_of_banks_nvm, unsigned int nbr_of_banks_util_nvm, enums::AddrMap addr_mapping, unsigned int nbr_of_ranks_dram, unsigned int nbr_of_ranks_nvm, uint8_t nvm_percent)
Definition: base.cc:463
gem5::BaseTrafficGen::recvReqRetry
void recvReqRetry()
Receive a retry from the neighbouring port and attempt to resend the waiting packet.
Definition: base.cc:289
gem5::RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:77
gem5::BaseTrafficGen::StatGroup::numSuppressed
statistics::Scalar numSuppressed
Count the number of dropped requests.
Definition: base.hh:202
gem5::BaseTrafficGen::StatGroup
Definition: base.hh:197
gem5::BaseTrafficGen::StatGroup::numPackets
statistics::Scalar numPackets
Count the number of generated packets.
Definition: base.hh:205
gem5::BaseTrafficGen::stats
gem5::BaseTrafficGen::StatGroup stats
gem5::DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:74
gem5::BaseTrafficGen::StatGroup::totalReadLatency
statistics::Scalar totalReadLatency
Total num of ticks read reqs took to complete
Definition: base.hh:220
gem5::BaseTrafficGen::BaseTrafficGen
BaseTrafficGen(const BaseTrafficGenParams &p)
Definition: base.cc:70
gem5::System
Definition: system.hh:77
gem5::BaseTrafficGen::noProgress
void noProgress()
Method to inform the user we have made no progress.
Definition: base.cc:329
gem5::BaseTrafficGen::~BaseTrafficGen
~BaseTrafficGen()
Definition: base.cc:89
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::BaseTrafficGen::createDram
std::shared_ptr< BaseGen > createDram(Tick duration, Addr start_addr, Addr end_addr, Addr blocksize, Tick min_period, Tick max_period, uint8_t read_percent, Addr data_limit, unsigned int num_seq_pkts, unsigned int page_size, unsigned int nbr_of_banks, unsigned int nbr_of_banks_util, enums::AddrMap addr_mapping, unsigned int nbr_of_ranks)
Definition: base.cc:412
gem5::BaseTrafficGen::createNvm
std::shared_ptr< BaseGen > createNvm(Tick duration, Addr start_addr, Addr end_addr, Addr blocksize, Tick min_period, Tick max_period, uint8_t read_percent, Addr data_limit, unsigned int num_seq_pkts, unsigned int buffer_size, unsigned int nbr_of_banks, unsigned int nbr_of_banks_util, enums::AddrMap addr_mapping, unsigned int nbr_of_ranks)
Definition: base.cc:506
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
statistics.hh
gem5::BaseTrafficGen::createTrace
std::shared_ptr< BaseGen > createTrace(Tick duration, const std::string &trace_file, Addr addr_offset)
Definition: base.cc:546
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::BaseTrafficGen::requestorId
const RequestorID requestorId
RequestorID used in generated requests.
Definition: base.hh:340
gem5::BaseTrafficGen::StatGroup::writeBW
statistics::Formula writeBW
Write bandwidth in bytes/s
Definition: base.hh:241
gem5::BaseTrafficGen::start
void start()
Definition: base.cc:282
gem5::BaseTrafficGen::StatGroup::bytesWritten
statistics::Scalar bytesWritten
Count the number of bytes written.
Definition: base.hh:217
gem5::BaseTrafficGen
The traffic generator is a module that generates stimuli for the memory system, based on a collection...
Definition: base.hh:67
gem5::BaseTrafficGen::TrafficGenPort::recvFunctionalSnoop
void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the peer.
Definition: base.hh:147
gem5::BaseTrafficGen::transition
void transition()
Transition to the next generator.
Definition: base.cc:230
gem5::BaseTrafficGen::TrafficGenPort::recvAtomicSnoop
Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from our peer.
Definition: base.hh:149
gem5::BaseTrafficGen::retryPktTick
Tick retryPktTick
Tick when the stalled packet was meant to be sent.
Definition: base.hh:170
gem5::BaseTrafficGen::retryReq
void retryReq()
Definition: base.cc:297
gem5::BaseTrafficGen::nextTransitionTick
Tick nextTransitionTick
Time of next transition.
Definition: base.hh:121
gem5::BaseTrafficGen::StatGroup::avgWriteLatency
statistics::Formula avgWriteLatency
Avg num of ticks each write reqs took to complete
Definition: base.hh:235
gem5::BaseTrafficGen::system
System *const system
The system used to determine which mode we are currently operating in.
Definition: base.hh:76
gem5::BaseTrafficGen::scheduleUpdate
void scheduleUpdate()
Schedule the update event based on nextPacketTick and nextTransitionTick.
Definition: base.cc:258
gem5::Packet::needsResponse
bool needsResponse() const
Definition: packet.hh:597
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::BaseTrafficGen::StatGroup::StatGroup
StatGroup(statistics::Group *parent)
Definition: base.cc:335
gem5::BaseTrafficGen::StatGroup::totalReads
statistics::Scalar totalReads
Count the number reads.
Definition: base.hh:226
gem5::BaseTrafficGen::createStrided
std::shared_ptr< BaseGen > createStrided(Tick duration, Addr start_addr, Addr end_addr, Addr blocksize, Addr stride_size, int gen_id, Tick min_period, Tick max_period, uint8_t read_percent, Addr data_limit)
Definition: base.cc:530
gem5::BaseGen
Base class for all generators, with the shared functionality and virtual functions for entering,...
Definition: base_gen.hh:64
gem5::ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:234
gem5::BaseTrafficGen::progressCheck
const Tick progressCheck
Time to tolerate waiting for retries (not making progress), until we declare things broken.
Definition: base.hh:88
gem5::BaseTrafficGen::TrafficGenPort::recvTimingSnoopReq
void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the peer.
Definition: base.hh:145
gem5::EventFunctionWrapper
Definition: eventq.hh:1115
gem5::BaseTrafficGen::TrafficGenPort::recvReqRetry
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: base.hh:140
gem5::BaseTrafficGen::TrafficGenPort::TrafficGenPort
TrafficGenPort(const std::string &name, BaseTrafficGen &traffic_gen)
Definition: base.hh:134
gem5::BaseTrafficGen::createDramRot
std::shared_ptr< BaseGen > createDramRot(Tick duration, Addr start_addr, Addr end_addr, Addr blocksize, Tick min_period, Tick max_period, uint8_t read_percent, Addr data_limit, unsigned int num_seq_pkts, unsigned int page_size, unsigned int nbr_of_banks, unsigned int nbr_of_banks_util, enums::AddrMap addr_mapping, unsigned int nbr_of_ranks, unsigned int max_seq_count_per_rank)
Definition: base.cc:436
gem5::BaseTrafficGen::update
void update()
Schedules event for next update and generates a new packet or requests a new generatoir depending on ...
Definition: base.cc:169
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
gem5::BaseTrafficGen::elasticReq
const bool elasticReq
Determine whether to add elasticity in the request injection, thus responding to backpressure by slow...
Definition: base.hh:82
qport.hh
gem5::BaseTrafficGen::StatGroup::numRetries
statistics::Scalar numRetries
Count the number of retries.
Definition: base.hh:208
gem5::BaseTrafficGen::activeGenerator
std::shared_ptr< BaseGen > activeGenerator
Currently active generator.
Definition: base.hh:343
gem5::BaseTrafficGen::updateEvent
EventFunctionWrapper updateEvent
Event for scheduling updates.
Definition: base.hh:191
clocked_object.hh
gem5::BaseTrafficGen::nextGenerator
virtual std::shared_ptr< BaseGen > nextGenerator()=0
gem5::BaseTrafficGen::maxOutstandingReqs
const int maxOutstandingReqs
Definition: base.hh:126
gem5::BaseTrafficGen::nextPacketTick
Tick nextPacketTick
Time of the next packet.
Definition: base.hh:124
gem5::BaseTrafficGen::streamGenerator
std::unique_ptr< StreamGen > streamGenerator
Stream/SubstreamID Generator.
Definition: base.hh:346
gem5::BaseTrafficGen::TrafficGenPort
Request port specialisation for the traffic generator.
Definition: base.hh:130
gem5::statistics::Group
Statistics container.
Definition: group.hh:93
gem5::BaseTrafficGen::StatGroup::avgReadLatency
statistics::Formula avgReadLatency
Avg num of ticks each read req took to complete
Definition: base.hh:232
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::BaseTrafficGen::recvTimingResp
bool recvTimingResp(PacketPtr pkt)
Definition: base.cc:558
gem5::RequestorID
uint16_t RequestorID
Definition: request.hh:95
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::BaseTrafficGen::createRandom
std::shared_ptr< BaseGen > createRandom(Tick duration, Addr start_addr, Addr end_addr, Addr blocksize, Tick min_period, Tick max_period, uint8_t read_percent, Addr data_limit)
Definition: base.cc:398
gem5::BaseTrafficGen::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: base.cc:132
gem5::BaseTrafficGen::getPort
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: base.cc:94
gem5::BaseTrafficGen::TrafficGenPort::trafficGen
BaseTrafficGen & trafficGen
Definition: base.hh:153
gem5::BaseTrafficGen::port
TrafficGenPort port
The instance of request port used by the traffic generator.
Definition: base.hh:164
gem5::BaseTrafficGen::StatGroup::readBW
statistics::Formula readBW
Read bandwidth in bytes/s
Definition: base.hh:238
gem5::BaseTrafficGen::waitingResp
std::unordered_map< RequestPtr, Tick > waitingResp
Reqs waiting for response.
Definition: base.hh:195
gem5::BaseTrafficGen::allocateWaitingRespSlot
bool allocateWaitingRespSlot(PacketPtr pkt)
Puts this packet in the waitingResp list and returns true if we are above the maximum number of ousta...
Definition: base.hh:179
gem5::BaseTrafficGen::createExit
std::shared_ptr< BaseGen > createExit(Tick duration)
Definition: base.cc:377

Generated on Tue Sep 21 2021 12:24:57 for gem5 by doxygen 1.8.17