Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/new memspec #105

Merged
merged 34 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6b5719c
implemented new memspec
Jun 27, 2024
19fd81d
changed json
Jun 28, 2024
a030746
added import vector and bug fix
Jun 28, 2024
9c8ac28
fixed memory error
Jun 28, 2024
4704e50
removed default constructor memspec
Jun 28, 2024
c6e3d99
removed unused tRTP in LPDDR5
Jun 28, 2024
572d5b7
removed hardcoded tCK
Jun 28, 2024
f1d7a4a
added all power domains
Jun 28, 2024
02529c0
added last_command_time interface calculation
Jul 4, 2024
3ba4c19
changed cmake naming
Jul 4, 2024
f41ef3e
added target cli in dev-mode
Jul 4, 2024
3f214db
implemented DRAMUtils in cli tool
Jul 4, 2024
c7b2589
changed cmake
Jul 4, 2024
aa7fcd1
changed cmakepreset
Jul 4, 2024
1ec43cf
memspec value fixes
Jul 4, 2024
d02dc11
implemented RefMode
Jul 4, 2024
a382632
test rounding error
Jul 4, 2024
5c0ca8f
Refactor dram_base api interface
Jul 8, 2024
21f45a1
changed cli floating point representation
Jul 8, 2024
2a88c4e
changed interface impedanceSpec
Jul 8, 2024
ecbd228
renamed namespace DRAMUtils::Config to DRAMUtils::MemSpec
Jul 15, 2024
fa7afb0
LPDDR5 use RCD_S
Jul 15, 2024
8396b54
removed TODOs
Jul 17, 2024
1d14278
removed memPowerSpec.resize in tests
Jul 17, 2024
8a04d5e
Fixed DRAMUtils to v1.0
IESE-T3 Jul 16, 2024
91dfa9a
Updated CMakePresets and minor cleanups in CMakeLists
IESE-T3 Jul 17, 2024
1d2c06b
Fixed wrong array access in LDDPR4 interface tests
IESE-T3 Jul 17, 2024
fb275a2
Small refactor in CMakeLists
IESE-T3 Jul 17, 2024
8e9c5f7
Updated LPDDR5 unit tests
IESE-T3 Jul 19, 2024
7d12a0f
use DRAMUtils parse functions
Jul 23, 2024
c82014e
removed nlohmann_json dependency
Jul 23, 2024
de70405
renamed WCKtoCK to WCK2CK
Jul 25, 2024
a278049
small cosmetic changes in cmakelist
Jul 31, 2024
7bb168b
changed DRAMUtils json
Jul 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ option(DRAMPOWER_BUILD_TESTS "Build DRAMPower unit tests" OFF)
option(DRAMPOWER_VERBOSE_CMAKE_OUTPUT "Show detailed CMake output" OFF)
option(DRAMPOWER_BUILD_CLI "Build DRAMPower Command Line Tool" OFF)

set(DRAMUTILS_DIR "" CACHE PATH "Local DRAMUtils installation path (optional)")

### Compiler settings ###
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

###############################################
### Library Settings ###
Expand All @@ -86,26 +90,32 @@ set(CMAKE_CXX_STANDARD 17)
### Detect OS threading library ###
find_package(Threads)

add_subdirectory(${DRAMPOWER_LIBRARY_DIR}/nlohmann_json)
### DRAMUtils ###
if (DRAMUTILS_DIR) # Fetch DRAMUtils from supplied local path
message(STATUS "Using local DRAMUtils installation from ${DRAMUTILS_DIR}")
FetchContent_Declare(
DRAMUtils
SOURCE_DIR ${DRAMUTILS_DIR}
)
else() # Fetch DRAMUtils from github
message(STATUS "Fetching DRAMUtils from github")
FetchContent_Declare(
DRAMUtils
GIT_REPOSITORY https://github.com/tukl-msd/DRAMUtils
GIT_TAG "v1.0"
)
endif()

### nlohmann_json ###
#FetchContent_Declare(
# json
# GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent
# GIT_TAG v3.9.1)
#
#FetchContent_GetProperties(json)
#if(NOT json_POPULATED)
# FetchContent_Populate(json)
# add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
#endif()
FetchContent_MakeAvailable(DRAMUtils)
set_target_properties(DRAMUtils PROPERTIES FOLDER lib)

### GoogleTest ###
if(DRAMPOWER_BUILD_TESTS)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG release-1.12.1)
googletest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG release-1.12.1
)

# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
Expand All @@ -123,7 +133,7 @@ endif()
add_subdirectory(src/DRAMPower)

