gem5  v20.1.0.0
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 class BaseGen;
51 class StreamGen;
52 class System;
53 struct BaseTrafficGenParams;
54 
65 {
66  friend class BaseGen;
67 
68  protected: // Params
73  System *const system;
74 
79  const bool elasticReq;
80 
86 
87  private:
92  void recvReqRetry();
93 
94  void retryReq();
95 
96  bool recvTimingResp(PacketPtr pkt);
97 
99  void transition();
100 
105  void scheduleUpdate();
106 
110  void noProgress();
111 
116 
119 
122 
124 
125 
128  {
129  public:
130 
131  TrafficGenPort(const std::string& name, BaseTrafficGen& traffic_gen)
132  : RequestPort(name, &traffic_gen), trafficGen(traffic_gen)
133  { }
134 
135  protected:
136 
138 
140  { return trafficGen.recvTimingResp(pkt); }
141 
143 
145 
146  Tick recvAtomicSnoop(PacketPtr pkt) { return 0; }
147 
148  private:
149 
151 
152  };
153 
158  void update();
159 
162 
165 
168 
171 
177  {
178  assert(waitingResp.find(pkt->req) == waitingResp.end());
179  assert(pkt->needsResponse());
180 
181  waitingResp[pkt->req] = curTick();
182 
183  return (maxOutstandingReqs > 0) &&
184  (waitingResp.size() > maxOutstandingReqs);
185  }
186 
189 
190  protected: // Stats
192  std::unordered_map<RequestPtr,Tick> waitingResp;
193 
194  struct StatGroup : public Stats::Group {
195  StatGroup(Stats::Group *parent);
196 
199 
202 
205 
208 
211 
214 
217 
220 
223 
226 
229 
232 
235 
238  } stats;
239 
240  public:
241  BaseTrafficGen(const BaseTrafficGenParams* p);
242 
243  ~BaseTrafficGen();
244 
245  Port &getPort(const std::string &if_name,
246  PortID idx=InvalidPortID) override;
247 
248  void init() override;
249 
250  DrainState drain() override;
251 
252  void serialize(CheckpointOut &cp) const override;
253  void unserialize(CheckpointIn &cp) override;
254 
255  public: // Generator factory methods
256  std::shared_ptr<BaseGen> createIdle(Tick duration);
257  std::shared_ptr<BaseGen> createExit(Tick duration);
258 
259  std::shared_ptr<BaseGen> createLinear(
260  Tick duration,
261  Addr start_addr, Addr end_addr, Addr blocksize,
262  Tick min_period, Tick max_period,
263  uint8_t read_percent, Addr data_limit);
264 
265  std::shared_ptr<BaseGen> createRandom(
266  Tick duration,
267  Addr start_addr, Addr end_addr, Addr blocksize,
268  Tick min_period, Tick max_period,
269  uint8_t read_percent, Addr data_limit);
270 
271  std::shared_ptr<BaseGen> createDram(
272  Tick duration,
273  Addr start_addr, Addr end_addr, Addr blocksize,
274  Tick min_period, Tick max_period,
275  uint8_t read_percent, Addr data_limit,
276  unsigned int num_seq_pkts, unsigned int page_size,
277  unsigned int nbr_of_banks, unsigned int nbr_of_banks_util,
278  Enums::AddrMap addr_mapping,
279  unsigned int nbr_of_ranks);
280 
281  std::shared_ptr<BaseGen> createDramRot(
282  Tick duration,
283  Addr start_addr, Addr end_addr, Addr blocksize,
284  Tick min_period, Tick max_period,
285  uint8_t read_percent, Addr data_limit,
286  unsigned int num_seq_pkts, unsigned int page_size,
287  unsigned int nbr_of_banks, unsigned int nbr_of_banks_util,
288  Enums::AddrMap addr_mapping,
289  unsigned int nbr_of_ranks,
290  unsigned int max_seq_count_per_rank);
291 
292  std::shared_ptr<BaseGen> createHybrid(
293  Tick duration,
294  Addr start_addr_dram, Addr end_addr_dram, Addr blocksize_dram,
295  Addr start_addr_nvm, Addr end_addr_nvm, Addr blocksize_nvm,
296  Tick min_period, Tick max_period,
297  uint8_t read_percent, Addr data_limit,
298  unsigned int num_seq_pkts_dram, unsigned int page_size_dram,
299  unsigned int nbr_of_banks_dram, unsigned int nbr_of_banks_util_dram,
300  unsigned int num_seq_pkts_nvm, unsigned int buffer_size_nvm,
301  unsigned int nbr_of_banks_nvm, unsigned int nbr_of_banks_util_nvm,
302  Enums::AddrMap addr_mapping,
303  unsigned int nbr_of_ranks_dram,
304  unsigned int nbr_of_ranks_nvm,
305  uint8_t nvm_percent);
306 
307  std::shared_ptr<BaseGen> createNvm(
308  Tick duration,
309  Addr start_addr, Addr end_addr, Addr blocksize,
310  Tick min_period, Tick max_period,
311  uint8_t read_percent, Addr data_limit,
312  unsigned int num_seq_pkts, unsigned int buffer_size,
313  unsigned int nbr_of_banks, unsigned int nbr_of_banks_util,
314  Enums::AddrMap addr_mapping,
315  unsigned int nbr_of_ranks);
316 
317  std::shared_ptr<BaseGen> createTrace(
318  Tick duration,
319  const std::string& trace_file, Addr addr_offset);
320 
321  protected:
322  void start();
323 
324  virtual std::shared_ptr<BaseGen> nextGenerator() = 0;
325 
330 
332  std::shared_ptr<BaseGen> activeGenerator;
333 
335  std::unique_ptr<StreamGen> streamGenerator;
336 };
337 
338 #endif //__CPU_TRAFFIC_GEN_BASE_HH__
BaseTrafficGen::StatGroup::totalReadLatency
Stats::Scalar totalReadLatency
Total num of ticks read reqs took to complete
Definition: base.hh:216
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:425
BaseGen
Base class for all generators, with the shared functionality and virtual functions for entering,...
Definition: base_gen.hh:57
BaseTrafficGen::retryReq
void retryReq()
Definition: base.cc:296
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
BaseTrafficGen::port
TrafficGenPort port
The instance of request port used by the traffic generator.
Definition: base.hh:161
BaseTrafficGen::recvReqRetry
void recvReqRetry()
Receive a retry from the neighbouring port and attempt to resend the waiting packet.
Definition: base.cc:288
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:387
BaseTrafficGen::StatGroup::avgReadLatency
Stats::Formula avgReadLatency
Avg num of ticks each read req took to complete
Definition: base.hh:228
BaseTrafficGen::activeGenerator
std::shared_ptr< BaseGen > activeGenerator
Currently active generator.
Definition: base.hh:332
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:93
BaseTrafficGen::transition
void transition()
Transition to the next generator.
Definition: base.cc:229
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:176
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
BaseTrafficGen::TrafficGenPort
Request port specialisation for the traffic generator.
Definition: base.hh:127
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
BaseTrafficGen::TrafficGenPort::recvTimingResp
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: base.hh:139
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:137
Packet::req
RequestPtr req
A pointer to the original request.
Definition: packet.hh:340
BaseTrafficGen::StatGroup::readBW
Stats::Formula readBW
Read bandwidth in bytes/s
Definition: base.hh:234
BaseTrafficGen::progressCheck
const Tick progressCheck
Time to tolerate waiting for retries (not making progress), until we declare things broken.
Definition: base.hh:85
BaseTrafficGen::noProgressEvent
EventFunctionWrapper noProgressEvent
Event to keep track of our progress, or lack thereof.
Definition: base.hh:115
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:401
ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:231
BaseTrafficGen::StatGroup::totalWrites
Stats::Scalar totalWrites
Count the number writes.
Definition: base.hh:225
EventFunctionWrapper
Definition: eventq.hh:1101
BaseTrafficGen::StatGroup::bytesRead
Stats::Scalar bytesRead
Count the number of bytes read.
Definition: base.hh:210
BaseTrafficGen::noProgress
void noProgress()
Method to inform the user we have made no progress.
Definition: base.cc:328
DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:71
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
RequestorID
uint16_t RequestorID
Definition: request.hh:85
BaseTrafficGen::BaseTrafficGen
BaseTrafficGen(const BaseTrafficGenParams *p)
Definition: base.cc:69
cp
Definition: cprintf.cc:40
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:452
BaseTrafficGen::nextTransitionTick
Tick nextTransitionTick
Time of next transition.
Definition: base.hh:118
BaseTrafficGen
The traffic generator is a module that generates stimuli for the memory system, based on a collection...
Definition: base.hh:64
BaseTrafficGen::StatGroup::avgWriteLatency
Stats::Formula avgWriteLatency
Avg num of ticks each write reqs took to complete
Definition: base.hh:231
BaseTrafficGen::retryPkt
PacketPtr retryPkt
Packet waiting to be sent.
Definition: base.hh:164
System
Definition: system.hh:73
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:373
statistics.hh
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:112
Port
Ports are used to interface objects to each other.
Definition: port.hh:56
Packet::needsResponse
bool needsResponse() const
Definition: packet.hh:570
BaseTrafficGen::StatGroup::numRetries
Stats::Scalar numRetries
Count the number of retries.
Definition: base.hh:204
BaseTrafficGen::nextGenerator
virtual std::shared_ptr< BaseGen > nextGenerator()=0
BaseTrafficGen::init
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: base.cc:103
BaseTrafficGen::createTrace
std::shared_ptr< BaseGen > createTrace(Tick duration, const std::string &trace_file, Addr addr_offset)
Definition: base.cc:519
BaseTrafficGen::TrafficGenPort::trafficGen
BaseTrafficGen & trafficGen
Definition: base.hh:150
BaseTrafficGen::StatGroup::totalWriteLatency
Stats::Scalar totalWriteLatency
Total num of ticks write reqs took to complete
Definition: base.hh:219
BaseTrafficGen::blockedWaitingResp
bool blockedWaitingResp
Set when we blocked waiting for outstanding reqs.
Definition: base.hh:170
RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:74
BaseTrafficGen::streamGenerator
std::unique_ptr< StreamGen > streamGenerator
Stream/SubStreamID Generator.
Definition: base.hh:335
BaseTrafficGen::StatGroup::numPackets
Stats::Scalar numPackets
Count the number of generated packets.
Definition: base.hh:201
BaseTrafficGen::TrafficGenPort::recvAtomicSnoop
Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from our peer.
Definition: base.hh:146
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:106
BaseTrafficGen::TrafficGenPort::recvTimingSnoopReq
void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the peer.
Definition: base.hh:142
BaseTrafficGen::waitingResp
std::unordered_map< RequestPtr, Tick > waitingResp
Reqs waiting for response.
Definition: base.hh:192
BaseTrafficGen::start
void start()
Definition: base.cc:281
BaseTrafficGen::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: base.cc:131
BaseTrafficGen::StatGroup::numSuppressed
Stats::Scalar numSuppressed
Count the number of dropped requests.
Definition: base.hh:198
BaseTrafficGen::StatGroup::StatGroup
StatGroup(Stats::Group *parent)
Definition: base.cc:334
BaseTrafficGen::scheduleUpdate
void scheduleUpdate()
Schedule the update event based on nextPacketTick and nextTransitionTick.
Definition: base.cc:257
StreamGen
Definition: stream_gen.hh:49
BaseTrafficGen::nextPacketTick
Tick nextPacketTick
Time of the next packet.
Definition: base.hh:121
qport.hh
BaseTrafficGen::requestorId
const RequestorID requestorId
RequestorID used in generated requests.
Definition: base.hh:329
BaseTrafficGen::StatGroup::totalReads
Stats::Scalar totalReads
Count the number reads.
Definition: base.hh:222
BaseTrafficGen::~BaseTrafficGen
~BaseTrafficGen()
Definition: base.cc:88
BaseTrafficGen::StatGroup
Definition: base.hh:194
clocked_object.hh
Stats::Formula
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3037
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
Stats::Group
Statistics container.
Definition: group.hh:83
BaseTrafficGen::recvTimingResp
bool recvTimingResp(PacketPtr pkt)
Definition: base.cc:531
BaseTrafficGen::updateEvent
EventFunctionWrapper updateEvent
Event for scheduling updates.
Definition: base.hh:188
BaseTrafficGen::stats
BaseTrafficGen::StatGroup stats
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
BaseTrafficGen::createIdle
std::shared_ptr< BaseGen > createIdle(Tick duration)
Definition: base.cc:359
BaseTrafficGen::retryPktTick
Tick retryPktTick
Tick when the stalled packet was meant to be sent.
Definition: base.hh:167
BaseTrafficGen::elasticReq
const bool elasticReq
Determine whether to add elasticity in the request injection, thus responding to backpressure by slow...
Definition: base.hh:79
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
BaseTrafficGen::StatGroup::retryTicks
Stats::Scalar retryTicks
Count the time incurred from back-pressure.
Definition: base.hh:207
BaseTrafficGen::TrafficGenPort::recvFunctionalSnoop
void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the peer.
Definition: base.hh:144
CheckpointIn
Definition: serialize.hh:67
BaseTrafficGen::maxOutstandingReqs
const int maxOutstandingReqs
Definition: base.hh:123
BaseTrafficGen::StatGroup::writeBW
Stats::Formula writeBW
Write bandwidth in bytes/s
Definition: base.hh:237
BaseTrafficGen::createExit
std::shared_ptr< BaseGen > createExit(Tick duration)
Definition: base.cc:366
BaseTrafficGen::system
System *const system
The system used to determine which mode we are currently operating in.
Definition: base.hh:73
BaseTrafficGen::update
void update()
Schedules event for next update and generates a new packet or requests a new generatoir depending on ...
Definition: base.cc:168
BaseTrafficGen::TrafficGenPort::TrafficGenPort
TrafficGenPort(const std::string &name, BaseTrafficGen &traffic_gen)
Definition: base.hh:131
BaseTrafficGen::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: base.cc:151
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:495
BaseTrafficGen::StatGroup::bytesWritten
Stats::Scalar bytesWritten
Count the number of bytes written.
Definition: base.hh:213
curTick
Tick curTick()
The current simulated tick.
Definition: core.hh:45

Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17