From 565e725cf6dbb0a651551a15de71b9abc1ff9405 Mon Sep 17 00:00:00 2001 From: Derek Christ Date: Wed, 7 May 2025 09:13:00 +0200 Subject: [PATCH] Make dataLength parameter required for initiators --- configs/ddr3-example.json | 1 + configs/ddr4-example.json | 1 + configs/ddr4-full-example.json | 1 + configs/hbm2-example.json | 1 + configs/lpddr4-example.json | 1 + configs/stt-mram-example.json | 1 + extensions/configs/ddr5-example.json | 1 + .../configs/ddr5-generator-example.json | 2 + extensions/configs/hbm3-example.json | 1 + extensions/configs/lpddr5-example.json | 1 + src/configuration/DRAMSys/config/TraceSetup.h | 11 ++-- src/simulator/simulator/Simulator.cpp | 13 ++-- .../simulator/generator/TrafficGenerator.cpp | 66 +++++++++---------- .../simulator/generator/TrafficGenerator.h | 7 +- src/simulator/simulator/hammer/RowHammer.cpp | 4 +- src/simulator/simulator/hammer/RowHammer.h | 2 +- src/simulator/simulator/player/StlPlayer.cpp | 9 ++- src/simulator/simulator/player/StlPlayer.h | 7 +- tests/tests_configuration/reference.json | 4 ++ .../test_configuration.cpp | 8 +++ tests/tests_regression/DDR3/ddr3-example.json | 1 + tests/tests_regression/DDR4/ddr4-example.json | 1 + tests/tests_regression/DDR5/ddr5-example.json | 1 + tests/tests_regression/HBM2/hbm2-example.json | 2 + tests/tests_regression/HBM3/hbm3-example.json | 2 + .../LPDDR4/lpddr4-example.json | 1 + .../LPDDR5/lpddr5-example.json | 1 + 27 files changed, 88 insertions(+), 63 deletions(-) diff --git a/configs/ddr3-example.json b/configs/ddr3-example.json index 8be3a4f4..0a265f58 100644 --- a/configs/ddr3-example.json +++ b/configs/ddr3-example.json @@ -9,6 +9,7 @@ { "type": "player", "clkMhz": 800, + "dataLength": 64, "name": "traces/example.stl" } ] diff --git a/configs/ddr4-example.json b/configs/ddr4-example.json index 989a1f3f..998d7f1c 100644 --- a/configs/ddr4-example.json +++ b/configs/ddr4-example.json @@ -9,6 +9,7 @@ { "type": "player", "clkMhz": 200, + "dataLength": 64, "name": "traces/example.stl" } ] diff --git a/configs/ddr4-full-example.json b/configs/ddr4-full-example.json index 45722879..08ad90f6 100644 --- a/configs/ddr4-full-example.json +++ b/configs/ddr4-full-example.json @@ -212,6 +212,7 @@ { "type": "player", "clkMhz": 200, + "dataLength": 64, "name": "traces/example.stl" } ] diff --git a/configs/hbm2-example.json b/configs/hbm2-example.json index b59ffc15..085b7b57 100644 --- a/configs/hbm2-example.json +++ b/configs/hbm2-example.json @@ -9,6 +9,7 @@ { "type": "player", "clkMhz": 1000, + "dataLength": 32, "name": "traces/example.stl" } ] diff --git a/configs/lpddr4-example.json b/configs/lpddr4-example.json index 7b1f8996..5408ecaf 100644 --- a/configs/lpddr4-example.json +++ b/configs/lpddr4-example.json @@ -9,6 +9,7 @@ { "type": "player", "clkMhz": 200, + "dataLength": 32, "name": "traces/example.stl" } ] diff --git a/configs/stt-mram-example.json b/configs/stt-mram-example.json index 8ecf6da2..6537c1ee 100644 --- a/configs/stt-mram-example.json +++ b/configs/stt-mram-example.json @@ -9,6 +9,7 @@ { "type": "player", "clkMhz": 800, + "dataLength": 64, "name": "traces/example.stl" } ] diff --git a/extensions/configs/ddr5-example.json b/extensions/configs/ddr5-example.json index e73395c1..7cbf1a8f 100644 --- a/extensions/configs/ddr5-example.json +++ b/extensions/configs/ddr5-example.json @@ -9,6 +9,7 @@ { "type": "player", "clkMhz": 2000, + "dataLength": 64, "name": "../../configs/traces/example.stl" } ] diff --git a/extensions/configs/ddr5-generator-example.json b/extensions/configs/ddr5-generator-example.json index 1fcfbc3f..874b8e95 100644 --- a/extensions/configs/ddr5-generator-example.json +++ b/extensions/configs/ddr5-generator-example.json @@ -8,6 +8,7 @@ "tracesetup": [ { "clkMhz": 2000, + "dataLength": 64, "type": "generator", "name": "gen0", "numRequests": 2000, @@ -19,6 +20,7 @@ }, { "clkMhz": 2000, + "dataLength": 64, "type": "generator", "name": "gen1", "numRequests": 2000, diff --git a/extensions/configs/hbm3-example.json b/extensions/configs/hbm3-example.json index 7d30ae27..3aae6e96 100644 --- a/extensions/configs/hbm3-example.json +++ b/extensions/configs/hbm3-example.json @@ -8,6 +8,7 @@ "tracesetup": [ { "clkMhz": 2000, + "dataLength": 32, "type": "generator", "name": "gen0", "numRequests": 2000, diff --git a/extensions/configs/lpddr5-example.json b/extensions/configs/lpddr5-example.json index 41878a8f..7f498bd9 100644 --- a/extensions/configs/lpddr5-example.json +++ b/extensions/configs/lpddr5-example.json @@ -9,6 +9,7 @@ { "type": "player", "clkMhz": 200, + "dataLength": 32, "name": "../../configs/traces/example.stl" } ] diff --git a/src/configuration/DRAMSys/config/TraceSetup.h b/src/configuration/DRAMSys/config/TraceSetup.h index 0de42183..c6a809ed 100644 --- a/src/configuration/DRAMSys/config/TraceSetup.h +++ b/src/configuration/DRAMSys/config/TraceSetup.h @@ -79,12 +79,13 @@ struct TracePlayer uint64_t clkMhz{}; std::string name; + unsigned dataLength; std::optional maxPendingReadRequests; std::optional maxPendingWriteRequests; }; NLOHMANN_JSONIFY_ALL_THINGS( - TracePlayer, clkMhz, name, maxPendingReadRequests, maxPendingWriteRequests) + TracePlayer, clkMhz, name, dataLength, maxPendingReadRequests, maxPendingWriteRequests) struct TrafficGeneratorActiveState { @@ -136,7 +137,7 @@ struct TrafficGenerator std::optional seed; std::optional maxTransactions; - std::optional dataLength; + unsigned dataLength; std::optional dataAlignment; uint64_t numRequests{}; @@ -174,7 +175,7 @@ struct TrafficGeneratorStateMachine std::optional seed; std::optional maxTransactions; - std::optional dataLength; + unsigned dataLength; std::optional dataAlignment; std::vector> states; std::vector transitions; @@ -200,7 +201,8 @@ struct RowHammer std::string name; std::optional maxPendingReadRequests; std::optional maxPendingWriteRequests; - + + unsigned dataLength; uint64_t numRequests{}; uint64_t rowIncrement{}; }; @@ -210,6 +212,7 @@ NLOHMANN_JSONIFY_ALL_THINGS(RowHammer, name, maxPendingReadRequests, maxPendingWriteRequests, + dataLength, numRequests, rowIncrement) diff --git a/src/simulator/simulator/Simulator.cpp b/src/simulator/simulator/Simulator.cpp index 86dc0b7d..369548b0 100644 --- a/src/simulator/simulator/Simulator.cpp +++ b/src/simulator/simulator/Simulator.cpp @@ -85,7 +85,6 @@ Simulator::instantiateInitiator(const DRAMSys::Config::Initiator& initiator) { uint64_t memorySize = dramSys->getMemSpec().getSimMemSizeInBytes(); sc_core::sc_time interfaceClk = dramSys->getMemSpec().tCK; - unsigned int defaultDataLength = dramSys->getMemSpec().defaultBytesPerBurst; return std::visit( [=](auto&& config) -> std::unique_ptr @@ -94,8 +93,7 @@ Simulator::instantiateInitiator(const DRAMSys::Config::Initiator& initiator) if constexpr (std::is_same_v || std::is_same_v) { - auto generator = - std::make_unique(config, memorySize, defaultDataLength); + auto generator = std::make_unique(config, memorySize); return std::make_unique(config.name.c_str(), std::move(generator), @@ -124,11 +122,8 @@ Simulator::instantiateInitiator(const DRAMSys::Config::Initiator& initiator) SC_REPORT_FATAL("Simulator", report.c_str()); } - auto player = std::make_unique(tracePath.c_str(), - config.clkMhz, - defaultDataLength, - *traceType, - storageEnabled); + auto player = std::make_unique( + config, tracePath.c_str(), *traceType, storageEnabled); return std::make_unique(config.name.c_str(), std::move(player), @@ -141,7 +136,7 @@ Simulator::instantiateInitiator(const DRAMSys::Config::Initiator& initiator) } else if constexpr (std::is_same_v) { - auto hammer = std::make_unique(config, defaultDataLength); + auto hammer = std::make_unique(config); return std::make_unique(config.name.c_str(), std::move(hammer), diff --git a/src/simulator/simulator/generator/TrafficGenerator.cpp b/src/simulator/simulator/generator/TrafficGenerator.cpp index 92f33a7d..dc36c37c 100644 --- a/src/simulator/simulator/generator/TrafficGenerator.cpp +++ b/src/simulator/simulator/generator/TrafficGenerator.cpp @@ -39,12 +39,11 @@ #include "SequentialState.h" TrafficGenerator::TrafficGenerator(DRAMSys::Config::TrafficGeneratorStateMachine const& config, - uint64_t memorySize, - unsigned int defaultDataLength) : + uint64_t memorySize) : stateTransistions(config.transitions), generatorPeriod(sc_core::sc_time(1.0 / static_cast(config.clkMhz), sc_core::SC_US)) { - unsigned int dataLength = config.dataLength.value_or(defaultDataLength); + unsigned int dataLength = config.dataLength; unsigned int dataAlignment = config.dataAlignment.value_or(dataLength); for (auto const& state : config.states) @@ -62,13 +61,13 @@ TrafficGenerator::TrafficGenerator(DRAMSys::Config::TrafficGeneratorStateMachine DRAMSys::Config::AddressDistribution::Random) { auto producer = std::make_unique(activeState.numRequests, - config.seed.value_or(0), - activeState.rwRatio, - activeState.minAddress, - activeState.maxAddress, - memorySize, - dataLength, - dataAlignment); + config.seed.value_or(0), + activeState.rwRatio, + activeState.minAddress, + activeState.maxAddress, + memorySize, + dataLength, + dataAlignment); producers.emplace(activeState.id, std::move(producer)); } @@ -76,13 +75,13 @@ TrafficGenerator::TrafficGenerator(DRAMSys::Config::TrafficGeneratorStateMachine { auto producer = std::make_unique(activeState.numRequests, - config.seed.value_or(0), - activeState.rwRatio, - activeState.addressIncrement, - activeState.minAddress, - activeState.maxAddress, - memorySize, - dataLength); + config.seed.value_or(0), + activeState.rwRatio, + activeState.addressIncrement, + activeState.minAddress, + activeState.maxAddress, + memorySize, + dataLength); producers.emplace(activeState.id, std::move(producer)); } @@ -98,35 +97,34 @@ TrafficGenerator::TrafficGenerator(DRAMSys::Config::TrafficGeneratorStateMachine } TrafficGenerator::TrafficGenerator(DRAMSys::Config::TrafficGenerator const& config, - uint64_t memorySize, - unsigned int defaultDataLength) : + uint64_t memorySize) : generatorPeriod(sc_core::sc_time(1.0 / static_cast(config.clkMhz), sc_core::SC_US)) { - unsigned int dataLength = config.dataLength.value_or(defaultDataLength); + unsigned int dataLength = config.dataLength; unsigned int dataAlignment = config.dataAlignment.value_or(dataLength); if (config.addressDistribution == DRAMSys::Config::AddressDistribution::Random) { auto producer = std::make_unique(config.numRequests, - config.seed.value_or(0), - config.rwRatio, - config.minAddress, - config.maxAddress, - memorySize, - dataLength, - dataAlignment); + config.seed.value_or(0), + config.rwRatio, + config.minAddress, + config.maxAddress, + memorySize, + dataLength, + dataAlignment); producers.emplace(0, std::move(producer)); } else { auto producer = std::make_unique(config.numRequests, - config.seed.value_or(0), - config.rwRatio, - config.addressIncrement, - config.minAddress, - config.maxAddress, - memorySize, - dataLength); + config.seed.value_or(0), + config.rwRatio, + config.addressIncrement, + config.minAddress, + config.maxAddress, + memorySize, + dataLength); producers.emplace(0, std::move(producer)); } } diff --git a/src/simulator/simulator/generator/TrafficGenerator.h b/src/simulator/simulator/generator/TrafficGenerator.h index 466cb42c..5a6602b3 100644 --- a/src/simulator/simulator/generator/TrafficGenerator.h +++ b/src/simulator/simulator/generator/TrafficGenerator.h @@ -47,13 +47,10 @@ class RequestProducer; class TrafficGenerator : public RequestProducer { public: - TrafficGenerator(DRAMSys::Config::TrafficGenerator const& config, - uint64_t memorySize, - unsigned int defaultDataLength); + TrafficGenerator(DRAMSys::Config::TrafficGenerator const& config, uint64_t memorySize); TrafficGenerator(DRAMSys::Config::TrafficGeneratorStateMachine const& config, - uint64_t memorySize, - unsigned int defaultDataLength); + uint64_t memorySize); uint64_t totalRequests() override; Request nextRequest() override; diff --git a/src/simulator/simulator/hammer/RowHammer.cpp b/src/simulator/simulator/hammer/RowHammer.cpp index d65a8fef..4dbf9825 100644 --- a/src/simulator/simulator/hammer/RowHammer.cpp +++ b/src/simulator/simulator/hammer/RowHammer.cpp @@ -35,11 +35,11 @@ #include "RowHammer.h" -RowHammer::RowHammer(DRAMSys::Config::RowHammer const& config, unsigned int dataLength) : +RowHammer::RowHammer(DRAMSys::Config::RowHammer const& config) : generatorPeriod(sc_core::sc_time(1.0 / static_cast(config.clkMhz), sc_core::SC_US)), numberOfRequests(config.numRequests), rowIncrement(config.rowIncrement), - dataLength(dataLength) + dataLength(config.dataLength) { } diff --git a/src/simulator/simulator/hammer/RowHammer.h b/src/simulator/simulator/hammer/RowHammer.h index 1d75b6e9..2c83b797 100644 --- a/src/simulator/simulator/hammer/RowHammer.h +++ b/src/simulator/simulator/hammer/RowHammer.h @@ -44,7 +44,7 @@ class RowHammer : public RequestProducer { public: - RowHammer(DRAMSys::Config::RowHammer const& config, unsigned int dataLength); + RowHammer(DRAMSys::Config::RowHammer const& config); Request nextRequest() override; sc_core::sc_time nextTrigger() override { return generatorPeriod; } diff --git a/src/simulator/simulator/player/StlPlayer.cpp b/src/simulator/simulator/player/StlPlayer.cpp index c96cafa9..e823d6d6 100644 --- a/src/simulator/simulator/player/StlPlayer.cpp +++ b/src/simulator/simulator/player/StlPlayer.cpp @@ -44,15 +44,14 @@ static constexpr std::size_t LINE_BUFFER_SIZE = 10000; -StlPlayer::StlPlayer(std::filesystem::path const& trace, - unsigned int clkMhz, - unsigned int defaultDataLength, +StlPlayer::StlPlayer(DRAMSys::Config::TracePlayer const& config, + std::filesystem::path const& trace, TraceType traceType, bool storageEnabled) : traceType(traceType), storageEnabled(storageEnabled), - playerPeriod(sc_core::sc_time(1.0 / static_cast(clkMhz), sc_core::SC_US)), - defaultDataLength(defaultDataLength), + playerPeriod(sc_core::sc_time(1.0 / static_cast(config.clkMhz), sc_core::SC_US)), + defaultDataLength(config.dataLength), traceFile(trace) { if (!traceFile.is_open()) diff --git a/src/simulator/simulator/player/StlPlayer.h b/src/simulator/simulator/player/StlPlayer.h index 28d887e1..53f567fd 100644 --- a/src/simulator/simulator/player/StlPlayer.h +++ b/src/simulator/simulator/player/StlPlayer.h @@ -42,6 +42,8 @@ #include "simulator/request/RequestProducer.h" +#include + #include #include @@ -61,9 +63,8 @@ public: Relative, }; - StlPlayer(std::filesystem::path const& trace, - unsigned int clkMhz, - unsigned int defaultDataLength, + StlPlayer(DRAMSys::Config::TracePlayer const& config, + std::filesystem::path const& trace, TraceType traceType, bool storageEnabled); diff --git a/tests/tests_configuration/reference.json b/tests/tests_configuration/reference.json index b61019a6..90b80bb9 100644 --- a/tests/tests_configuration/reference.json +++ b/tests/tests_configuration/reference.json @@ -215,6 +215,7 @@ { "type": "player", "clkMhz": 100, + "dataLength": 64, "name": "mytrace.stl" }, { @@ -222,12 +223,14 @@ "addressDistribution": "random", "clkMhz": 100, "name": "MyTestGen", + "dataLength": 64, "numRequests": 1000, "rwRatio": 0.5 }, { "type": "statemachine", "clkMhz": 100, + "dataLength": 64, "maxPendingReadRequests": 8, "name": "MyTestGen", "states": [ @@ -260,6 +263,7 @@ { "type": "rowhammer", "clkMhz": 100, + "dataLength": 64, "name": "MyTestHammer", "numRequests": 4000, "rowIncrement": 2097152 diff --git a/tests/tests_configuration/test_configuration.cpp b/tests/tests_configuration/test_configuration.cpp index 2d8d138e..959267ef 100644 --- a/tests/tests_configuration/test_configuration.cpp +++ b/tests/tests_configuration/test_configuration.cpp @@ -318,6 +318,7 @@ DRAMSys::Config::TracePlayer ConfigurationTest::createTracePlayer() { DRAMSys::Config::TracePlayer player; player.clkMhz = 100; + player.dataLength = 64; player.name = "mytrace.stl"; return player; @@ -327,6 +328,7 @@ DRAMSys::Config::TrafficGenerator ConfigurationTest::createTraceGeneratorOneStat { DRAMSys::Config::TrafficGenerator gen; gen.clkMhz = 100; + gen.dataLength = 64; gen.name = "MyTestGen"; gen.numRequests = 1000; @@ -345,6 +347,7 @@ ConfigurationTest::createTraceGeneratorMultipleStates() DRAMSys::Config::TrafficGeneratorStateMachine gen; gen.clkMhz = 100; + gen.dataLength = 64; gen.name = "MyTestGen"; gen.maxPendingReadRequests = 8; @@ -381,6 +384,7 @@ DRAMSys::Config::RowHammer ConfigurationTest::createTraceHammer() DRAMSys::Config::RowHammer hammer; hammer.clkMhz = 100; + hammer.dataLength = 64; hammer.name = "MyTestHammer"; hammer.numRequests = 4000; hammer.rowIncrement = 2097152; @@ -720,12 +724,14 @@ TEST_F(ConfigurationTest, TraceSetup) { "type": "player", "clkMhz": 100, + "dataLength": 64, "name": "mytrace.stl" }, { "type": "generator", "addressDistribution": "random", "clkMhz": 100, + "dataLength": 64, "name": "MyTestGen", "numRequests": 1000, "rwRatio": 0.5 @@ -733,6 +739,7 @@ TEST_F(ConfigurationTest, TraceSetup) { "type": "statemachine", "clkMhz": 100, + "dataLength": 64, "maxPendingReadRequests": 8, "name": "MyTestGen", "states": [ @@ -765,6 +772,7 @@ TEST_F(ConfigurationTest, TraceSetup) { "type": "rowhammer", "clkMhz": 100, + "dataLength": 64, "name": "MyTestHammer", "numRequests": 4000, "rowIncrement": 2097152 diff --git a/tests/tests_regression/DDR3/ddr3-example.json b/tests/tests_regression/DDR3/ddr3-example.json index 0d201661..fead0578 100644 --- a/tests/tests_regression/DDR3/ddr3-example.json +++ b/tests/tests_regression/DDR3/ddr3-example.json @@ -137,6 +137,7 @@ { "type": "player", "clkMhz": 533, + "dataLength": 64, "name": "traces/trace_test2.stl" } ] diff --git a/tests/tests_regression/DDR4/ddr4-example.json b/tests/tests_regression/DDR4/ddr4-example.json index fd26fc30..88f82348 100644 --- a/tests/tests_regression/DDR4/ddr4-example.json +++ b/tests/tests_regression/DDR4/ddr4-example.json @@ -213,6 +213,7 @@ { "type": "player", "clkMhz": 933, + "dataLength": 64, "name": "traces/trace_test3.stl" } ] diff --git a/tests/tests_regression/DDR5/ddr5-example.json b/tests/tests_regression/DDR5/ddr5-example.json index 49e91043..0a6d353a 100644 --- a/tests/tests_regression/DDR5/ddr5-example.json +++ b/tests/tests_regression/DDR5/ddr5-example.json @@ -220,6 +220,7 @@ { "type": "player", "clkMhz": 1600, + "dataLength": 64, "name": "traces/trace_test3.stl" } ] diff --git a/tests/tests_regression/HBM2/hbm2-example.json b/tests/tests_regression/HBM2/hbm2-example.json index f0494361..9a548aab 100644 --- a/tests/tests_regression/HBM2/hbm2-example.json +++ b/tests/tests_regression/HBM2/hbm2-example.json @@ -128,11 +128,13 @@ { "type": "player", "clkMhz": 1000, + "dataLength": 64, "name": "traces/trace1_test4.stl" }, { "type": "player", "clkMhz": 1000, + "dataLength": 64, "name": "traces/trace2_test4.stl" } ] diff --git a/tests/tests_regression/HBM3/hbm3-example.json b/tests/tests_regression/HBM3/hbm3-example.json index 238bb66e..b7e0f8e1 100644 --- a/tests/tests_regression/HBM3/hbm3-example.json +++ b/tests/tests_regression/HBM3/hbm3-example.json @@ -131,11 +131,13 @@ { "type": "player", "clkMhz": 1600, + "dataLength": 32, "name": "traces/trace1_test4.stl" }, { "type": "player", "clkMhz": 1600, + "dataLength": 32, "name": "traces/trace2_test4.stl" } ] diff --git a/tests/tests_regression/LPDDR4/lpddr4-example.json b/tests/tests_regression/LPDDR4/lpddr4-example.json index f44abaee..500908b7 100644 --- a/tests/tests_regression/LPDDR4/lpddr4-example.json +++ b/tests/tests_regression/LPDDR4/lpddr4-example.json @@ -183,6 +183,7 @@ { "type": "player", "clkMhz": 1600, + "dataLength": 32, "name": "traces/trace_lpddr4.stl" } ] diff --git a/tests/tests_regression/LPDDR5/lpddr5-example.json b/tests/tests_regression/LPDDR5/lpddr5-example.json index 53da1716..348426d6 100644 --- a/tests/tests_regression/LPDDR5/lpddr5-example.json +++ b/tests/tests_regression/LPDDR5/lpddr5-example.json @@ -205,6 +205,7 @@ { "type": "player", "clkMhz": 1600, + "dataLength": 32, "name": "traces/trace_lpddr5.stl" } ]