if(DRAMPOWER_BUILD_CLI)
add_subdirectory(src/cli)
add_subdirectory(src/cli)
endif()

###############################################
Expand Down
77 changes: 77 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 14,
"patch": 0
},
"configurePresets": [
{
"name": "cmake-pedantic",
"hidden": true,
"warnings": {
"dev": true,
"deprecated": true,
"unusedCli": true,
"systemVars": false
}
},
{
"name": "dev-mode",
"hidden": true,
"inherits": "cmake-pedantic",
"cacheVariables": {
"DRAMPOWER_BUILD_TESTS": "ON",
"CMAKE_BUILD_PARALLEL_LEVEL": ""
}
},
{
"name": "ci-common",
"binaryDir": "${sourceDir}/build",
"inherits": [
"dev-mode"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "ci-unix",
"generator": "Unix Makefiles",
"inherits": [
"ci-common"
]
},
{
"name": "ci-msvc",
"generator": "Visual Studio 17 2022",
"inherits": [
"ci-common"
],
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/DWIN32 /D_WINDOWS /W3 /GR /EHsc /MP"
}
},
{
"name": "dev-unix",
"generator": "Unix Makefiles",
"inherits": [
"dev-mode"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic"
}
},
{
"name": "dev-msvc",
"generator": "Visual Studio 17 2022",
"inherits": [
"dev-mode"
],
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/DWIN32 /D_WINDOWS /W3 /GR /EHsc /MP"
}
}
]
}
2 changes: 1 addition & 1 deletion src/DRAMPower/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ file(GLOB_RECURSE HEADER_FILES CONFIGURE_DEPENDS *.h;*.hpp)
add_library(DRAMPower ${SOURCE_FILES} ${HEADER_FILES})
target_include_directories(DRAMPower PUBLIC ${PROJECT_SOURCE_DIR})
target_link_libraries(DRAMPower PUBLIC
nlohmann_json::nlohmann_json
DRAMUtils
)

add_library(DRAMSys::DRAMPower ALIAS DRAMPower)
Expand Down
30 changes: 17 additions & 13 deletions src/DRAMPower/DRAMPower/command/Pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <vector>

