gem5  v19.0.0.0
base.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013, 2016-2019 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  * Authors: Thomas Grass
38  * Andreas Hansson
39  * Sascha Bischoff
40  */
41 
42 #ifndef __CPU_TRAFFIC_GEN_BASE_HH__
43 #define __CPU_TRAFFIC_GEN_BASE_HH__
44 
45 #include <memory>
46 #include <tuple>
47 #include <unordered_map>
48 
49 #include "base/statistics.hh"
50 #include "enums/AddrMap.hh"
51 #include "mem/qport.hh"
52 #include "sim/clocked_object.hh"
53 
54 class BaseGen;
55 class StreamGen;
56 class System;
57 struct BaseTrafficGenParams;
58 
69 {
70  friend class BaseGen;
71 
72  protected: // Params
77  System *const system;
78 
83  const bool elasticReq;
84 
90 
91  private:
96  void recvReqRetry();
97 
98  void retryReq();
99 
100  bool recvTimingResp(PacketPtr pkt);
101 
103  void transition();
104 
109  void scheduleUpdate();
110 
114  void noProgress();
115 
120 
123 
126 
128 
129 
131  class TrafficGenPort : public MasterPort
132  {
133  public:
134 
135  TrafficGenPort(const std::string& name, BaseTrafficGen& traffic_gen)
136  : MasterPort(name, &traffic_gen), trafficGen(traffic_gen)
137  { }
138 
139  protected:
140 
142 
144  { return trafficGen.recvTimingResp(pkt); }
145 
147 
149 
150  Tick recvAtomicSnoop(PacketPtr pkt) { return 0; }
151 
152  private:
153 
155 
156  };
157 
162  void update();
163 
166 
169 
172 
175 
181  {
182  assert(waitingResp.find(pkt->req) == waitingResp.end());
183  assert(pkt->needsResponse());
184 
185  waitingResp[pkt->req] = curTick();
186 
187  return (maxOutstandingReqs > 0) &&
188  (waitingResp.size() > maxOutstandingReqs);
189  }
190 
193 
194  protected: // Stats
196  std::unordered_map<RequestPtr,Tick> waitingResp;
197 
198  struct StatGroup : public Stats::Group {
199  StatGroup(Stats::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_DRAM, 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_DRAM, 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> createTrace(
297  Tick duration,
298  const std::string& trace_file, Addr addr_offset);
299 
300  protected:
301  void start();
302 
303  virtual std::shared_ptr<BaseGen> nextGenerator() = 0;
304 
309 
311  std::shared_ptr<BaseGen> activeGenerator;
312 
314  std::unique_ptr<StreamGen> streamGenerator;
315 };
316 
317 #endif //__CPU_TRAFFIC_GEN_BASE_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:75
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: base.cc:105
virtual std::shared_ptr< BaseGen > nextGenerator()=0
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_DRAM, 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
Ports are used to interface objects to each other.
Definition: port.hh:60
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: base.cc:153
std::shared_ptr< BaseGen > createTrace(Tick duration, const std::string &trace_file, Addr addr_offset)
Definition: base.cc:452
void recvReqRetry()
Receive a retry from the neighbouring port and attempt to resend the waiting packet.
Definition: base.cc:290
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: base.cc:95
std::unique_ptr< StreamGen > streamGenerator
Stream/SubStreamID Generator.
Definition: base.hh:314
TrafficGenPort port
The instance of master port used by the traffic generator.
Definition: base.hh:165
Stats::Scalar totalWriteLatency
Total num of ticks write reqs took to complete.
Definition: base.hh:223
void recvReqRetry()
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: base.hh:141
const PortID InvalidPortID
Definition: types.hh:238
DrainState
Object drain/handover states.
Definition: drain.hh:71
BaseTrafficGen & trafficGen
Definition: base.hh:154
void transition()
Transition to the next generator.
Definition: base.cc:231
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:180
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
TrafficGenPort(const std::string &name, BaseTrafficGen &traffic_gen)
Definition: base.hh:135
std::shared_ptr< BaseGen > activeGenerator
Currently active generator.
Definition: base.hh:311
bool blockedWaitingResp
Set when we blocked waiting for outstanding reqs.
Definition: base.hh:174
const bool elasticReq
Determine whether to add elasticity in the request injection, thus responding to backpressure by slow...
Definition: base.hh:83
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: base.cc:133
Stats::Scalar numPackets
Count the number of generated packets.
Definition: base.hh:205
Definition: system.hh:77
void scheduleUpdate()
Schedule the update event based on nextPacketTick and nextTransitionTick.
Definition: base.cc:259
Stats::Scalar totalReadLatency
Total num of ticks read reqs took to complete.
Definition: base.hh:220
Definition: cprintf.cc:42
std::shared_ptr< BaseGen > createExit(Tick duration)
Definition: base.cc:367
void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the peer.
Definition: base.hh:148
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_DRAM, unsigned int nbr_of_banks_util, Enums::AddrMap addr_mapping, unsigned int nbr_of_ranks)
Definition: base.cc:401
Declaration of Statistics objects.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
const MasterID masterID
MasterID used in generated requests.
Definition: base.hh:308
~BaseTrafficGen()
Definition: base.cc:90
EventFunctionWrapper noProgressEvent
Event to keep track of our progress, or lack thereof.
Definition: base.hh:119
RequestPtr req
A pointer to the original request.
Definition: packet.hh:327
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
Declaration of the queued port.
Tick retryPktTick
Tick when the stalled packet was meant to be sent.
Definition: base.hh:171
Tick curTick()
The current simulated tick.
Definition: core.hh:47
void update()
Schedules event for next update and generates a new packet or requests a new generatoir depending on ...
Definition: base.cc:170
bool needsResponse() const
Definition: packet.hh:542
Stats::Scalar numSuppressed
Count the number of dropped requests.
Definition: base.hh:202
void start()
Definition: base.cc:283
Stats::Formula writeBW
Write bandwidth in bytes/s.
Definition: base.hh:241
uint64_t Tick
Tick count type.
Definition: types.hh:63
std::shared_ptr< BaseGen > createIdle(Tick duration)
Definition: base.cc:361
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Stats::Scalar totalReads
Count the number reads.
Definition: base.hh:226
System *const system
The system used to determine which mode we are currently operating in.
Definition: base.hh:77
ClockedObject declaration and implementation.
Stats::Scalar bytesWritten
Count the number of bytes written.
Definition: base.hh:217
Tick nextPacketTick
Time of the next packet.
Definition: base.hh:125
bool recvTimingResp(PacketPtr pkt)
Definition: base.cc:464
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
uint16_t MasterID
Definition: request.hh:86
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
Statistics container.
Definition: group.hh:85
Tick nextTransitionTick
Time of next transition.
Definition: base.hh:122
PacketPtr retryPkt
Packet waiting to be sent.
Definition: base.hh:168
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3012
Stats::Formula avgWriteLatency
Avg num of ticks each write reqs took to complete.
Definition: base.hh:235
Stats::Scalar retryTicks
Count the time incurred from back-pressure.
Definition: base.hh:211
std::ostream CheckpointOut
Definition: serialize.hh:68
Stats::Scalar numRetries
Count the number of retries.
Definition: base.hh:208
EventFunctionWrapper updateEvent
Event for scheduling updates.
Definition: base.hh:192
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:106
Stats::Formula readBW
Read bandwidth in bytes/s.
Definition: base.hh:238
Stats::Scalar totalWrites
Count the number writes.
Definition: base.hh:229
void noProgress()
Method to inform the user we have made no progress.
Definition: base.cc:330
Stats::Scalar bytesRead
Count the number of bytes read.
Definition: base.hh:214
std::unordered_map< RequestPtr, Tick > waitingResp
Reqs waiting for response.
Definition: base.hh:196
const int maxOutstandingReqs
Definition: base.hh:127
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
void retryReq()
Definition: base.cc:298
The traffic generator is a master module that generates stimuli for the memory system, based on a collection of simple generator behaviours that are either probabilistic or based on traces.
Definition: base.hh:68
Stats::Formula avgReadLatency
Avg num of ticks each read req took to complete.
Definition: base.hh:232
const Tick progressCheck
Time to tolerate waiting for retries (not making progress), until we declare things broken...
Definition: base.hh:89
Base class for all generators, with the shared functionality and virtual functions for entering...
Definition: base_gen.hh:62
void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the peer.
Definition: base.hh:146
Bitfield< 0 > p
BaseTrafficGen::StatGroup stats
DrainState drain() override
Notify an object that it needs to drain its state.
Definition: base.cc:114
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the peer.
Definition: base.hh:143
Master port specialisation for the traffic generator.
Definition: base.hh:131
Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from our peer.
Definition: base.hh:150
BaseTrafficGen(const BaseTrafficGenParams *p)
Definition: base.cc:71

Generated on Fri Feb 28 2020 16:26:58 for gem5 by doxygen 1.8.13