-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 Naive Hybrid Update Scheme for mVLSI
* Add update scheme definition * Define 'Naive' update scheme
- Loading branch information
Showing
31 changed files
with
977 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## This PR updates | ||
|
||
(Add description) | ||
|
||
## PR Checklist | ||
- [ ] Did you include comments/documentation? | ||
- [ ] Did you include and pass unit tests? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
target_sources(${TARGET_NAME} PRIVATE ${SOURCE_LIST}) | ||
target_link_libraries(${TARGET_NAME} PUBLIC gtest gtest_main) | ||
target_link_libraries(${TARGET_NAME} PUBLIC nlohmann_json::nlohmann_json) | ||
target_link_libraries(${TARGET_NAME} PUBLIC lbmLib) | ||
target_link_libraries(${TARGET_NAME} PUBLIC simLib) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "gtest/gtest.h" | ||
#include "benchmark/benchmark.h" | ||
|
||
#include "../src/baseSimulator.h" | ||
#include "../src/baseSimulator.hh" | ||
|
||
using T = double; | ||
|
||
void BM_simRun(benchmark::State& state) { | ||
|
||
std::string file = "../examples/Hybrid/Network4a.JSON"; | ||
|
||
// Load and set the network from a JSON file | ||
arch::Network<T> network = porting::networkFromJSON<T>(file); | ||
|
||
// Load and set the simulation from a JSON file | ||
sim::Simulation<T> testSimulation = porting::simulationFromJSON<T>(file, &network); | ||
for (auto _ : state) { | ||
testSimulation.simulate(); | ||
} | ||
} | ||
BENCHMARK(BM_simRun); | ||
|
||
BENCHMARK_MAIN(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
set(SOURCE_LIST | ||
Scheme.hh | ||
Naive.hh | ||
) | ||
|
||
set(HEADER_LIST | ||
Scheme.h | ||
Naive.h | ||
) | ||
|
||
target_sources(${TARGET_NAME} PUBLIC ${SOURCE_LIST} ${HEADER_LIST}) | ||
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) | ||
target_link_libraries(${TARGET_NAME} PUBLIC eigen) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* @file Naive.h | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
namespace arch { | ||
|
||
// Forward declared dependencies | ||
template<typename T> | ||
class Module; | ||
|
||
} | ||
|
||
namespace mmft{ | ||
|
||
/** | ||
* @brief The Naive Scheme is an update scheme that sets the relaxation factor of an iterative update scheme to a | ||
* given constant for all nodes. | ||
*/ | ||
template<typename T> | ||
class NaiveScheme : public Scheme<T> { | ||
|
||
public: | ||
/** | ||
* @brief Constructor of the Naive Scheme with provided constants. | ||
* @param[in] modules The map of modules with boundary nodes upon which this scheme acts. | ||
* @param[in] alpha The relaxation value for the pressure value update. | ||
* @param[in] beta The relaxation value of the flow rate value update. | ||
* @param[in] theta The amount of LBM stream and collide cycles between updates for a module. | ||
*/ | ||
NaiveScheme(const std::unordered_map<int, std::shared_ptr<arch::Module<T>>>& modules, T alpha, T beta, int theta); | ||
|
||
/** | ||
* @brief Constructor of the Naive Scheme with provided constants. | ||
* @param[in] modules The map of modules with boundary nodes upon which this scheme acts. | ||
* @param[in] alpha The relaxation value for the pressure value update. | ||
* @param[in] beta The relaxation value of the flow rate value update. | ||
* @param[in] theta The amount of LBM stream and collide cycles between updates for a module. | ||
*/ | ||
NaiveScheme(const std::shared_ptr<arch::Module<T>> module, T alpha, T beta, int theta); | ||
|
||
/** | ||
* @brief Constructor of the Naive Scheme with provided constants. | ||
* @param[in] modules The map of modules with boundary nodes upon which this scheme acts. | ||
* @param[in] alpha The relaxation value for the pressure value update. | ||
* @param[in] beta The relaxation value of the flow rate value update. | ||
* @param[in] theta The amount of LBM stream and collide cycles between updates for a module. | ||
*/ | ||
NaiveScheme(const std::shared_ptr<arch::Module<T>> module, std::unordered_map<int, T> alpha, std::unordered_map<int, T> beta, int theta); | ||
|
||
/** | ||
* @brief Constructor of the Naive Scheme with provided constants. | ||
* @param[in] nodeIds The Ids of the set of nodes on which this scheme acts | ||
* @param[in] moduleIds The Ids of the set of modules on which this scheme acts. | ||
* @param[in] alpha The relaxation value for the pressure value update. | ||
* @param[in] beta The relaxation value of the flow rate value update. | ||
* @param[in] theta The amount of LBM stream and collide cycles between updates for a module. | ||
*/ | ||
NaiveScheme(std::vector<int> nodeIds, std::vector<int> moduleIds, T alpha, T beta, int theta); | ||
|
||
/** | ||
* @brief Constructor of the Naive Scheme with provided constants. The ids of the nodes and modules | ||
* are passed in the maps. | ||
* @param[in] alpha The relaxation value for the pressure value update. | ||
* @param[in] beta The relaxation value of the flow rate value update. | ||
* @param[in] theta The amount of LBM stream and collide cycles between updates for a module. | ||
*/ | ||
NaiveScheme(std::unordered_map<int, T> alpha, std::unordered_map<int, T> beta, std::unordered_map<int, int> theta); | ||
|
||
}; | ||
|
||
} // namespace mmft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "Naive.h" | ||
|
||
namespace mmft { | ||
|
||
template<typename T> | ||
NaiveScheme<T>::NaiveScheme(const std::unordered_map<int, std::shared_ptr<arch::Module<T>>>& modules, T alpha, T beta, int theta) : | ||
Scheme<T>(modules, alpha, beta, theta) { } | ||
|
||
template<typename T> | ||
NaiveScheme<T>::NaiveScheme(const std::shared_ptr<arch::Module<T>> module, T alpha, T beta, int theta) : | ||
Scheme<T>(module, alpha, beta, theta) { } | ||
|
||
template<typename T> | ||
NaiveScheme<T>::NaiveScheme(const std::shared_ptr<arch::Module<T>> module, std::unordered_map<int, T> alpha, std::unordered_map<int, T> beta, int theta) : | ||
Scheme<T>(module, alpha, beta, theta) { } | ||
|
||
template<typename T> | ||
NaiveScheme<T>::NaiveScheme(std::vector<int> nodeIds, std::vector<int> moduleIds, T alpha, T beta, int theta) : | ||
Scheme<T>() | ||
{ | ||
for (auto nodeId : nodeIds) { | ||
this->alpha.try_emplace(nodeId, alpha); | ||
} | ||
for (auto nodeId : nodeIds) { | ||
this->beta.try_emplace(nodeId, beta); | ||
} | ||
for (auto moduleId : moduleIds) { | ||
this->alpha.try_emplace(moduleId, theta); | ||
} | ||
} | ||
|
||
template<typename T> | ||
NaiveScheme<T>::NaiveScheme(std::unordered_map<int, T> alpha_, std::unordered_map<int, T> beta_, std::unordered_map<int, int> theta_) : | ||
Scheme<T>(alpha_, beta_, theta_) { } | ||
|
||
} // namespace mmft |
Oops, something went wrong.