gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
traffic_gen.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013, 2016 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 #ifndef __CPU_TRAFFIC_GEN_TRAFFIC_GEN_HH__
42 #define __CPU_TRAFFIC_GEN_TRAFFIC_GEN_HH__
43 
44 #include <unordered_map>
45 
46 #include "base/statistics.hh"
48 #include "mem/mem_object.hh"
49 #include "mem/qport.hh"
50 #include "params/TrafficGen.hh"
51 
61 class TrafficGen : public MemObject
62 {
63 
64  private:
65 
69  void transition();
70 
76  void enterState(uint32_t newState);
77 
91  std::string resolveFile(const std::string &name);
92 
97  void parseConfig();
98 
104  void update();
105 
110  void recvReqRetry();
111 
115  void noProgress();
116 
118  struct Transition {
119  uint32_t from;
120  uint32_t to;
121  double p;
122  };
123 
129 
134 
138  const std::string configFile;
139 
144  const bool elasticReq;
145 
151 
156 
159 
162 
165 
167  uint32_t currState;
168 
170  std::unordered_map<uint32_t, BaseGen*> states;
171 
173  class TrafficGenPort : public MasterPort
174  {
175  public:
176 
177  TrafficGenPort(const std::string& name, TrafficGen& traffic_gen)
178  : MasterPort(name, &traffic_gen), trafficGen(traffic_gen)
179  { }
180 
181  protected:
182 
184 
185  bool recvTimingResp(PacketPtr pkt);
186 
188 
190 
191  Tick recvAtomicSnoop(PacketPtr pkt) { return 0; }
192 
193  private:
194 
196 
197  };
198 
201 
204 
207 
210 
211  uint64_t numSuppressed;
212 
215 
218 
221 
222  public:
223 
224  TrafficGen(const TrafficGenParams* p);
225 
227 
228  BaseMasterPort& getMasterPort(const std::string &if_name,
229  PortID idx = InvalidPortID) override;
230 
231  void init() override;
232 
233  void initState() override;
234 
235  DrainState drain() override;
236 
237  void serialize(CheckpointOut &cp) const override;
238  void unserialize(CheckpointIn &cp) override;
239 
241  void regStats() override;
242 
243 };
244 
245 #endif //__CPU_TRAFFIC_GEN_TRAFFIC_GEN_HH__
EventWrapper< TrafficGen,&TrafficGen::update > updateEvent
Event for scheduling updates.
Definition: traffic_gen.hh:209
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:167
void recvReqRetry()
Receive a retry from the neighbouring port and attempt to resend the waiting packet.
Definition: traffic_gen.cc:512
TrafficGenPort port
The instance of master port used by the traffic generator.
Definition: traffic_gen.hh:200
PacketPtr retryPkt
Packet waiting to be sent.
Definition: traffic_gen.hh:203
Master port specialisation for the traffic generator.
Definition: traffic_gen.hh:173
Declaration of a set of generator behaviours that are used by the stand-alone traffic generator...
const PortID InvalidPortID
Definition: types.hh:182
DrainState
Object drain/handover states.
Definition: drain.hh:71
void noProgress()
Method to inform the user we have made no progress.
Definition: traffic_gen.cc:545
void enterState(uint32_t newState)
Enter a new state.
Definition: traffic_gen.cc:499
Tick nextPacketTick
Time of the next packet.
Definition: traffic_gen.hh:161
TrafficGen(const TrafficGenParams *p)
Definition: traffic_gen.cc:57
Struct to represent a probabilistic transition during parsing.
Definition: traffic_gen.hh:118
Stats::Scalar retryTicks
Count the time incurred from back-pressure.
Definition: traffic_gen.hh:220
void recvFunctionalSnoop(PacketPtr pkt)
Receive a functional snoop request packet from the slave port.
Definition: traffic_gen.hh:189
MemObject declaration.
uint32_t currState
Index of the current state.
Definition: traffic_gen.hh:167
Definition: system.hh:83
Stats::Scalar numPackets
Count the number of generated packets.
Definition: traffic_gen.hh:214
TrafficGenPort(const std::string &name, TrafficGen &traffic_gen)
Definition: traffic_gen.hh:177
const std::string configFile
The config file to parse.
Definition: traffic_gen.hh:138
std::vector< std::vector< double > > transitionMatrix
State transition matrix.
Definition: traffic_gen.hh:164
Declaration of Statistics objects.
Tick recvAtomicSnoop(PacketPtr pkt)
Receive an atomic snoop request packet from the slave port.
Definition: traffic_gen.hh:191
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
STL vector class.
Definition: stl.hh:40
uint64_t numSuppressed
Definition: traffic_gen.hh:211
void parseConfig()
Parse the config file and build the state map and transition matrix.
Definition: traffic_gen.cc:257
DrainState drain() override
Notify an object that it needs to drain its state.
Definition: traffic_gen.cc:127
void recvReqRetry()
Called by the slave port if sendTimingReq was called on this master port (causing recvTimingReq to be...
Definition: traffic_gen.hh:183
Declaration of the queued port.
void regStats() override
Register statistics.
Definition: traffic_gen.cc:552
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: traffic_gen.hh:61
uint64_t Tick
Tick count type.
Definition: types.hh:63
BaseMasterPort & getMasterPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a master port with a given name and index.
Definition: traffic_gen.cc:83
System * system
The system used to determine which mode we are currently operating in.
Definition: traffic_gen.hh:128
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: traffic_gen.cc:165
const bool elasticReq
Determine whether to add elasticity in the request injection, thus responding to backpressure by slow...
Definition: traffic_gen.hh:144
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: traffic_gen.cc:146
void recvTimingSnoopReq(PacketPtr pkt)
Receive a timing snoop request from the slave port.
Definition: traffic_gen.hh:187
void update()
Schedules event for next update and executes an update on the state graph, either performing a state ...
Definition: traffic_gen.cc:185
uint16_t MasterID
Definition: request.hh:85
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
Stats::Scalar numRetries
Count the number of retries.
Definition: traffic_gen.hh:217
Tick retryPktTick
Tick when the stalled packet was meant to be sent.
Definition: traffic_gen.hh:206
virtual const std::string name() const
Definition: sim_object.hh:117
std::string resolveFile(const std::string &name)
Resolve a file path in the configuration file.
Definition: traffic_gen.cc:236
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: traffic_gen.cc:93
std::ostream CheckpointOut
Definition: serialize.hh:67
The MemObject class extends the ClockedObject with accessor functions to get its master and slave por...
Definition: mem_object.hh:60
A BaseMasterPort is a protocol-agnostic master port, responsible only for the structural connection t...
Definition: port.hh:115
Tick nextTransitionTick
Time of next transition.
Definition: traffic_gen.hh:158
MasterID masterID
MasterID used in generated requests.
Definition: traffic_gen.hh:133
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:181
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: traffic_gen.cc:113
EventWrapper< TrafficGen,&TrafficGen::noProgress > noProgressEvent
Event to keep track of our progress, or lack thereof.
Definition: traffic_gen.hh:155
Bitfield< 0 > p
bool recvTimingResp(PacketPtr pkt)
Receive a timing response from the slave port.
Definition: traffic_gen.cc:573
void transition()
Determine next state and perform the transition.
Definition: traffic_gen.cc:480
const Tick progressCheck
Time to tolerate waiting for retries (not making progress), until we declare things broken...
Definition: traffic_gen.hh:150
std::unordered_map< uint32_t, BaseGen * > states
Map of generator states.
Definition: traffic_gen.hh:170

Generated on Fri Jun 9 2017 13:03:44 for gem5 by doxygen 1.8.6