From c42866cecb3f70e83bfd37b2d54f04b31902021c Mon Sep 17 00:00:00 2001 From: Derek Christ Date: Fri, 7 Jun 2024 14:33:56 +0200 Subject: [PATCH] Add more example simulations in the benchmarks --- benches/addressdecoder.cpp | 8 ++++---- benches/simulation.cpp | 25 ++++++++++++++++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/benches/addressdecoder.cpp b/benches/addressdecoder.cpp index 594f3e06..193f98ad 100644 --- a/benches/addressdecoder.cpp +++ b/benches/addressdecoder.cpp @@ -49,7 +49,7 @@ static DRAMSys::AddressDecoder addressDecoder() return decoder; } -static void decode(benchmark::State& state) +static void addressdecoder_decode(benchmark::State& state) { auto decoder = addressDecoder(); @@ -61,9 +61,9 @@ static void decode(benchmark::State& state) } } -BENCHMARK(decode); +BENCHMARK(addressdecoder_decode); -static void encode(benchmark::State& state) +static void addressdecoder_encode(benchmark::State& state) { auto decoder = addressDecoder(); @@ -77,4 +77,4 @@ static void encode(benchmark::State& state) } } -BENCHMARK(encode); +BENCHMARK(addressdecoder_encode); diff --git a/benches/simulation.cpp b/benches/simulation.cpp index 4d8ddd55..fd8e025b 100644 --- a/benches/simulation.cpp +++ b/benches/simulation.cpp @@ -37,19 +37,26 @@ #include #include +#include -static void ddr3Simulation(benchmark::State& state) +namespace Simulation { - auto rdbuf = std::cout.rdbuf(nullptr); + +template +static void example_simulation(benchmark::State& state, Args&&... args) +{ + auto args_tuple = std::make_tuple(std::move(args)...); + auto *rdbuf = std::cout.rdbuf(nullptr); for (auto _ : state) { sc_core::sc_get_curr_simcontext()->reset(); - std::filesystem::path configFile("configs/ddr3-example.json"); + std::filesystem::path configFile(std::get<0>(args_tuple)); std::filesystem::path resourceDirectory("configs"); - DRAMSys::Config::Configuration configuration = DRAMSys::Config::from_path(configFile.c_str()); + DRAMSys::Config::Configuration configuration = + DRAMSys::Config::from_path(configFile.c_str()); Simulator simulator(std::move(configuration), std::move(resourceDirectory)); simulator.run(); @@ -58,4 +65,12 @@ static void ddr3Simulation(benchmark::State& state) std::cout.rdbuf(rdbuf); } -BENCHMARK(ddr3Simulation); +BENCHMARK_CAPTURE(example_simulation, ddr3, std::string("configs/ddr3-example.json")); +BENCHMARK_CAPTURE(example_simulation, ddr4, std::string("configs/ddr4-example.json")); +BENCHMARK_CAPTURE(example_simulation, ddr5, std::string("configs/ddr5-example.json")); +BENCHMARK_CAPTURE(example_simulation, lpddr4, std::string("configs/lpddr4-example.json")); +BENCHMARK_CAPTURE(example_simulation, lpddr5, std::string("configs/lpddr5-example.json")); +BENCHMARK_CAPTURE(example_simulation, hbm2, std::string("configs/hbm2-example.json")); +BENCHMARK_CAPTURE(example_simulation, hbm3, std::string("configs/hbm3-example.json")); + +} // namespace Simulation