Remove hard-coded subdirectory paths for configs

Previously, the subdirectories in which the sub-json files were searched
in were hardcoded. Now, DRAMSys simply searches in the directory of the
base config, making this approach more flexible.
This commit is contained in:
2025-04-07 13:26:47 +02:00
parent a97b676b92
commit 939fc90f98
34 changed files with 61 additions and 285 deletions

View File

@@ -46,7 +46,6 @@ namespace DRAMSys::Config
struct AddressMapping
{
static constexpr std::string_view KEY = "addressmapping";
static constexpr std::string_view SUB_DIR = "addressmapping";
using BitEntry = std::variant<unsigned int, std::vector<unsigned int>>;

View File

@@ -36,7 +36,6 @@
#include "DRAMSysConfiguration.h"
#include <fstream>
#include <iostream>
namespace DRAMSys::Config
{
@@ -91,12 +90,10 @@ Configuration from_path(std::filesystem::path baseConfig)
if (event == parse_event_t::value && current_sub_config != SubConfig::Unkown)
{
// Replace name of json file with actual json data
auto parse_json = [&parser_callback, baseDir](std::string_view base_dir,
std::string_view sub_config_key,
auto parse_json = [&parser_callback, baseDir](std::string_view sub_config_key,
const std::string& filename) -> json_t
{
std::filesystem::path path{baseDir};
path /= base_dir;
path /= filename;
std::ifstream json_file(path);
@@ -110,15 +107,15 @@ Configuration from_path(std::filesystem::path baseConfig)
};
if (current_sub_config == SubConfig::MemSpec)
parsed = parse_json(MemSpec::SUB_DIR, MemSpec::KEY, parsed);
parsed = parse_json(MemSpec::KEY, parsed);
else if (current_sub_config == SubConfig::AddressMapping)
parsed = parse_json(AddressMapping::SUB_DIR, AddressMapping::KEY, parsed);
parsed = parse_json(AddressMapping::KEY, parsed);
else if (current_sub_config == SubConfig::McConfig)
parsed = parse_json(McConfig::SUB_DIR, McConfig::KEY, parsed);
parsed = parse_json(McConfig::KEY, parsed);
else if (current_sub_config == SubConfig::SimConfig)
parsed = parse_json(SimConfig::SUB_DIR, SimConfig::KEY, parsed);
parsed = parse_json(SimConfig::KEY, parsed);
else if (current_sub_config == SubConfig::TraceSetup)
parsed = parse_json(TraceSetupConstants::SUB_DIR, TraceSetupConstants::KEY, parsed);
parsed = parse_json(TraceSetupConstants::KEY, parsed);
}
return true;

View File

@@ -170,7 +170,6 @@ NLOHMANN_JSON_SERIALIZE_ENUM(ArbiterType,
struct McConfig
{
static constexpr std::string_view KEY = "mcconfig";
static constexpr std::string_view SUB_DIR = "mcconfig";
std::optional<PagePolicyType> PagePolicy;
std::optional<SchedulerType> Scheduler;

View File

@@ -58,7 +58,6 @@ NLOHMANN_JSON_SERIALIZE_ENUM(StoreModeType,
struct SimConfig
{
static constexpr std::string_view KEY = "simconfig";
static constexpr std::string_view SUB_DIR = "simconfig";
std::optional<uint64_t> AddressOffset;
std::optional<bool> CheckTLM2Protocol;

View File

@@ -205,7 +205,6 @@ NLOHMANN_JSONIFY_ALL_THINGS(RowHammer,
struct TraceSetupConstants
{
static constexpr std::string_view KEY = "tracesetup";
static constexpr std::string_view SUB_DIR = "tracesetup";
};
using Initiator =

View File

@@ -78,12 +78,11 @@ NLOHMANN_JSON_SERIALIZE_ENUM(MemoryType,
{MemoryType::GDDR6, "GDDR6"},
{MemoryType::HBM2, "HBM2"},
{MemoryType::HBM3, "HBM3"},
{MemoryType::STTMRAM, "STTMRAM"}})
{MemoryType::STTMRAM, "STT-MRAM"}})
struct MemSpec
{
static constexpr std::string_view KEY = "memspec";
static constexpr std::string_view SUB_DIR = "memspec";
MemArchitectureSpecType memarchitecturespec;
std::string memoryId;

View File

@@ -103,7 +103,7 @@ Simulator::instantiateInitiator(const DRAMSys::Config::Initiator& initiator)
}
else if constexpr (std::is_same_v<T, DRAMSys::Config::TracePlayer>)
{
std::filesystem::path tracePath = baseConfig.parent_path() / TRACE_DIRECTORY / config.name;
std::filesystem::path tracePath = baseConfig.parent_path() / config.name;
std::optional<StlPlayer::TraceType> traceType;

View File

@@ -41,8 +41,6 @@
#include <DRAMSys/config/DRAMSysConfiguration.h>
#include <DRAMSys/simulation/DRAMSys.h>
static constexpr std::string_view TRACE_DIRECTORY = "traces";
class Simulator
{
public: