cpu,stdlib: Updating strided generator (#762)
This change improves the functionality of strided generator to create trace with better flexibility. It allows the user to manually set offset and stride size instead of calculating it based on a "gen_id". This way different patterns could be created with the same SimObject. In addition, this change adds stdlib components for strided generator.
This commit is contained in:
@@ -527,19 +527,20 @@ BaseTrafficGen::createNvm(Tick duration,
|
||||
}
|
||||
|
||||
std::shared_ptr<BaseGen>
|
||||
BaseTrafficGen::createStrided(Tick duration,
|
||||
Addr start_addr, Addr end_addr, Addr blocksize,
|
||||
Addr stride_size, int gen_id,
|
||||
Tick min_period, Tick max_period,
|
||||
uint8_t read_percent, Addr data_limit)
|
||||
BaseTrafficGen::createStrided(
|
||||
Tick duration,
|
||||
Addr start_addr, Addr end_addr, Addr offset,
|
||||
Addr block_size, Addr superblock_size, Addr stride_size,
|
||||
Tick min_period, Tick max_period,
|
||||
uint8_t read_percent, Addr data_limit)
|
||||
{
|
||||
return std::shared_ptr<BaseGen>(new StridedGen(*this, requestorId,
|
||||
duration, start_addr,
|
||||
end_addr, blocksize,
|
||||
system->cacheLineSize(),
|
||||
stride_size, gen_id,
|
||||
min_period, max_period,
|
||||
read_percent, data_limit));
|
||||
return std::shared_ptr<BaseGen>(new StridedGen(
|
||||
*this, requestorId, duration,
|
||||
system->cacheLineSize(),
|
||||
start_addr, end_addr, offset,
|
||||
block_size, superblock_size, stride_size,
|
||||
min_period, max_period,
|
||||
read_percent, data_limit));
|
||||
}
|
||||
|
||||
std::shared_ptr<BaseGen>
|
||||
|
||||
@@ -320,8 +320,8 @@ class BaseTrafficGen : public ClockedObject
|
||||
|
||||
std::shared_ptr<BaseGen> createStrided(
|
||||
Tick duration,
|
||||
Addr start_addr, Addr end_addr, Addr blocksize,
|
||||
Addr stride_size, int gen_id,
|
||||
Addr start_addr, Addr end_addr, Addr offset,
|
||||
Addr block_size, Addr superblock_size, Addr stride_size,
|
||||
Tick min_period, Tick max_period,
|
||||
uint8_t read_percent, Addr data_limit);
|
||||
|
||||
|
||||
@@ -46,11 +46,28 @@
|
||||
namespace gem5
|
||||
{
|
||||
|
||||
StridedGen::StridedGen(SimObject& obj, RequestorID requestor_id,
|
||||
Tick duration, Addr cacheline_size,
|
||||
Addr start_addr, Addr end_addr, Addr offset,
|
||||
Addr block_size, Addr superblock_size, Addr stride_size,
|
||||
Tick min_period, Tick max_period,
|
||||
uint8_t read_percent, Addr data_limit)
|
||||
: StochasticGen(obj, requestor_id, duration, start_addr, end_addr,
|
||||
block_size, cacheline_size, min_period, max_period,
|
||||
read_percent, data_limit),
|
||||
offset(offset), superblockSize(superblock_size), strideSize(stride_size),
|
||||
nextAddr(0), dataManipulated(0)
|
||||
{
|
||||
assert(superblock_size % block_size == 0);
|
||||
assert(offset % superblock_size == 0);
|
||||
assert(stride_size % superblock_size == 0);
|
||||
}
|
||||
|
||||
void
|
||||
StridedGen::enter()
|
||||
{
|
||||
// reset the address and the data counter
|
||||
nextAddr = startAddr + genID * blocksize;
|
||||
nextAddr = startAddr + offset;
|
||||
dataManipulated = 0;
|
||||
}
|
||||
|
||||
@@ -74,14 +91,20 @@ StridedGen::getNextPacket()
|
||||
isRead ? MemCmd::ReadReq : MemCmd::WriteReq);
|
||||
|
||||
// increment the address
|
||||
nextAddr += strideSize;
|
||||
nextAddr += blocksize;
|
||||
|
||||
// if we have completed reading a block we need to jump
|
||||
// (strideSize - blockSize) bytes to start reading the next block
|
||||
if ((nextAddr - (startAddr + offset)) % superblockSize == 0) {
|
||||
nextAddr += (strideSize - superblockSize);
|
||||
}
|
||||
|
||||
// If we have reached the end of the address space, reset the
|
||||
// address to the start of the range
|
||||
if (nextAddr > endAddr) {
|
||||
DPRINTF(TrafficGen, "Wrapping address to the start of "
|
||||
"the range\n");
|
||||
nextAddr = startAddr + genID * blocksize;
|
||||
nextAddr = startAddr + offset;
|
||||
}
|
||||
|
||||
return pkt;
|
||||
|
||||
@@ -71,35 +71,26 @@ class StridedGen : public StochasticGen
|
||||
*
|
||||
* @param obj SimObject owning this sequence generator
|
||||
* @param requestor_id RequestorID related to the memory requests
|
||||
* @param _duration duration of this state before transitioning
|
||||
* @param cacheline_size cache line size in the system
|
||||
* @param duration duration of this state before transitioning
|
||||
* @param start_addr Start address
|
||||
* @param end_addr End address
|
||||
* @param _blocksize Size used for transactions injected
|
||||
* @param cacheline_size cache line size in the system
|
||||
* @param offset The offset to start_addr for generating addresses.
|
||||
* First generated address = start_addr + offset.
|
||||
* @param block_size Size used for transactions injected
|
||||
* @param stride_size The strided size for consecutive requests
|
||||
* @param gen_id The order of traffic generator in a list of strided \
|
||||
* traffic generators, this param is used to offset the start address of \
|
||||
* each generator accordingly with others.
|
||||
* @param superblock_size Number of bytes to read before taking a stride
|
||||
* @param min_period Lower limit of random inter-transaction time
|
||||
* @param max_period Upper limit of random inter-transaction time
|
||||
* @param read_percent Percent of transactions that are reads
|
||||
* @param data_limit Upper limit on how much data to read/write
|
||||
*/
|
||||
StridedGen(SimObject &obj,
|
||||
RequestorID requestor_id, Tick _duration,
|
||||
Addr start_addr, Addr end_addr,
|
||||
Addr _blocksize, Addr cacheline_size,
|
||||
Addr stride_size, int gen_id,
|
||||
Tick min_period, Tick max_period,
|
||||
uint8_t read_percent, Addr data_limit)
|
||||
: StochasticGen(obj, requestor_id, _duration, start_addr, end_addr,
|
||||
_blocksize, cacheline_size, min_period, max_period,
|
||||
read_percent, data_limit),
|
||||
nextAddr(0),
|
||||
dataManipulated(0),
|
||||
strideSize(stride_size),
|
||||
genID(gen_id)
|
||||
{ }
|
||||
StridedGen(SimObject& obj, RequestorID requestor_id,
|
||||
Tick duration, Addr cacheline_size,
|
||||
Addr start_addr, Addr end_addr, Addr offset,
|
||||
Addr block_size, Addr superblock_size, Addr stride_size,
|
||||
Tick min_period, Tick max_period,
|
||||
uint8_t read_percent, Addr data_limit);
|
||||
|
||||
void enter();
|
||||
|
||||
@@ -108,6 +99,12 @@ class StridedGen : public StochasticGen
|
||||
Tick nextPacketTick(bool elastic, Tick delay) const;
|
||||
|
||||
private:
|
||||
|
||||
Addr offset;
|
||||
Addr superblockSize;
|
||||
/* The size of the access stride */
|
||||
Addr strideSize;
|
||||
|
||||
/** Address of next request */
|
||||
Addr nextAddr;
|
||||
|
||||
@@ -117,17 +114,6 @@ class StridedGen : public StochasticGen
|
||||
* generating requests.
|
||||
*/
|
||||
Addr dataManipulated;
|
||||
|
||||
/* The size by which consequent requests are separated */
|
||||
Addr strideSize;
|
||||
|
||||
/**
|
||||
* This param is used to indicate the order of a traffic
|
||||
* generator among a set of traffic generators, then it
|
||||
* is used to calculate the start address separately for
|
||||
* each traffic generator in a list of generators.
|
||||
*/
|
||||
int genID;
|
||||
};
|
||||
|
||||
} // namespace gem5
|
||||
|
||||
@@ -287,6 +287,35 @@ TrafficGen::parseConfig()
|
||||
DPRINTF(TrafficGen, "State: %d NvmGen\n", id);
|
||||
}
|
||||
}
|
||||
} else if (mode == "STRIDED") {
|
||||
uint32_t read_percent;
|
||||
Addr start_addr;
|
||||
Addr end_addr;
|
||||
Addr offset;
|
||||
Addr blocksize;
|
||||
Addr superblock_size;
|
||||
Addr stride_size;
|
||||
Tick min_period;
|
||||
Tick max_period;
|
||||
Addr data_limit;
|
||||
|
||||
is >> read_percent >> start_addr >> end_addr >> offset >>
|
||||
blocksize >> superblock_size >> stride_size >>
|
||||
min_period >> max_period >> data_limit;
|
||||
|
||||
DPRINTF(TrafficGen, "%s, addr %x to %x with offset %x, "
|
||||
"size %d, super size %d, stride size %d, "
|
||||
"period %d to %d, %d%% reads\n",
|
||||
mode, start_addr, end_addr, offset, blocksize,
|
||||
superblock_size, stride_size, min_period,
|
||||
max_period, read_percent);
|
||||
|
||||
states[id] = createStrided(
|
||||
duration, start_addr, end_addr, offset,
|
||||
blocksize, superblock_size, stride_size,
|
||||
min_period, max_period, read_percent, data_limit);
|
||||
|
||||
DPRINTF(TrafficGen, "State: %d StridedGen\n", id);
|
||||
} else {
|
||||
fatal("%s: Unknown traffic generator mode: %s",
|
||||
name(), mode);
|
||||
|
||||
Reference in New Issue
Block a user