Skip to content

Commit

Permalink
Stopped passing Config object around
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrazzle committed Feb 13, 2024
1 parent d5bb767 commit 26aefc8
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 41 deletions.
41 changes: 19 additions & 22 deletions src/Memory/MemoryFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ struct SimpleConfigs {
int wordSize;
};

std::unique_ptr<SubArray>
makeSimpleSubArray(const NVM::Simulation::Config& conf) {
std::unique_ptr<SubArray> makeSimpleSubArray() {
SimpleConfigs configs;

ConfigParser::registerValue<double>("PIMFaultRate", 0.0,
Expand All @@ -34,54 +33,52 @@ makeSimpleSubArray(const NVM::Simulation::Config& conf) {
FaultModel model(configs.pimFaultRate, configs.wordSize,
configs.numCorrectableFaults);

auto timer = std::make_unique<NVM::Timing::ConfigurableTimer>(conf);
return std::unique_ptr<SubArray>(new SimpleSubArray(
conf.get<int>("DBCS"), std::move(timer), model, configs.numTries));
int dbcs;
ConfigParser::registerValue<int>("DBCS", 64, &dbcs);

auto timer = std::make_unique<NVM::Timing::ConfigurableTimer>();
return std::unique_ptr<SubArray>(
new SimpleSubArray(dbcs, std::move(timer), model, configs.numTries));
}

std::unique_ptr<Bank> makeSimpleBank(const NVM::Simulation::Config& conf) {
std::unique_ptr<Bank> makeSimpleBank() {
auto bank = std::unique_ptr<Bank>(new SimpleBank());
bank->addSubArray(makeSimpleSubArray(conf));
bank->addSubArray(makeSimpleSubArray());
return std::move(bank);
}

std::unique_ptr<Rank> makeSimpleRank(const NVM::Simulation::Config& conf) {
std::unique_ptr<Rank> makeSimpleRank() {
auto rank = std::unique_ptr<Rank>(new SimpleRank());
rank->addBank(makeSimpleBank(conf));
rank->addBank(makeSimpleBank());
return std::move(rank);
}

std::unique_ptr<Interconnect>
makeSimpleInterconnect(const NVM::Simulation::Config& conf) {
std::unique_ptr<Interconnect> makeSimpleInterconnect() {
auto interconnect = std::unique_ptr<Interconnect>(new SimpleInterconnect());
interconnect->addRank(makeSimpleRank(conf));
interconnect->addRank(makeSimpleRank());
return std::move(interconnect);
}

std::unique_ptr<MemoryController>
makeSimpleController(const NVM::Simulation::Config& conf) {
std::unique_ptr<MemoryController> makeSimpleController() {
auto controller = std::unique_ptr<MemoryController>(new SimpleController());
controller->addInterconnect(makeSimpleInterconnect(conf));
controller->addInterconnect(makeSimpleInterconnect());
return std::move(controller);
}

std::unique_ptr<MemorySystem>
NVM::Memory::makeSimpleSystem(const NVM::Simulation::Config& conf) {
std::unique_ptr<MemorySystem> NVM::Memory::makeSimpleSystem() {
SimpleSystem* system = new SimpleSystem();
system->addController(makeSimpleController(conf));
system->addController(makeSimpleController());
return std::unique_ptr<MemorySystem>(system);
}

using NVM::State::StateSystem;

std::unique_ptr<MemorySystem>
NVM::Memory::makeStateSystem(const NVM::Simulation::Config& conf) {
std::unique_ptr<MemorySystem> NVM::Memory::makeStateSystem() {
return std::make_unique<StateSystem>();
}

using NVM::ComponentType::ComponentSystem;

std::unique_ptr<MemorySystem>
NVM::Memory::makeComponentSystem(const NVM::Simulation::Config& conf) {
std::unique_ptr<MemorySystem> NVM::Memory::makeComponentSystem() {
return std::make_unique<ComponentSystem>();
}
9 changes: 3 additions & 6 deletions src/Memory/MemoryFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ class MemorySystem;
*
* @return Unique pointer to the created MemorySystem
*/
std::unique_ptr<MemorySystem>
makeSimpleSystem(const NVM::Simulation::Config& conf);
std::unique_ptr<MemorySystem> makeSimpleSystem();

std::unique_ptr<MemorySystem>
makeStateSystem(const NVM::Simulation::Config& conf);
std::unique_ptr<MemorySystem> makeStateSystem();

std::unique_ptr<MemorySystem>
makeComponentSystem(const NVM::Simulation::Config& conf);
std::unique_ptr<MemorySystem> makeComponentSystem();

} // namespace NVM::Memory
13 changes: 9 additions & 4 deletions src/MemoryTypes/Simple/Timing/Timer/ConfigurableTimer.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
#include "MemoryTypes/Simple/Timing/Timer/ConfigurableTimer.h"

#include "Utils/ConfigParser.h"

using namespace NVM::Timing;
using NVM::Command;
using namespace NVM::Memory;

ConfigurableTimer::ConfigurableTimer(const NVM::Simulation::Config& conf) :
remainingCycles(0) {
ConfigurableTimer::ConfigurableTimer() : remainingCycles(0) {
timings[static_cast<size_t>(CommandType::READ)] = 5;
timings[static_cast<size_t>(CommandType::WRITE)] = 5;
timings[static_cast<size_t>(CommandType::ACTIVATE)] = conf.get<int>("tACT");
timings[static_cast<size_t>(CommandType::PIM)] = 5;
timings[static_cast<size_t>(CommandType::ROWCLONE)] = 5;
timings[static_cast<size_t>(CommandType::PRECHARGE)] = conf.get<int>("tRP");

ConfigParser::registerValue<unsigned int>(
"tACT", 1, &timings[static_cast<size_t>(CommandType::ACTIVATE)]);
ConfigParser::registerValue<unsigned int>(
"tRP", 1, &timings[static_cast<size_t>(CommandType::PRECHARGE)]);
}

void ConfigurableTimer::cycle() {
Expand Down
2 changes: 1 addition & 1 deletion src/MemoryTypes/Simple/Timing/Timer/ConfigurableTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using NVM::Simulation::Config;

class ConfigurableTimer : public NVM::Memory::CommandTimer {
public:
ConfigurableTimer(const Config& conf);
ConfigurableTimer();

void cycle();
bool busy() const;
Expand Down
14 changes: 7 additions & 7 deletions src/main/simpleMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ncycle_t getMaxCycles(char* arg) {
return 0;
}

void setAddressScheme(const NVM::Simulation::Config& conf) {
void setAddressScheme() {
ComponentCounts counts;

ConfigParser::registerValue<unsigned int>("DBCS", 64, &counts.rows);
Expand All @@ -38,7 +38,7 @@ void setAddressScheme(const NVM::Simulation::Config& conf) {
setScheme(addressScheme, counts);
}

void setLogLevel(const NVM::Simulation::Config& conf) {
void setLogLevel() {
std::string logLevel;
ConfigParser::registerValue<std::string>("LogLevel", "STAT", &logLevel);

Expand Down Expand Up @@ -78,8 +78,8 @@ int main(int argc, char* argv[]) {
conf.override(argv[i]);
}

setLogLevel(conf);
setAddressScheme(conf);
setLogLevel();
setAddressScheme();

// Build RTSystem
std::unique_ptr<MemorySystem> memory;
Expand All @@ -88,11 +88,11 @@ int main(int argc, char* argv[]) {
ConfigParser::registerValue<std::string>("MemType", "Simple", &memType);

if (memType == "Simple") {
memory = makeSimpleSystem(conf);
memory = makeSimpleSystem();
} else if (memType == "State") {
memory = makeStateSystem(conf);
memory = makeStateSystem();
} else if (memType == "Component") {
memory = makeComponentSystem(conf);
memory = makeComponentSystem();
}

// Build TraceReader
Expand Down
4 changes: 3 additions & 1 deletion test/Memory/MemoryFactory.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Memory/MemorySystem.h"
#include "Simulation/Config.h"
#include "Utils/ConfigParser.h"

#include <catch2/catch_test_macros.hpp>

Expand All @@ -12,6 +13,7 @@ TEST_CASE("Makes valid simple system", "[MemoryFactory], [Memory]") {
conf.set("DBCS", 1);
conf.set("tACT", 1);
conf.set("tRP", 1);
auto system = makeSimpleSystem(conf);
ConfigParser::setConfig(conf);
auto system = makeSimpleSystem();
REQUIRE(system);
}

0 comments on commit 26aefc8

Please sign in to comment.