Introduce a common json configuration library
This new configuration library is capable of parsing DRAMSys config jsons and generating them. The "Configuration" struct contains the complete configuration required for simulation. The library will be used in future in DRAMSys itself and also in the TracePlayer, gem5 player, TraceAnalyzer and all other tools that use DRAMSys as a library.
This commit is contained in:
@@ -44,9 +44,8 @@ set(DCMAKE_SH="CMAKE_SH-NOTFOUND")
|
||||
# Add DRAMPower:
|
||||
add_subdirectory(src/common/third_party/DRAMPower)
|
||||
|
||||
# Add nlohmann:
|
||||
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
||||
add_subdirectory(src/common/third_party/nlohmann)
|
||||
# Add Configuration
|
||||
add_subdirectory(src/common/configuration)
|
||||
|
||||
# Add SystemC:
|
||||
if(DEFINED ENV{SYSTEMC_HOME})
|
||||
|
||||
87
DRAMSys/library/src/common/configuration/AddressMapping.cpp
Normal file
87
DRAMSys/library/src/common/configuration/AddressMapping.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#include "AddressMapping.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
|
||||
void to_json(json &j, const AddressMapping &m)
|
||||
{
|
||||
json congen = json{};
|
||||
|
||||
congen = json{{"BYTE_BIT", m.byteBits},
|
||||
{"COLUMN_BIT", m.coloumnBits},
|
||||
{"BANKGROUP_BIT", m.bankGroupBits},
|
||||
{"BANK_BIT", m.bankBits},
|
||||
{"ROW_BIT", m.rowBits}};
|
||||
|
||||
Util::from_optional("CHANNEL_BIT", congen, m.channelBits);
|
||||
Util::from_optional("BYTE_BIT", congen, m.byteBits);
|
||||
Util::from_optional("BANKGROUP_BIT", congen, m.bankGroupBits);
|
||||
Util::from_optional("XOR", congen, m.xorBits);
|
||||
|
||||
j["CONGEN"] = congen;
|
||||
}
|
||||
|
||||
void from_json(const json &j, AddressMapping &m)
|
||||
{
|
||||
json congen = j.at("CONGEN");
|
||||
|
||||
congen.at("COLUMN_BIT").get_to(m.coloumnBits);
|
||||
congen.at("BANK_BIT").get_to(m.bankBits);
|
||||
congen.at("ROW_BIT").get_to(m.rowBits);
|
||||
|
||||
Util::get_optional("CHANNEL_BIT", congen, m.channelBits);
|
||||
Util::get_optional("BYTE_BIT", congen, m.byteBits);
|
||||
Util::get_optional("BANKGROUP_BIT", congen, m.bankGroupBits);
|
||||
Util::get_optional("XOR", congen, m.xorBits);
|
||||
}
|
||||
|
||||
void to_json(json &j, const XorPair &x)
|
||||
{
|
||||
j = json{{"FIRST", x.first}, {"SECOND", x.second}};
|
||||
}
|
||||
|
||||
void from_json(const json &j, XorPair &x)
|
||||
{
|
||||
j.at("FIRST").get_to(x.first);
|
||||
j.at("SECOND").get_to(x.second);
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
71
DRAMSys/library/src/common/configuration/AddressMapping.h
Normal file
71
DRAMSys/library/src/common/configuration/AddressMapping.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#ifndef ADDRESSMAPPING_H
|
||||
#define ADDRESSMAPPING_H
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
struct XorPair
|
||||
{
|
||||
unsigned int first;
|
||||
unsigned int second;
|
||||
};
|
||||
|
||||
void to_json(json &j, const XorPair &x);
|
||||
void from_json(const json &j, XorPair &x);
|
||||
|
||||
struct AddressMapping
|
||||
{
|
||||
std::pair<std::unordered_set<unsigned int>, bool> byteBits;
|
||||
std::unordered_set<unsigned int> coloumnBits;
|
||||
std::unordered_set<unsigned int> bankBits;
|
||||
std::pair<std::unordered_set<unsigned int>, bool> bankGroupBits;
|
||||
std::unordered_set<unsigned int> rowBits;
|
||||
std::pair<std::unordered_set<unsigned int>, bool> channelBits;
|
||||
std::pair<std::vector<XorPair>, bool> xorBits;
|
||||
};
|
||||
|
||||
void to_json(json &j, const AddressMapping &m);
|
||||
void from_json(const json &j, AddressMapping &m);
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
#endif // ADDRESSMAPPING_H
|
||||
57
DRAMSys/library/src/common/configuration/CMakeLists.txt
Normal file
57
DRAMSys/library/src/common/configuration/CMakeLists.txt
Normal file
@@ -0,0 +1,57 @@
|
||||
# Copyright (c) 2021, 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:
|
||||
# Derek Christ
|
||||
|
||||
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/library/src/common/third_party/nlohmann ${CMAKE_CURRENT_BINARY_DIR}/nlohmann)
|
||||
|
||||
option(DRAMSYS_CONFIGURATION_TESTS "Build the unit tests for configuration." OFF)
|
||||
|
||||
if (DRAMSYS_CONFIGURATION_TESTS)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
|
||||
endif()
|
||||
|
||||
add_library(DRAMSysConfiguration STATIC
|
||||
Configuration.cpp
|
||||
AddressMapping.cpp
|
||||
McConfig.cpp
|
||||
SimConfig.cpp
|
||||
ThermalConfig.cpp
|
||||
TraceSetup.cpp
|
||||
memspec/MemSpec.cpp
|
||||
memspec/MemArchitectureSpec.cpp
|
||||
memspec/MemPowerSpec.cpp
|
||||
memspec/MemTimingSpec.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(DRAMSysConfiguration PRIVATE nlohmann_json::nlohmann_json)
|
||||
target_include_directories(DRAMSysConfiguration PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
68
DRAMSys/library/src/common/configuration/Configuration.cpp
Normal file
68
DRAMSys/library/src/common/configuration/Configuration.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#include "Configuration.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
|
||||
void to_json(json &j, const Configuration &c)
|
||||
{
|
||||
j = json{{"addressmapping", c.addressMapping},
|
||||
{"mcconfig", c.mcConfig},
|
||||
{"memspec", c.memSpec},
|
||||
{"simulationid", c.simulationId},
|
||||
{"simconfig", c.simConfig}};
|
||||
|
||||
Util::from_optional("thermalconfig", j, c.thermalConfig);
|
||||
Util::from_optional("tracesetup", j, c.traceSetup);
|
||||
}
|
||||
|
||||
void from_json(const json &j, Configuration &c)
|
||||
{
|
||||
j.at("addressmapping").get_to(c.addressMapping);
|
||||
j.at("mcconfig").get_to(c.mcConfig);
|
||||
j.at("memspec").get_to(c.memSpec);
|
||||
j.at("simulationid").get_to(c.simulationId);
|
||||
j.at("simconfig").get_to(c.simConfig);
|
||||
|
||||
Util::get_optional("thermalconfig", j, c.thermalConfig);
|
||||
Util::get_optional("tracesetup", j, c.traceSetup);
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
80
DRAMSys/library/src/common/configuration/Configuration.h
Normal file
80
DRAMSys/library/src/common/configuration/Configuration.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#ifndef CONFIGURATION_H
|
||||
#define CONFIGURATION_H
|
||||
|
||||
#include "AddressMapping.h"
|
||||
#include "McConfig.h"
|
||||
#include "SimConfig.h"
|
||||
#include "ThermalConfig.h"
|
||||
#include "TraceSetup.h"
|
||||
#include "memspec/MemSpec.h"
|
||||
|
||||
#include <memory>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* To support polymorphic configurations, a Json "type" tag is used
|
||||
* to determine the correct type before further parsing.
|
||||
*
|
||||
* To support optional values, std::pair is used. The first parameter is the value,
|
||||
* the second parameter specifies if the value is valid.
|
||||
* Replace with std::optional when this project is updated to C++17.
|
||||
* Consider also switching to std::variant to achieve static polymorphism.
|
||||
*/
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
struct Configuration
|
||||
{
|
||||
AddressMapping addressMapping;
|
||||
McConfig mcConfig;
|
||||
MemSpec memSpec;
|
||||
SimConfig simConfig;
|
||||
std::string simulationId;
|
||||
std::pair<ThermalConfig, bool> thermalConfig;
|
||||
std::pair<TraceSetup, bool> traceSetup;
|
||||
};
|
||||
|
||||
void to_json(json &j, const Configuration &p);
|
||||
void from_json(const json &j, Configuration &p);
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
#endif // CONFIGURATION_H
|
||||
78
DRAMSys/library/src/common/configuration/McConfig.cpp
Normal file
78
DRAMSys/library/src/common/configuration/McConfig.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#include "McConfig.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
|
||||
void to_json(json &j, const McConfig &c)
|
||||
{
|
||||
j = json{{"PagePolicy", c.pagePolicy},
|
||||
{"Scheduler", c.scheduler},
|
||||
{"SchedulerBuffer", c.schedulerBuffer},
|
||||
{"RequestBufferSize", c.requestBufferSize},
|
||||
{"CmdMux", c.cmdMux},
|
||||
{"RespQueue", c.respQueue},
|
||||
{"RefreshPolicy", c.refreshPolicy},
|
||||
{"RefreshMaxPostponed", c.refreshMaxPostponed},
|
||||
{"RefreshMaxPulledin", c.refreshMaxPulledin},
|
||||
{"PowerDownPolicy", c.powerDownPolicy},
|
||||
{"Arbiter", c.arbiter},
|
||||
{"MaxActiveTransactions", c.maxActiveTransactions}};
|
||||
|
||||
Util::from_optional("RefreshManagment", j, c.refreshManagement);
|
||||
}
|
||||
|
||||
void from_json(const json &j, McConfig &c)
|
||||
{
|
||||
j.at("PagePolicy").get_to(c.pagePolicy);
|
||||
j.at("Scheduler").get_to(c.scheduler);
|
||||
j.at("SchedulerBuffer").get_to(c.schedulerBuffer);
|
||||
j.at("RequestBufferSize").get_to(c.requestBufferSize);
|
||||
j.at("CmdMux").get_to(c.cmdMux);
|
||||
j.at("RespQueue").get_to(c.respQueue);
|
||||
j.at("RefreshPolicy").get_to(c.refreshPolicy);
|
||||
j.at("RefreshMaxPostponed").get_to(c.refreshMaxPostponed);
|
||||
j.at("RefreshMaxPulledin").get_to(c.refreshMaxPulledin);
|
||||
j.at("PowerDownPolicy").get_to(c.powerDownPolicy);
|
||||
j.at("Arbiter").get_to(c.arbiter);
|
||||
j.at("MaxActiveTransactions").get_to(c.maxActiveTransactions);
|
||||
|
||||
Util::get_optional("RefreshManagment", j, c.refreshManagement);
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
171
DRAMSys/library/src/common/configuration/McConfig.h
Normal file
171
DRAMSys/library/src/common/configuration/McConfig.h
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#ifndef MCCONFIG_H
|
||||
#define MCCONFIG_H
|
||||
|
||||
#include <memory>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
enum class PagePolicy
|
||||
{
|
||||
Open,
|
||||
OpenAdaptive,
|
||||
Closed,
|
||||
ClosedAdaptive,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(PagePolicy, {
|
||||
{PagePolicy::Invalid, nullptr},
|
||||
{PagePolicy::Open, "Open"},
|
||||
{PagePolicy::OpenAdaptive, "OpenAdaptive"},
|
||||
{PagePolicy::Closed, "Closed"},
|
||||
{PagePolicy::ClosedAdaptive, "ClosedAdaptive"},
|
||||
})
|
||||
|
||||
enum class Scheduler
|
||||
{
|
||||
Fifo,
|
||||
FrFcfs,
|
||||
FrFcfsGrp,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(Scheduler, {{Scheduler::Invalid, nullptr},
|
||||
{Scheduler::Fifo, "Fifo"},
|
||||
{Scheduler::FrFcfs, "FrFcfs"},
|
||||
{Scheduler::FrFcfsGrp, "FrFcfsGrp"}})
|
||||
|
||||
enum class SchedulerBuffer
|
||||
{
|
||||
Bankwise,
|
||||
ReadWrite,
|
||||
Shared,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(SchedulerBuffer, {{SchedulerBuffer::Invalid, nullptr},
|
||||
{SchedulerBuffer::Bankwise, "Bankwise"},
|
||||
{SchedulerBuffer::ReadWrite, "ReadWrite"},
|
||||
{SchedulerBuffer::Shared, "Shared"}})
|
||||
|
||||
enum class CmdMux
|
||||
{
|
||||
Oldest,
|
||||
Strict,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(CmdMux,
|
||||
{{CmdMux::Invalid, nullptr}, {CmdMux::Oldest, "Oldest"}, {CmdMux::Strict, "Strict"}})
|
||||
|
||||
enum class RespQueue
|
||||
{
|
||||
Fifo,
|
||||
Reorder,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(RespQueue, {{RespQueue::Invalid, nullptr},
|
||||
{RespQueue::Fifo, "Fifo"},
|
||||
{RespQueue::Reorder, "Reorder"}})
|
||||
|
||||
enum class RefreshPolicy
|
||||
{
|
||||
NoRefresh,
|
||||
AllBank,
|
||||
PerBank,
|
||||
SameBank,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(RefreshPolicy, {{RefreshPolicy::Invalid, nullptr},
|
||||
{RefreshPolicy::AllBank, "AllBank"},
|
||||
{RefreshPolicy::PerBank, "PerBank"},
|
||||
{RefreshPolicy::SameBank, "SameBank"}})
|
||||
|
||||
enum class PowerDownPolicy
|
||||
{
|
||||
NoPowerDown,
|
||||
Staggered,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(PowerDownPolicy, {{PowerDownPolicy::Invalid, nullptr},
|
||||
{PowerDownPolicy::NoPowerDown, "NoPowerDown"},
|
||||
{PowerDownPolicy::Staggered, "Staggered"}})
|
||||
|
||||
enum class Arbiter
|
||||
{
|
||||
Simple,
|
||||
Fifo,
|
||||
Reorder,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(Arbiter, {{Arbiter::Invalid, nullptr},
|
||||
{Arbiter::Simple, "Simple"},
|
||||
{Arbiter::Fifo, "Fifo"},
|
||||
{Arbiter::Reorder, "Reorder"}})
|
||||
|
||||
struct McConfig
|
||||
{
|
||||
PagePolicy pagePolicy;
|
||||
Scheduler scheduler;
|
||||
SchedulerBuffer schedulerBuffer;
|
||||
unsigned int requestBufferSize;
|
||||
CmdMux cmdMux;
|
||||
RespQueue respQueue;
|
||||
RefreshPolicy refreshPolicy;
|
||||
unsigned int refreshMaxPostponed;
|
||||
unsigned int refreshMaxPulledin;
|
||||
PowerDownPolicy powerDownPolicy;
|
||||
Arbiter arbiter;
|
||||
unsigned int maxActiveTransactions;
|
||||
std::pair<bool, bool> refreshManagement;
|
||||
};
|
||||
|
||||
void to_json(json &j, const McConfig &c);
|
||||
void from_json(const json &j, McConfig &c);
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
#endif // MCCONFIG_H
|
||||
79
DRAMSys/library/src/common/configuration/SimConfig.cpp
Normal file
79
DRAMSys/library/src/common/configuration/SimConfig.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#include "SimConfig.h"
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
|
||||
void to_json(json &j, const SimConfig &c)
|
||||
{
|
||||
j = json{{"AddressOffset", c.addressOffset},
|
||||
{"CheckTLM2Protocol", c.checkTLM2Protocol},
|
||||
{"DatabaseRecording", c.databaseRecording},
|
||||
{"Debug", c.debug},
|
||||
{"ECCControllerMode", c.eccControllerMode},
|
||||
{"EnableWindowing", c.enableWindowing},
|
||||
{"ErrorCSVFile", c.errorCsvFile},
|
||||
{"ErrorChipSeed", c.errorChipSeed},
|
||||
{"PowerAnalysis", c.powerAnalysis},
|
||||
{"SimulationName", c.simulationName},
|
||||
{"SimulationProgressBar", c.simulationProgressBar},
|
||||
{"StoreMode", c.storeMode},
|
||||
{"ThermalSimulation", c.thermalSimulation},
|
||||
{"UseMalloc", c.useMalloc},
|
||||
{"WindowSize", c.windowSize}};
|
||||
}
|
||||
|
||||
void from_json(const json &j, SimConfig &c)
|
||||
{
|
||||
j.at("AddressOffset").get_to(c.addressOffset);
|
||||
j.at("CheckTLM2Protocol").get_to(c.checkTLM2Protocol);
|
||||
j.at("DatabaseRecording").get_to(c.databaseRecording);
|
||||
j.at("Debug").get_to(c.debug);
|
||||
j.at("ECCControllerMode").get_to(c.eccControllerMode);
|
||||
j.at("EnableWindowing").get_to(c.enableWindowing);
|
||||
j.at("ErrorCSVFile").get_to(c.errorCsvFile);
|
||||
j.at("ErrorChipSeed").get_to(c.errorChipSeed);
|
||||
j.at("PowerAnalysis").get_to(c.powerAnalysis);
|
||||
j.at("SimulationName").get_to(c.simulationName);
|
||||
j.at("SimulationProgressBar").get_to(c.simulationProgressBar);
|
||||
j.at("StoreMode").get_to(c.storeMode);
|
||||
j.at("ThermalSimulation").get_to(c.thermalSimulation);
|
||||
j.at("UseMalloc").get_to(c.useMalloc);
|
||||
j.at("WindowSize").get_to(c.windowSize);
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
92
DRAMSys/library/src/common/configuration/SimConfig.h
Normal file
92
DRAMSys/library/src/common/configuration/SimConfig.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#ifndef SIMCONFIG_H
|
||||
#define SIMCONFIG_H
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
enum class ECCControllerMode
|
||||
{
|
||||
Disabled,
|
||||
Hamming,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(ECCControllerMode, {{ECCControllerMode::Invalid, nullptr},
|
||||
{ECCControllerMode::Disabled, "Disabled"},
|
||||
{ECCControllerMode::Hamming, "Hamming"}})
|
||||
|
||||
enum class StoreMode
|
||||
{
|
||||
NoStorage,
|
||||
Store,
|
||||
ErrorModel,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(StoreMode, {{StoreMode::Invalid, nullptr},
|
||||
{StoreMode::Store, "Store"},
|
||||
{StoreMode::ErrorModel, "ErrorModel"}})
|
||||
|
||||
struct SimConfig
|
||||
{
|
||||
unsigned int addressOffset;
|
||||
bool checkTLM2Protocol;
|
||||
bool databaseRecording;
|
||||
bool debug;
|
||||
ECCControllerMode eccControllerMode;
|
||||
bool enableWindowing;
|
||||
std::string errorCsvFile;
|
||||
unsigned int errorChipSeed;
|
||||
bool powerAnalysis;
|
||||
std::string simulationName;
|
||||
bool simulationProgressBar;
|
||||
StoreMode storeMode;
|
||||
bool thermalSimulation;
|
||||
bool useMalloc;
|
||||
unsigned int windowSize;
|
||||
};
|
||||
|
||||
void to_json(json &j, const SimConfig &c);
|
||||
void from_json(const json &j, SimConfig &c);
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
#endif
|
||||
98
DRAMSys/library/src/common/configuration/ThermalConfig.cpp
Normal file
98
DRAMSys/library/src/common/configuration/ThermalConfig.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#include "ThermalConfig.h"
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
|
||||
void to_json(json &j, const ThermalConfig &c)
|
||||
{
|
||||
j = json{{"TemperatureScale", c.temperatureScale},
|
||||
{"StaticTemperatureDefaultValue", c.staticTemperatureDefaultValue},
|
||||
{"ThermalSimPeriod", c.thermalSimPeriod},
|
||||
{"ThermalSimUnit", c.thermalSimUnit},
|
||||
{"PowerInfoFile", c.powerInfo},
|
||||
{"IceServerIp", c.iceServerIp},
|
||||
{"IceServerPort", c.iceServerPort},
|
||||
{"SimPeriodAdjustFactor", c.simPeriodAdjustFactor},
|
||||
{"NPowStableCyclesToIncreasePeriod", c.nPowStableCyclesToIncreasePeriod},
|
||||
{"GenerateTemperatureMap", c.generateTemperatureMap},
|
||||
{"GeneratePowerMap", c.generatePowerMap}};
|
||||
}
|
||||
|
||||
void from_json(const json &j, ThermalConfig &c)
|
||||
{
|
||||
j.at("TemperatureScale").get_to(c.temperatureScale);
|
||||
j.at("StaticTemperatureDefaultValue").get_to(c.staticTemperatureDefaultValue);
|
||||
j.at("ThermalSimPeriod").get_to(c.thermalSimPeriod);
|
||||
j.at("ThermalSimUnit").get_to(c.thermalSimUnit);
|
||||
j.at("PowerInfoFile").get_to(c.powerInfo);
|
||||
j.at("IceServerIp").get_to(c.iceServerIp);
|
||||
j.at("IceServerPort").get_to(c.iceServerPort);
|
||||
j.at("SimPeriodAdjustFactor").get_to(c.simPeriodAdjustFactor);
|
||||
j.at("NPowStableCyclesToIncreasePeriod").get_to(c.nPowStableCyclesToIncreasePeriod);
|
||||
j.at("GenerateTemperatureMap").get_to(c.generateTemperatureMap);
|
||||
j.at("GeneratePowerMap").get_to(c.generatePowerMap);
|
||||
}
|
||||
|
||||
void to_json(json &j, const DramDieChannel &c)
|
||||
{
|
||||
j = json{{"init_pow", c.init_pow}, {"threshold", c.threshold}};
|
||||
}
|
||||
|
||||
void from_json(const json &j, DramDieChannel &c)
|
||||
{
|
||||
j.at("init_pow").get_to(c.init_pow);
|
||||
j.at("threshold").get_to(c.threshold);
|
||||
}
|
||||
|
||||
void to_json(json &j, const PowerInfo &c)
|
||||
{
|
||||
j = json{{"dram_die_channel0", c.channel0},
|
||||
{"dram_die_channel1", c.channel1},
|
||||
{"dram_die_channel2", c.channel2},
|
||||
{"dram_die_channel3", c.channel3}};
|
||||
}
|
||||
|
||||
void from_json(const json &j, PowerInfo &c)
|
||||
{
|
||||
j.at("dram_die_channel0").get_to(c.channel0);
|
||||
j.at("dram_die_channel1").get_to(c.channel1);
|
||||
j.at("dram_die_channel2").get_to(c.channel2);
|
||||
j.at("dram_die_channel3").get_to(c.channel3);
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
117
DRAMSys/library/src/common/configuration/ThermalConfig.h
Normal file
117
DRAMSys/library/src/common/configuration/ThermalConfig.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#ifndef THERMALCONFIG_H
|
||||
#define THERMALCONFIG_H
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
enum class TemperatureScale
|
||||
{
|
||||
Celsius,
|
||||
Fahrenheit,
|
||||
Kelvin,
|
||||
Invalid = -1,
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(TemperatureScale, {{TemperatureScale::Invalid, nullptr},
|
||||
{TemperatureScale::Celsius, "Celsius"},
|
||||
{TemperatureScale::Fahrenheit, "Fahrenheit"},
|
||||
{TemperatureScale::Kelvin, "Kelvin"}})
|
||||
|
||||
enum class ThermalSimUnit
|
||||
{
|
||||
Seconds,
|
||||
Milliseconds,
|
||||
Microseconds,
|
||||
Nanoseconds,
|
||||
Picoseconds,
|
||||
Femtoseconds,
|
||||
Invalid = -1,
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(ThermalSimUnit, {{ThermalSimUnit::Invalid, nullptr},
|
||||
{ThermalSimUnit::Seconds, "s"},
|
||||
{ThermalSimUnit::Milliseconds, "ms"},
|
||||
{ThermalSimUnit::Microseconds, "us"},
|
||||
{ThermalSimUnit::Nanoseconds, "ns"},
|
||||
{ThermalSimUnit::Picoseconds, "ps"},
|
||||
{ThermalSimUnit::Femtoseconds, "fs"}})
|
||||
|
||||
struct DramDieChannel
|
||||
{
|
||||
double init_pow;
|
||||
double threshold;
|
||||
};
|
||||
|
||||
void to_json(json &j, const DramDieChannel &c);
|
||||
void from_json(const json &j, DramDieChannel &c);
|
||||
|
||||
struct PowerInfo
|
||||
{
|
||||
DramDieChannel channel0;
|
||||
DramDieChannel channel1;
|
||||
DramDieChannel channel2;
|
||||
DramDieChannel channel3;
|
||||
};
|
||||
|
||||
void to_json(json &j, const PowerInfo &c);
|
||||
void from_json(const json &j, PowerInfo &c);
|
||||
|
||||
struct ThermalConfig
|
||||
{
|
||||
TemperatureScale temperatureScale;
|
||||
int staticTemperatureDefaultValue;
|
||||
double thermalSimPeriod;
|
||||
ThermalSimUnit thermalSimUnit;
|
||||
PowerInfo powerInfo;
|
||||
std::string iceServerIp;
|
||||
unsigned int iceServerPort;
|
||||
unsigned int simPeriodAdjustFactor;
|
||||
unsigned int nPowStableCyclesToIncreasePeriod;
|
||||
bool generateTemperatureMap;
|
||||
bool generatePowerMap;
|
||||
};
|
||||
|
||||
void to_json(json &j, const ThermalConfig &c);
|
||||
void from_json(const json &j, ThermalConfig &c);
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
#endif // THERMALCONFIG_H
|
||||
131
DRAMSys/library/src/common/configuration/TraceSetup.cpp
Normal file
131
DRAMSys/library/src/common/configuration/TraceSetup.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#include "TraceSetup.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
|
||||
TrafficInitiator::~TrafficInitiator()
|
||||
{
|
||||
}
|
||||
|
||||
void to_json(json &j, const TraceSetup &c)
|
||||
{
|
||||
// Create an empty array
|
||||
j = json::array();
|
||||
|
||||
for (const auto &initiator : c.initiators)
|
||||
{
|
||||
json inititator_j;
|
||||
|
||||
inititator_j["name"] = initiator->name;
|
||||
inititator_j["clkMhz"] = initiator->clkMhz;
|
||||
|
||||
if (const auto generator = dynamic_cast<TraceGenerator *>(initiator.get()))
|
||||
{
|
||||
inititator_j["type"] = "generator";
|
||||
inititator_j["numRequests"] = generator->numRequests;
|
||||
inititator_j["rwRatio"] = generator->rwRatio;
|
||||
inititator_j["addressDistribution"] = generator->addressDistribution;
|
||||
|
||||
Util::from_optional("seed", inititator_j, generator->seed);
|
||||
Util::from_optional("maxPendingReadRequests", inititator_j, generator->maxPendingReadRequests);
|
||||
Util::from_optional("maxPendingWriteRequests", inititator_j, generator->maxPendingWriteRequests);
|
||||
Util::from_optional("minAddress", inititator_j, generator->minAddress);
|
||||
Util::from_optional("maxAddress", inititator_j, generator->maxAddress);
|
||||
}
|
||||
else if (const auto hammer = dynamic_cast<TraceHammer *>(initiator.get()))
|
||||
{
|
||||
inititator_j["type"] = "hammer";
|
||||
inititator_j["numRequests"] = hammer->numRequests;
|
||||
inititator_j["rowIncrement"] = hammer->rowIncrement;
|
||||
}
|
||||
else if (const auto player = dynamic_cast<TracePlayer *>(initiator.get()))
|
||||
{
|
||||
inititator_j["type"] = "player";
|
||||
}
|
||||
|
||||
j.insert(j.end(), inititator_j);
|
||||
}
|
||||
}
|
||||
|
||||
void from_json(const json &j, TraceSetup &c)
|
||||
{
|
||||
for (const auto &initiator_j : j)
|
||||
{
|
||||
// Default to Player, when not specified
|
||||
TrafficInitiatorType type = initiator_j.value("type", TrafficInitiatorType::Player);
|
||||
|
||||
std::unique_ptr<TrafficInitiator> initiator;
|
||||
if (type == TrafficInitiatorType::Player)
|
||||
{
|
||||
initiator = std::unique_ptr<TracePlayer>(new TracePlayer);
|
||||
}
|
||||
else if (type == TrafficInitiatorType::Generator)
|
||||
{
|
||||
TraceGenerator *generator = new TraceGenerator;
|
||||
|
||||
initiator_j.at("numRequests").get_to(generator->numRequests);
|
||||
initiator_j.at("rwRatio").get_to(generator->rwRatio);
|
||||
initiator_j.at("addressDistribution").get_to(generator->addressDistribution);
|
||||
|
||||
Util::get_optional("seed", initiator_j, generator->seed);
|
||||
Util::get_optional("maxPendingReadRequests", initiator_j, generator->maxPendingReadRequests);
|
||||
Util::get_optional("maxPendingWriteRequests", initiator_j, generator->maxPendingWriteRequests);
|
||||
Util::get_optional("minAddress", initiator_j, generator->minAddress);
|
||||
Util::get_optional("maxAddress", initiator_j, generator->maxAddress);
|
||||
|
||||
initiator = std::unique_ptr<TraceGenerator>(generator);
|
||||
}
|
||||
else if (type == TrafficInitiatorType::Hammer)
|
||||
{
|
||||
TraceHammer *hammer = new TraceHammer;
|
||||
|
||||
initiator_j.at("numRequests").get_to(hammer->numRequests);
|
||||
initiator_j.at("rowIncrement").get_to(hammer->rowIncrement);
|
||||
|
||||
initiator = std::unique_ptr<TraceHammer>(hammer);
|
||||
}
|
||||
|
||||
initiator_j.at("name").get_to(initiator->name);
|
||||
initiator_j.at("clkMhz").get_to(initiator->clkMhz);
|
||||
|
||||
c.initiators.emplace(std::move(initiator));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
112
DRAMSys/library/src/common/configuration/TraceSetup.h
Normal file
112
DRAMSys/library/src/common/configuration/TraceSetup.h
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#ifndef TRACESETUP_H
|
||||
#define TRACESETUP_H
|
||||
|
||||
#include <memory>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
enum class TrafficInitiatorType
|
||||
{
|
||||
Player,
|
||||
Generator,
|
||||
Hammer,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(TrafficInitiatorType, {{TrafficInitiatorType::Invalid, nullptr},
|
||||
{TrafficInitiatorType::Player, "player"},
|
||||
{TrafficInitiatorType::Hammer, "hammer"},
|
||||
{TrafficInitiatorType::Generator, "generator"}})
|
||||
|
||||
enum class AddressDistribution
|
||||
{
|
||||
Random,
|
||||
Sequential,
|
||||
Invalid = -1
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(AddressDistribution, {{AddressDistribution::Invalid, nullptr},
|
||||
{AddressDistribution::Random, "random"},
|
||||
{AddressDistribution::Sequential, "sequential"}})
|
||||
|
||||
struct TrafficInitiator
|
||||
{
|
||||
virtual ~TrafficInitiator() = 0;
|
||||
|
||||
unsigned int clkMhz;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct TracePlayer : public TrafficInitiator
|
||||
{
|
||||
};
|
||||
|
||||
struct TraceGenerator : public TrafficInitiator
|
||||
{
|
||||
unsigned int numRequests;
|
||||
double rwRatio;
|
||||
AddressDistribution addressDistribution;
|
||||
std::pair<unsigned int, bool> addressIncrement;
|
||||
std::pair<unsigned int, bool> seed;
|
||||
std::pair<unsigned int, bool> maxPendingReadRequests;
|
||||
std::pair<unsigned int, bool> maxPendingWriteRequests;
|
||||
std::pair<unsigned int, bool> minAddress;
|
||||
std::pair<unsigned int, bool> maxAddress;
|
||||
};
|
||||
|
||||
struct TraceHammer : public TrafficInitiator
|
||||
{
|
||||
unsigned int numRequests;
|
||||
unsigned int rowIncrement;
|
||||
};
|
||||
|
||||
struct TraceSetup
|
||||
{
|
||||
std::unordered_set<std::unique_ptr<TrafficInitiator>> initiators;
|
||||
};
|
||||
|
||||
void to_json(json &j, const TraceSetup &c);
|
||||
void from_json(const json &j, TraceSetup &c);
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#include "MemArchitectureSpec.h"
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
|
||||
void to_json(json &j, const MemArchitectureSpec &c)
|
||||
{
|
||||
j = json{};
|
||||
|
||||
for (const auto &entry : c.entries)
|
||||
{
|
||||
j[entry.first] = entry.second;
|
||||
}
|
||||
}
|
||||
|
||||
void from_json(const json &j, MemArchitectureSpec &c)
|
||||
{
|
||||
for (const auto &entry : j.items())
|
||||
{
|
||||
c.entries[entry.key()] = entry.value();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#ifndef MEMARCHITECTURESPEC_H
|
||||
#define MEMARCHITECTURESPEC_H
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
struct MemArchitectureSpec
|
||||
{
|
||||
std::unordered_map<std::string, unsigned int> entries;
|
||||
};
|
||||
|
||||
void to_json(json &j, const MemArchitectureSpec &c);
|
||||
void from_json(const json &j, MemArchitectureSpec &c);
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#include "MemPowerSpec.h"
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
|
||||
void to_json(json &j, const MemPowerSpec &c)
|
||||
{
|
||||
j = json{};
|
||||
|
||||
for (const auto &entry : c.entries)
|
||||
{
|
||||
j[entry.first] = entry.second;
|
||||
}
|
||||
}
|
||||
|
||||
void from_json(const json &j, MemPowerSpec &c)
|
||||
{
|
||||
for (const auto &entry : j.items())
|
||||
{
|
||||
c.entries[entry.key()] = entry.value();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#ifndef MEMPOWERSPEC_H
|
||||
#define MEMPOWERSPEC_H
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
struct MemPowerSpec
|
||||
{
|
||||
std::unordered_map<std::string, unsigned int> entries;
|
||||
};
|
||||
|
||||
void to_json(json &j, const MemPowerSpec &c);
|
||||
void from_json(const json &j, MemPowerSpec &c);
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
#endif
|
||||
62
DRAMSys/library/src/common/configuration/memspec/MemSpec.cpp
Normal file
62
DRAMSys/library/src/common/configuration/memspec/MemSpec.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#include "MemSpec.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
|
||||
void to_json(json &j, const MemSpec &c)
|
||||
{
|
||||
j = json{{"memarchitecturespec", c.memArchitectureSpec},
|
||||
{"memoryId", c.memoryId},
|
||||
{"memoryType", c.memoryType},
|
||||
{"memtimingspec", c.memTimingSpec}};
|
||||
|
||||
Util::from_optional("mempowerspec", j, c.memPowerSpec);
|
||||
}
|
||||
|
||||
void from_json(const json &j, MemSpec &c)
|
||||
{
|
||||
j.at("memarchitecturespec").get_to(c.memArchitectureSpec);
|
||||
j.at("memoryId").get_to(c.memoryId);
|
||||
j.at("memoryType").get_to(c.memoryType);
|
||||
j.at("memtimingspec").get_to(c.memTimingSpec);
|
||||
|
||||
Util::get_optional("mempowerspec", j, c.memPowerSpec);
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
63
DRAMSys/library/src/common/configuration/memspec/MemSpec.h
Normal file
63
DRAMSys/library/src/common/configuration/memspec/MemSpec.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#ifndef MEMSPEC_H
|
||||
#define MEMSPEC_H
|
||||
|
||||
#include "MemArchitectureSpec.h"
|
||||
#include "MemPowerSpec.h"
|
||||
#include "MemTimingSpec.h"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
struct MemSpec
|
||||
{
|
||||
MemArchitectureSpec memArchitectureSpec;
|
||||
std::string memoryId;
|
||||
std::string memoryType;
|
||||
MemTimingSpec memTimingSpec;
|
||||
std::pair<MemPowerSpec, bool> memPowerSpec;
|
||||
};
|
||||
|
||||
void to_json(json &j, const MemSpec &c);
|
||||
void from_json(const json &j, MemSpec &c);
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
#endif // MEMSPEC_H
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#include "MemTimingSpec.h"
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
|
||||
void to_json(json &j, const MemTimingSpec &c)
|
||||
{
|
||||
j = json{};
|
||||
|
||||
for (const auto &entry : c.entries)
|
||||
{
|
||||
j[entry.first] = entry.second;
|
||||
}
|
||||
}
|
||||
|
||||
void from_json(const json &j, MemTimingSpec &c)
|
||||
{
|
||||
for (const auto &entry : j.items())
|
||||
{
|
||||
c.entries[entry.key()] = entry.value();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#ifndef MEMTIMINGSPEC_H
|
||||
#define MEMTIMINGSPEC_H
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Configuration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
struct MemTimingSpec
|
||||
{
|
||||
std::unordered_map<std::string, unsigned int> entries;
|
||||
};
|
||||
|
||||
void to_json(json &j, const MemTimingSpec &c);
|
||||
void from_json(const json &j, MemTimingSpec &c);
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
add_executable(simpletest simpletest.cpp)
|
||||
target_link_libraries(simpletest PRIVATE DRAMSysConfiguration nlohmann_json::nlohmann_json)
|
||||
181
DRAMSys/library/src/common/configuration/tests/simpletest.cpp
Normal file
181
DRAMSys/library/src/common/configuration/tests/simpletest.cpp
Normal file
@@ -0,0 +1,181 @@
|
||||
#include <Configuration.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
Configuration::AddressMapping getAddressMapping()
|
||||
{
|
||||
// Configuration::ConGen *mycongen = new Configuration::ConGen;
|
||||
// mycongen->byteBits = {{0, 1}, true};
|
||||
// mycongen->bankBits = {16};
|
||||
// mycongen->bankGroupBits = {{13, 14, 15}, true};
|
||||
// mycongen->coloumnBits = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
|
||||
// mycongen->channelBits = {{33}, true};
|
||||
// mycongen->rowBits = {17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32};
|
||||
// return std::unique_ptr<Configuration::AddressMapping>(mycongen);
|
||||
|
||||
return Configuration::AddressMapping{{{0, 1}, true},
|
||||
{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
|
||||
{16},
|
||||
{{13, 14, 15}, true},
|
||||
{17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
|
||||
{{33}, true},
|
||||
{{}, false}};
|
||||
}
|
||||
|
||||
Configuration::McConfig getMcConfig()
|
||||
{
|
||||
return Configuration::McConfig{Configuration::PagePolicy::Open,
|
||||
Configuration::Scheduler::FrFcfs,
|
||||
Configuration::SchedulerBuffer::Bankwise,
|
||||
8,
|
||||
Configuration::CmdMux::Oldest,
|
||||
Configuration::RespQueue::Fifo,
|
||||
Configuration::RefreshPolicy::AllBank,
|
||||
0,
|
||||
0,
|
||||
Configuration::PowerDownPolicy::NoPowerDown,
|
||||
Configuration::Arbiter::Simple,
|
||||
128,
|
||||
std::pair<bool, bool>{false, true}};
|
||||
}
|
||||
|
||||
Configuration::SimConfig getSimConfig()
|
||||
{
|
||||
return Configuration::SimConfig {
|
||||
0,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
Configuration::ECCControllerMode::Disabled,
|
||||
false,
|
||||
"error.csv",
|
||||
42,
|
||||
false,
|
||||
"ddr5",
|
||||
true,
|
||||
Configuration::StoreMode::NoStorage,
|
||||
false,
|
||||
false,
|
||||
1000
|
||||
};
|
||||
}
|
||||
|
||||
Configuration::ThermalConfig getThermalConfig()
|
||||
{
|
||||
return Configuration::ThermalConfig{Configuration::TemperatureScale::Celsius,
|
||||
89,
|
||||
100,
|
||||
Configuration::ThermalSimUnit::Microseconds,
|
||||
Configuration::PowerInfo{{0.0, 1.0}, {0.0, 1.0}, {0.0, 1.0}, {0.0, 1.0}},
|
||||
"127.0.0.1",
|
||||
118800,
|
||||
10,
|
||||
5,
|
||||
true,
|
||||
true};
|
||||
}
|
||||
|
||||
std::unique_ptr<Configuration::TracePlayer> getTracePlayer()
|
||||
{
|
||||
Configuration::TracePlayer *player = new Configuration::TracePlayer;
|
||||
|
||||
player->clkMhz = 100;
|
||||
player->name = "mytrace.stl";
|
||||
|
||||
return std::unique_ptr<Configuration::TracePlayer>(player);
|
||||
}
|
||||
|
||||
std::unique_ptr<Configuration::TraceGenerator> getTraceGeneratorRandom()
|
||||
{
|
||||
Configuration::TraceGenerator *gen = new Configuration::TraceGenerator;
|
||||
|
||||
gen->clkMhz = 100;
|
||||
gen->name = "MyTestGen";
|
||||
|
||||
gen->addressDistribution = Configuration::AddressDistribution::Random;
|
||||
gen->maxAddress = {1000, true};
|
||||
gen->maxPendingReadRequests = {8, true};
|
||||
gen->rwRatio = 0.5;
|
||||
gen->seed = {1337, true};
|
||||
gen->numRequests = 1000;
|
||||
|
||||
return std::unique_ptr<Configuration::TraceGenerator>(gen);
|
||||
}
|
||||
|
||||
std::unique_ptr<Configuration::TraceGenerator> getTraceGeneratorSequential()
|
||||
{
|
||||
Configuration::TraceGenerator *gen = new Configuration::TraceGenerator;
|
||||
|
||||
gen->clkMhz = 100;
|
||||
gen->name = "MyTestGen";
|
||||
|
||||
gen->addressDistribution = Configuration::AddressDistribution::Sequential;
|
||||
gen->addressIncrement = {64, true};
|
||||
gen->maxAddress = {1000, true};
|
||||
gen->maxPendingReadRequests = {8, true};
|
||||
gen->rwRatio = 0.5;
|
||||
gen->numRequests = 1000;
|
||||
|
||||
return std::unique_ptr<Configuration::TraceGenerator>(gen);
|
||||
}
|
||||
|
||||
std::unique_ptr<Configuration::TraceHammer> getTraceHammer()
|
||||
{
|
||||
Configuration::TraceHammer *hammer = new Configuration::TraceHammer;
|
||||
|
||||
hammer->clkMhz = 100;
|
||||
hammer->name = "MyTestHammer";
|
||||
|
||||
hammer->numRequests = 4000;
|
||||
hammer->rowIncrement = 2097152;
|
||||
|
||||
return std::unique_ptr<Configuration::TraceHammer>(hammer);
|
||||
}
|
||||
|
||||
Configuration::TraceSetup getTraceSetup()
|
||||
{
|
||||
std::unordered_set<std::unique_ptr<Configuration::TrafficInitiator>> initiators;
|
||||
initiators.emplace(getTracePlayer());
|
||||
initiators.emplace(getTraceGeneratorRandom());
|
||||
initiators.emplace(getTraceGeneratorSequential());
|
||||
initiators.emplace(getTraceHammer());
|
||||
|
||||
return Configuration::TraceSetup{std::move(initiators)};
|
||||
}
|
||||
|
||||
Configuration::Configuration getConfig(const Configuration::MemSpec &memSpec)
|
||||
{
|
||||
return Configuration::Configuration{
|
||||
getAddressMapping(),
|
||||
getMcConfig(),
|
||||
memSpec,
|
||||
getSimConfig(),
|
||||
"std::string_simulationId",
|
||||
{getThermalConfig(), true},
|
||||
// {{}, false}, works too
|
||||
{getTraceSetup(), true},
|
||||
};
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ifstream file("ddr5.json");
|
||||
json ddr5_j = json::parse(file, nullptr, false);
|
||||
json config = ddr5_j.at("simulation");
|
||||
Configuration::Configuration conf = config.get<Configuration::Configuration>();
|
||||
std::ofstream fileout("myjson.json");
|
||||
json j_my;
|
||||
j_my["simulation"] = getConfig(conf.memSpec); // just copy memspec over
|
||||
fileout << j_my.dump(4);
|
||||
|
||||
std::ifstream file2("hbm2.json");
|
||||
json hbm2_j = json::parse(file2, nullptr, false);
|
||||
json hbm2_config = hbm2_j.at("simulation");
|
||||
Configuration::Configuration hbm2conf = hbm2_config.get<Configuration::Configuration>();
|
||||
std::ofstream filehbm2("myhbm2.json");
|
||||
json j_myhbm2;
|
||||
j_myhbm2["simulation"] = hbm2conf;
|
||||
filehbm2 << j_myhbm2.dump(4);
|
||||
}
|
||||
75
DRAMSys/library/src/common/configuration/util.h
Normal file
75
DRAMSys/library/src/common/configuration/util.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace Util
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
/**
|
||||
* Inspired from https://github.com/nlohmann/json/issues/1749#issuecomment-770748811
|
||||
*/
|
||||
template <typename T>
|
||||
void get_optional(const std::string &name, const json &j, std::pair<T, bool> &val)
|
||||
{
|
||||
auto it = j.find(name);
|
||||
if (it != j.end())
|
||||
{
|
||||
val.first = it->template get<T>();
|
||||
val.second = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
val.second = false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void from_optional(const std::string &name, json &j, const std::pair<T, bool> &val)
|
||||
{
|
||||
if (val.second)
|
||||
{
|
||||
j[name] = val.first;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Util
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user