namespace DRAMPower {
namespace pattern_descriptor {
Expand All @@ -26,7 +27,8 @@ enum class PatternEncoderBitSpec
{
L = 0,
H = 1,
LAST_BIT = 2
LAST_BIT = 2,
INVALID = -1
};

// struct for initializer list in PatternEncoderSettings
Expand All @@ -43,20 +45,20 @@ class PatternEncoderOverrides
std::unordered_map<pattern_descriptor::t, PatternEncoderBitSpec> settings;
public:
// Constructor with initializer list for settings
PatternEncoderOverrides(std::initializer_list<PatternEncoderSettingsEntry> settings)
PatternEncoderOverrides(std::initializer_list<PatternEncoderSettingsEntry> _settings)
{
for (const auto &setting : settings)
for (const auto &setting : _settings)
{
this->settings[setting.descriptor] = setting.bitSpec;
this->settings.emplace(setting.descriptor, setting.bitSpec);
}
};
PatternEncoderOverrides() = default;

public:
void updateSettings(std::initializer_list<PatternEncoderSettingsEntry> settings)
void updateSettings(std::initializer_list<PatternEncoderSettingsEntry> _settings)
{
// Update settings if descriptor is already present
for (const auto &setting : settings)
for (const auto &setting : _settings)
{
this->settings[setting.descriptor] = setting.bitSpec;
}
Expand All @@ -69,7 +71,11 @@ class PatternEncoderOverrides

PatternEncoderBitSpec getSetting(pattern_descriptor::t descriptor)
{
return this->settings[descriptor];
if (this->settings.find(descriptor) != this->settings.end())
{
return this->settings.at(descriptor);
}
return PatternEncoderBitSpec::INVALID;
};

bool hasSetting(pattern_descriptor::t descriptor)
Expand Down Expand Up @@ -98,19 +104,17 @@ inline bool applyBitSpec(
bool default_bit
)
{
if(!spec.hasSetting(descriptor))
{
return default_bit;
}

switch (spec.getSetting(descriptor))
auto setting = spec.getSetting(descriptor);
switch (setting)
{
case PatternEncoderBitSpec::L:
return false;
case PatternEncoderBitSpec::H:
return true;
case PatternEncoderBitSpec::LAST_BIT:
return LAST_BIT;
case PatternEncoderBitSpec::INVALID:
return default_bit;
default:
assert(false);
break;
Expand Down
15 changes: 12 additions & 3 deletions src/DRAMPower/DRAMPower/data/energy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ double energy_info_t::total() const
return total;
};

void energy_info_t::to_json(nlohmann::json &j) const
void energy_info_t::to_json(json_t &j) const
{
j = nlohmann::json{
{"ACT", E_act},
Expand Down Expand Up @@ -80,7 +80,16 @@ double DRAMPower::energy_t::total() const
return total;
}

void DRAMPower::energy_t::to_json(nlohmann::json &j) const
void DRAMPower::interface_energy_info_t::to_json(json_t &j) const
{
j = nlohmann::json{};
j["controller"]["dynamicEnergy"] = controller.dynamicEnergy;
j["controller"]["staticEnergy"] = controller.staticEnergy;
j["dram"]["dynamicEnergy"] = dram.dynamicEnergy;
j["dram"]["staticEnergy"] = dram.staticEnergy;
}

void DRAMPower::energy_t::to_json(json_t &j) const
{
j = nlohmann::json{
{"E_bg_act_shared", E_bg_act_shared},
Expand All @@ -94,7 +103,7 @@ void DRAMPower::energy_t::to_json(nlohmann::json &j) const
auto energy_arr = nlohmann::json::array();
for (const energy_info_t& energy : bank_energy)
{
nlohmann::json bank_energy_json;
json_t bank_energy_json;
energy.to_json(bank_energy_json);
energy_arr.push_back(bank_energy_json);
}
Expand Down
40 changes: 28 additions & 12 deletions src/DRAMPower/DRAMPower/data/energy.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

#include <vector>
#include <iostream>
#include <nlohmann/json.hpp>

#include <DRAMUtils/util/json_utils.h>

namespace DRAMPower {

Expand All @@ -29,7 +30,7 @@ struct energy_info_t
double E_ref_2B = 0.0;

double total() const;
void to_json(nlohmann::json &j) const;
void to_json(json_t &j) const;
energy_info_t& operator+=(const energy_info_t & other);
// Operator << for std::cout
friend std::ostream & operator<<(std::ostream & os, const energy_info_t & ei)
Expand Down Expand Up @@ -57,7 +58,7 @@ struct energy_t
{
std::vector<energy_info_t> bank_energy;
energy_info_t total_energy(); // TODO rename
void to_json(nlohmann::json &j) const;
void to_json(json_t &j) const;
constexpr inline const char * const get_Bank_energy_keyword() const
{
return "BankEnergy";
Expand Down Expand Up @@ -88,18 +89,18 @@ struct energy_t
double total() const;
};

struct interface_power_t
struct interface_energy_t
{
double dynamicPower = 0.0;
double staticPower = 0.0;
double dynamicEnergy = 0.0;
double staticEnergy = 0.0;

interface_power_t &operator+=(const interface_power_t &rhs) {
dynamicPower += rhs.dynamicPower;
staticPower += rhs.staticPower;
interface_energy_t &operator+=(const interface_energy_t &rhs) {
dynamicEnergy += rhs.dynamicEnergy;
staticEnergy += rhs.staticEnergy;
return *this;
}

friend interface_power_t operator+(interface_power_t lhs, const interface_power_t &rhs) {
friend interface_energy_t operator+(interface_energy_t lhs, const interface_energy_t &rhs) {
lhs += rhs;
return lhs;
}
Expand All @@ -109,8 +110,12 @@ struct interface_power_t

struct interface_energy_info_t
{
interface_power_t controller;
interface_power_t dram;
interface_energy_t controller;
interface_energy_t dram;

double total() const {
return controller.dynamicEnergy + controller.staticEnergy + dram.dynamicEnergy + dram.staticEnergy;
}

interface_energy_info_t &operator+=(const interface_energy_info_t &rhs) {
controller += rhs.controller;
Expand All @@ -123,6 +128,17 @@ struct interface_energy_info_t
lhs += rhs;
return lhs;
}

friend std::ostream & operator<<(std::ostream & os, const interface_energy_info_t & e)
{
os << "Controller: dynamicEnergy: " << e.controller.dynamicEnergy << " ";
os << "staticEnergy: " << e.controller.staticEnergy << std::endl;
os << "DRAM: dynamicEnergy: " << e.dram.dynamicEnergy << " ";
os << "staticEnergy: " << e.dram.staticEnergy << std::endl;
os << "Total: " << e.total() << std::endl;
return os;
}
void to_json(json_t &j) const;
};

};
Expand Down
Loading