47 #include "config/have_protobuf.hh" 56 #include "debug/Checkpoint.hh" 57 #include "debug/TrafficGen.hh" 58 #include "enums/AddrMap.hh" 59 #include "params/BaseTrafficGen.hh" 74 elasticReq(p->elastic_req),
75 progressCheck(p->progress_check),
97 if (if_name ==
"port") {
110 fatal(
"The port of %s is not connected!\n",
name());
135 warn(
"%s serialization does not keep all traffic generator" 136 " internal state\n",
name());
138 DPRINTF(Checkpoint,
"Serializing BaseTrafficGen\n");
155 warn(
"%s serialization does not restore all traffic generator" 156 " internal state\n",
name());
190 pkt->
req->setStreamId(sid);
193 pkt->
req->setSubStreamId(ssid);
213 warn(
"%s suppressed %d packets with non-memory addresses\n",
240 if (duration !=
MaxTick && duration != 0) {
332 fatal(
"BaseTrafficGen %s spent %llu ticks without making progress",
339 "Number of suppressed packets to non-memory space"),
340 ADD_STAT(numPackets,
"Number of packets generated"),
341 ADD_STAT(numRetries,
"Number of retries"),
342 ADD_STAT(retryTicks,
"Time spent waiting due to back-pressure (ticks)"),
343 ADD_STAT(bytesRead,
"Number of bytes read"),
344 ADD_STAT(bytesWritten,
"Number of bytes written"),
345 ADD_STAT(totalReadLatency,
"Total latency of read requests"),
346 ADD_STAT(totalWriteLatency,
"Total latency of write requests"),
347 ADD_STAT(totalReads,
"Total num of reads"),
348 ADD_STAT(totalWrites,
"Total num of writes"),
349 ADD_STAT(avgReadLatency,
"Avg latency of read requests",
350 totalReadLatency / totalReads),
351 ADD_STAT(avgWriteLatency,
"Avg latency of write requests",
352 totalWriteLatency / totalWrites),
353 ADD_STAT(readBW,
"Read bandwidth in bytes/s",
355 ADD_STAT(writeBW,
"Write bandwidth in bytes/s",
360 std::shared_ptr<BaseGen>
363 return std::shared_ptr<BaseGen>(
new IdleGen(*
this,
masterID, duration));
366 std::shared_ptr<BaseGen>
369 return std::shared_ptr<BaseGen>(
new ExitGen(*
this,
masterID, duration));
372 std::shared_ptr<BaseGen>
376 uint8_t read_percent,
Addr data_limit)
379 duration, start_addr,
382 min_period, max_period,
383 read_percent, data_limit));
386 std::shared_ptr<BaseGen>
390 uint8_t read_percent,
Addr data_limit)
393 duration, start_addr,
396 min_period, max_period,
397 read_percent, data_limit));
400 std::shared_ptr<BaseGen>
404 uint8_t read_percent,
Addr data_limit,
405 unsigned int num_seq_pkts,
unsigned int page_size,
406 unsigned int nbr_of_banks_DRAM,
407 unsigned int nbr_of_banks_util,
408 Enums::AddrMap addr_mapping,
409 unsigned int nbr_of_ranks)
412 duration, start_addr,
415 min_period, max_period,
416 read_percent, data_limit,
417 num_seq_pkts, page_size,
424 std::shared_ptr<BaseGen>
428 uint8_t read_percent,
Addr data_limit,
429 unsigned int num_seq_pkts,
430 unsigned int page_size,
431 unsigned int nbr_of_banks_DRAM,
432 unsigned int nbr_of_banks_util,
433 Enums::AddrMap addr_mapping,
434 unsigned int nbr_of_ranks,
435 unsigned int max_seq_count_per_rank)
438 duration, start_addr,
441 min_period, max_period,
442 read_percent, data_limit,
443 num_seq_pkts, page_size,
448 max_seq_count_per_rank));
451 std::shared_ptr<BaseGen>
453 const std::string& trace_file,
Addr addr_offset)
456 return std::shared_ptr<BaseGen>(
459 panic(
"Can't instantiate trace generation without Protobuf support!\n");
469 "Received unexpected response [%s reqPtr=%x]\n",
472 assert(iter->second <=
curTick());
476 stats.bytesWritten += pkt->
req->getSize();
480 stats.bytesRead += pkt->
req->getSize();
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
#define panic(...)
This implements a cprintf based panic() function.
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)
Ports are used to interface objects to each other.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
std::shared_ptr< BaseGen > createTrace(Tick duration, const std::string &trace_file, Addr addr_offset)
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
void recvReqRetry()
Receive a retry from the neighbouring port and attempt to resend the waiting packet.
#define fatal(...)
This implements a cprintf based fatal() function.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
std::unique_ptr< StreamGen > streamGenerator
Stream/SubStreamID Generator.
TrafficGenPort port
The instance of master port used by the traffic generator.
DrainState
Object drain/handover states.
Tick when() const
Get the time that the event is scheduled.
The linear generator generates sequential requests from a start to an end address, with a fixed block size.
void transition()
Transition to the next generator.
bool allocateWaitingRespSlot(PacketPtr pkt)
Puts this packet in the waitingResp list and returns true if we are above the maximum number of ousta...
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)
DrainState drainState() const
Return the current drain state of an object.
Declaration of the trace generator that reads a trace file and plays the transactions.
std::shared_ptr< BaseGen > activeGenerator
Currently active generator.
bool blockedWaitingResp
Set when we blocked waiting for outstanding reqs.
const bool elasticReq
Determine whether to add elasticity in the request injection, thus responding to backpressure by slow...
void serialize(CheckpointOut &cp) const override
Serialize an object.
void signalDrainDone() const
Signal that an object is drained.
Stats::Scalar numPackets
Count the number of generated packets.
void scheduleUpdate()
Schedule the update event based on nextPacketTick and nextTransitionTick.
Overload hash function for BasicBlockRange type.
bool sendTimingReq(PacketPtr pkt)
Attempt to send a timing request to the slave port by calling its corresponding receive function...
bool isConnected() const
Is this port currently connected to a peer?
Declaration of DRAM rotation generator that rotates through each rank.
std::shared_ptr< BaseGen > createExit(Tick duration)
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)
Declaration of the idle generator that does nothing.
Stats::Formula simSeconds
void deschedule(Event &event)
const MasterID masterID
MasterID used in generated requests.
EventFunctionWrapper noProgressEvent
Event to keep track of our progress, or lack thereof.
RequestPtr req
A pointer to the original request.
static StreamGen * create(const BaseTrafficGenParams *p)
Factory method for constructing a Stream generator.
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)
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
#define UNSERIALIZE_SCALAR(scalar)
The idle generator does nothing.
The trace replay generator reads a trace file and plays back the transactions.
Tick retryPktTick
Tick when the stalled packet was meant to be sent.
Tick curTick()
The current simulated tick.
void update()
Schedules event for next update and generates a new packet or requests a new generatoir depending on ...
bool scheduled() const
Determine if the current event is scheduled.
Stats::Scalar numSuppressed
Count the number of dropped requests.
The traffic generator is a master module that generates stimuli for the memory system, based on a collection of simple behaviours that are either probabilistic or based on traces.
bool isMemAddr(Addr addr) const
Check if a physical address is within a range of a memory that is part of the global address map...
uint64_t Tick
Tick count type.
std::shared_ptr< BaseGen > createIdle(Tick duration)
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Declaration of the base generator class for all generators.
MasterID getMasterId(const SimObject *master, std::string submaster=std::string())
Request an id used to create a request object in the system.
System *const system
The system used to determine which mode we are currently operating in.
DRAM specific generator is for issuing request with variable page hit length and bank utilization...
Tick nextPacketTick
Time of the next packet.
The exit generator exits from the simulation once entered.
bool recvTimingResp(PacketPtr pkt)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Draining buffers pending serialization/handover.
virtual const std::string name() const
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Tick nextTransitionTick
Time of next transition.
Declaration of the DRAM generator for issuing variable page hit length requests and bank utilisation...
Declaration of the linear generator that generates sequential requests.
PacketPtr retryPkt
Packet waiting to be sent.
#define SERIALIZE_SCALAR(scalar)
void reschedule(Event &event, Tick when, bool always=false)
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Stats::Scalar retryTicks
Count the time incurred from back-pressure.
std::ostream CheckpointOut
Stats::Scalar numRetries
Count the number of retries.
EventFunctionWrapper updateEvent
Event for scheduling updates.
void print(std::ostream &o, int verbosity=0, const std::string &prefix="") const
The random generator is similar to the linear one, but does not generate sequential addresses...
void schedule(Event &event, Tick when)
void noProgress()
Method to inform the user we have made no progress.
Declaration of the random generator that randomly selects addresses within a range.
std::unordered_map< RequestPtr, Tick > waitingResp
Reqs waiting for response.
const int maxOutstandingReqs
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Declaration of the Stream generator for issuing memory requests with variable/fixed stream and substr...
const Tick progressCheck
Time to tolerate waiting for retries (not making progress), until we declare things broken...
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
Declaration of the exit generator that ends the simulation.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
BaseTrafficGen::StatGroup stats
std::vector< Info * > stats
Counter value() const
Return the current value of this stat as its base type.
DrainState drain() override
Notify an object that it needs to drain its state.
StatGroup(Stats::Group *parent)
BaseTrafficGen(const BaseTrafficGenParams *p)
unsigned int cacheLineSize() const
Get the cache line size of the system.