Add "dataAlignment" field for random traffic generators
This commit is contained in:
@@ -128,6 +128,7 @@ struct TrafficGenerator
|
||||
std::optional<uint64_t> seed;
|
||||
std::optional<uint64_t> maxTransactions;
|
||||
std::optional<unsigned> dataLength;
|
||||
std::optional<unsigned> dataAlignment;
|
||||
|
||||
uint64_t numRequests;
|
||||
double rwRatio;
|
||||
@@ -145,6 +146,7 @@ NLOHMANN_JSONIFY_ALL_THINGS(TrafficGenerator,
|
||||
seed,
|
||||
maxTransactions,
|
||||
dataLength,
|
||||
dataAlignment,
|
||||
numRequests,
|
||||
rwRatio,
|
||||
addressDistribution,
|
||||
@@ -162,6 +164,7 @@ struct TrafficGeneratorStateMachine
|
||||
std::optional<uint64_t> seed;
|
||||
std::optional<uint64_t> maxTransactions;
|
||||
std::optional<unsigned> dataLength;
|
||||
std::optional<unsigned> dataAlignment;
|
||||
std::vector<std::variant<TrafficGeneratorActiveState, TrafficGeneratorIdleState>> states;
|
||||
std::vector<TrafficGeneratorStateTransition> transitions;
|
||||
};
|
||||
@@ -174,6 +177,7 @@ NLOHMANN_JSONIFY_ALL_THINGS(TrafficGeneratorStateMachine,
|
||||
seed,
|
||||
maxTransactions,
|
||||
dataLength,
|
||||
dataAlignment,
|
||||
states,
|
||||
transitions)
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ int sc_main(int argc, char **argv)
|
||||
for (auto const &initiator_config : configuration.tracesetup.value())
|
||||
{
|
||||
uint64_t memorySize = dramSys->getConfig().memSpec->getSimMemSizeInBytes();
|
||||
unsigned int dataLength = dramSys->getConfig().memSpec->defaultBytesPerBurst;
|
||||
unsigned int defaultDataLength = dramSys->getConfig().memSpec->defaultBytesPerBurst;
|
||||
|
||||
auto initiator = std::visit(
|
||||
[=, &memoryManager](auto &&config) -> std::unique_ptr<Initiator>
|
||||
@@ -120,7 +120,7 @@ int sc_main(int argc, char **argv)
|
||||
return std::make_unique<TrafficGenerator>(config,
|
||||
memoryManager,
|
||||
memorySize,
|
||||
dataLength,
|
||||
defaultDataLength,
|
||||
transactionFinished,
|
||||
termianteInitiator);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ int sc_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
StlPlayer player(
|
||||
tracePath.c_str(), config.clkMhz, dataLength, traceType, false);
|
||||
tracePath.c_str(), config.clkMhz, defaultDataLength, traceType, false);
|
||||
|
||||
return std::make_unique<SimpleInitiator<StlPlayer>>(config.name.c_str(),
|
||||
memoryManager,
|
||||
@@ -156,7 +156,7 @@ int sc_main(int argc, char **argv)
|
||||
else if constexpr (std::is_same_v<T, DRAMSys::Config::RowHammer>)
|
||||
{
|
||||
RowHammer hammer(
|
||||
config.numRequests, config.clkMhz, config.rowIncrement, dataLength);
|
||||
config.numRequests, config.clkMhz, config.rowIncrement, defaultDataLength);
|
||||
|
||||
return std::make_unique<SimpleInitiator<RowHammer>>(config.name.c_str(),
|
||||
memoryManager,
|
||||
|
||||
@@ -43,15 +43,17 @@ RandomProducer::RandomProducer(uint64_t numRequests,
|
||||
std::optional<uint64_t> minAddress,
|
||||
std::optional<uint64_t> maxAddress,
|
||||
uint64_t memorySize,
|
||||
unsigned int dataLength)
|
||||
unsigned int dataLength,
|
||||
unsigned int dataAlignment)
|
||||
: numberOfRequests(numRequests),
|
||||
seed(seed.value_or(DEFAULT_SEED)),
|
||||
rwRatio(rwRatio),
|
||||
randomGenerator(this->seed),
|
||||
generatorPeriod(sc_core::sc_time(1.0 / static_cast<double>(clkMhz), sc_core::SC_US)),
|
||||
dataLength(dataLength),
|
||||
dataAlignment(dataAlignment),
|
||||
randomAddressDistribution(minAddress.value_or(DEFAULT_MIN_ADDRESS),
|
||||
maxAddress.value_or((memorySize / dataLength) - 1))
|
||||
maxAddress.value_or((memorySize) - dataLength))
|
||||
{
|
||||
if (minAddress > memorySize - 1)
|
||||
SC_REPORT_FATAL("TrafficGenerator", "minAddress is out of range.");
|
||||
@@ -69,7 +71,11 @@ RandomProducer::RandomProducer(uint64_t numRequests,
|
||||
Request RandomProducer::nextRequest()
|
||||
{
|
||||
Request request;
|
||||
request.address = randomAddressDistribution(randomGenerator) * dataLength;
|
||||
request.address = randomAddressDistribution(randomGenerator);
|
||||
|
||||
// Align address
|
||||
request.address = request.address - (request.address % dataAlignment);
|
||||
|
||||
request.command = readWriteDistribution(randomGenerator) < rwRatio ? Request::Command::Read
|
||||
: Request::Command::Write;
|
||||
request.length = dataLength;
|
||||
|
||||
@@ -50,7 +50,8 @@ public:
|
||||
std::optional<uint64_t> minAddress,
|
||||
std::optional<uint64_t> maxAddress,
|
||||
uint64_t memorySize,
|
||||
unsigned int dataLength);
|
||||
unsigned int dataLength,
|
||||
unsigned int dataAlignment);
|
||||
|
||||
Request nextRequest() override;
|
||||
|
||||
@@ -62,6 +63,7 @@ public:
|
||||
const double rwRatio;
|
||||
const sc_core::sc_time generatorPeriod;
|
||||
const unsigned int dataLength;
|
||||
const unsigned int dataAlignment;
|
||||
|
||||
std::default_random_engine randomGenerator;
|
||||
std::uniform_real_distribution<double> readWriteDistribution{0.0, 1.0};
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
TrafficGenerator::TrafficGenerator(DRAMSys::Config::TrafficGeneratorStateMachine const &config,
|
||||
MemoryManager &memoryManager,
|
||||
uint64_t memorySize,
|
||||
unsigned int dataLength,
|
||||
unsigned int defaultDataLength,
|
||||
std::function<void()> transactionFinished,
|
||||
std::function<void()> terminateInitiator)
|
||||
: consumer(
|
||||
@@ -51,6 +51,9 @@ TrafficGenerator::TrafficGenerator(DRAMSys::Config::TrafficGeneratorStateMachine
|
||||
std::move(terminateInitiator)),
|
||||
stateTransistions(config.transitions)
|
||||
{
|
||||
unsigned int dataLength = config.dataLength.value_or(defaultDataLength);
|
||||
unsigned int dataAlignment = config.dataAlignment.value_or(dataLength);
|
||||
|
||||
for (auto const &state : config.states)
|
||||
{
|
||||
std::visit(
|
||||
@@ -72,7 +75,8 @@ TrafficGenerator::TrafficGenerator(DRAMSys::Config::TrafficGeneratorStateMachine
|
||||
activeState.minAddress,
|
||||
activeState.maxAddress,
|
||||
memorySize,
|
||||
dataLength);
|
||||
dataLength,
|
||||
dataAlignment);
|
||||
|
||||
producers.emplace(activeState.id, std::move(producer));
|
||||
}
|
||||
@@ -105,7 +109,7 @@ TrafficGenerator::TrafficGenerator(DRAMSys::Config::TrafficGeneratorStateMachine
|
||||
TrafficGenerator::TrafficGenerator(DRAMSys::Config::TrafficGenerator const &config,
|
||||
MemoryManager &memoryManager,
|
||||
uint64_t memorySize,
|
||||
unsigned int dataLength,
|
||||
unsigned int defaultDataLength,
|
||||
std::function<void()> transactionFinished,
|
||||
std::function<void()> terminateInitiator)
|
||||
: consumer(
|
||||
@@ -117,6 +121,9 @@ TrafficGenerator::TrafficGenerator(DRAMSys::Config::TrafficGenerator const &conf
|
||||
std::move(transactionFinished),
|
||||
std::move(terminateInitiator))
|
||||
{
|
||||
unsigned int dataLength = config.dataLength.value_or(defaultDataLength);
|
||||
unsigned int dataAlignment = config.dataAlignment.value_or(dataLength);
|
||||
|
||||
if (config.addressDistribution == DRAMSys::Config::AddressDistribution::Random)
|
||||
{
|
||||
auto producer = std::make_unique<RandomProducer>(config.numRequests,
|
||||
@@ -126,7 +133,8 @@ TrafficGenerator::TrafficGenerator(DRAMSys::Config::TrafficGenerator const &conf
|
||||
config.minAddress,
|
||||
config.maxAddress,
|
||||
memorySize,
|
||||
dataLength);
|
||||
dataLength,
|
||||
dataAlignment);
|
||||
producers.emplace(0, std::move(producer));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -49,14 +49,14 @@ public:
|
||||
TrafficGenerator(DRAMSys::Config::TrafficGenerator const &config,
|
||||
MemoryManager &memoryManager,
|
||||
uint64_t memorySize,
|
||||
unsigned int dataLength,
|
||||
unsigned int defaultDataLength,
|
||||
std::function<void()> transactionFinished,
|
||||
std::function<void()> terminateInitiator);
|
||||
|
||||
TrafficGenerator(DRAMSys::Config::TrafficGeneratorStateMachine const &config,
|
||||
MemoryManager &memoryManager,
|
||||
uint64_t memorySize,
|
||||
unsigned int dataLength,
|
||||
unsigned int defaultDataLength,
|
||||
std::function<void()> transactionFinished,
|
||||
std::function<void()> terminateInitiator);
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Technische Universität Kaiserslautern
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Authors:
|
||||
* Lukas Steiner
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "request/Request.h"
|
||||
#include "request/RequestProducer.h"
|
||||
|
||||
class DbiProducer : public RequestProducer
|
||||
{
|
||||
Request nextRequest() override {}
|
||||
uint64_t totalRequests() override {}
|
||||
sc_core::sc_time clkPeriod() override {}
|
||||
};
|
||||
Reference in New Issue
Block a user