Go to the documentation of this file.
47 #include "debug/TrafficGen.hh"
48 #include "params/TrafficGen.hh"
56 configFile(
p->config_file),
62 TrafficGenParams::create()
86 "Traffic generator is only active in timing mode\n");
116 char *config_path = strdup(
configFile.c_str());
117 char *config_dir = dirname(config_path);
118 const std::string config_rel =
csprintf(
"%s/%s", config_dir,
name);
122 if (access(config_rel.c_str(), R_OK) == 0)
139 infile.open(
configFile.c_str(), ifstream::in);
140 if (!infile.is_open()) {
141 fatal(
"Traffic generator %s config file not found at %s\n",
145 bool init_state_set =
false;
152 while (getline(infile, line).good()) {
154 if (line.find(
'#') != 1) {
156 istringstream
is(line);
161 if (keyword ==
"STATE") {
167 is >>
id >> duration >>
mode;
169 if (
mode ==
"TRACE") {
173 is >> traceFile >> addrOffset;
178 }
else if (
mode ==
"IDLE") {
181 }
else if (
mode ==
"EXIT") {
184 }
else if (
mode ==
"LINEAR" ||
mode ==
"RANDOM" ||
185 mode ==
"DRAM" ||
mode ==
"DRAM_ROTATE" ||
187 uint32_t read_percent;
195 is >> read_percent >> start_addr >> end_addr >>
196 blocksize >> min_period >> max_period >> data_limit;
199 " period %d to %d, %d%% reads\n",
200 mode, start_addr, end_addr, blocksize, min_period,
201 max_period, read_percent);
204 if (
mode ==
"LINEAR") {
207 min_period, max_period,
208 read_percent, data_limit);
210 }
else if (
mode ==
"RANDOM") {
213 min_period, max_period,
214 read_percent, data_limit);
216 }
else if (
mode ==
"DRAM" ||
mode ==
"DRAM_ROTATE" ||
220 unsigned int stride_size;
221 unsigned int page_size;
222 unsigned int nbr_of_banks;
223 unsigned int nbr_of_banks_util;
224 unsigned _addr_mapping;
225 unsigned int nbr_of_ranks;
227 is >> stride_size >> page_size >> nbr_of_banks >>
228 nbr_of_banks_util >> _addr_mapping >>
230 Enums::AddrMap addr_mapping =
231 static_cast<Enums::AddrMap
>(_addr_mapping);
233 if (stride_size > page_size)
234 warn(
"Memory generator stride size (%d) is greater"
235 " than page size (%d) of the memory\n",
236 blocksize, page_size);
240 unsigned int num_seq_pkts = 1;
242 if (stride_size > blocksize) {
243 num_seq_pkts =
divCeil(stride_size, blocksize);
245 "block size: %d, num_seq_pkts: %d\n",
246 stride_size, blocksize, num_seq_pkts);
249 if (
mode ==
"DRAM") {
252 min_period, max_period,
253 read_percent, data_limit,
254 num_seq_pkts, page_size,
260 }
else if (
mode ==
"DRAM_ROTATE") {
265 unsigned int max_seq_count_per_rank =
266 (read_percent == 50) ? nbr_of_banks_util * 2
271 min_period, max_period,
274 num_seq_pkts, page_size,
279 max_seq_count_per_rank);
284 min_period, max_period,
285 read_percent, data_limit,
286 num_seq_pkts, page_size,
295 fatal(
"%s: Unknown traffic generator mode: %s",
298 }
else if (keyword ==
"TRANSITION") {
307 }
else if (keyword ==
"INIT") {
311 init_state_set =
true;
319 fatal(
"%s: initial state not specified (add 'INIT <id>' line "
320 "to the config file)\n",
name());
324 for (
size_t i = 0;
i <
states.size();
i++) {
329 t != transitions.end(); ++
t) {
335 for (
size_t i = 0;
i <
states.size();
i++) {
337 for (
size_t j = 0;
j <
states.size();
j++) {
342 if (abs(
sum - 1.0) > 0.001)
343 fatal(
"%s has transition probability != 1 for state %d\n",
356 double cumulative = 0.0;
366 std::shared_ptr<BaseGen>
Struct to represent a probabilistic transition during parsing.
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)
#define fatal(...)
This implements a cprintf based fatal() function.
void serialize(CheckpointOut &cp) const override
Serialize an object.
std::string resolveFile(const std::string &name)
Resolve a file path in the configuration file.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
virtual void initState()
initState() is called on each SimObject when not restoring from a checkpoint.
bool isTimingMode() const
Is the system in timing mode?
#define UNSERIALIZE_SCALAR(scalar)
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)
std::shared_ptr< BaseGen > activeGenerator
Currently active generator.
void transition()
Transition to the next generator.
uint64_t Tick
Tick count type.
std::unordered_map< uint32_t, std::shared_ptr< BaseGen > > states
Map of generator states.
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
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)
T divCeil(const T &a, const U &b)
The traffic generator is a module that generates stimuli for the memory system, based on a collection...
size_t nextState()
Use the transition matrix to find the next state index.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
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)
void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
std::shared_ptr< BaseGen > createTrace(Tick duration, const std::string &trace_file, Addr addr_offset)
std::shared_ptr< BaseGen > nextGenerator() override
uint32_t currState
Index of the current state.
TrafficGen(const TrafficGenParams *p)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
const std::string & name()
#define SERIALIZE_SCALAR(scalar)
std::vector< std::vector< double > > transitionMatrix
State transition matrix.
void serialize(CheckpointOut &cp) const override
Serialize an object.
virtual const std::string name() const
Overload hash function for BasicBlockRange type.
void parseConfig()
Parse the config file and build the state map and transition matrix.
std::enable_if< std::is_integral< T >::value, T >::type random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
std::ostream CheckpointOut
std::shared_ptr< BaseGen > createIdle(Tick duration)
const std::string configFile
The config file to parse.
std::shared_ptr< BaseGen > createExit(Tick duration)
The traffic generator is a module that generates stimuli for the memory system, based on a collection...
std::string csprintf(const char *format, const Args &...args)
System *const system
The system used to determine which mode we are currently operating in.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
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)
Generated on Wed Sep 30 2020 14:02:10 for gem5 by doxygen 1.8.17