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

Build the dependency graph only after establishing all connections #54

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion include/reactor-cpp/environment.hh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public:

template <class T> void draw_connection(Port<T>* source, Port<T>* sink, ConnectionProperties properties) {
if (top_environment_ == nullptr || top_environment_ == this) {
log::Debug() << "drawing connection: " << source << " --> " << sink;
log::Debug() << "drawing connection: " << source->fqn() << " --> " << sink->fqn();
graph_.add_edge(source, sink, properties);
} else {
top_environment_->draw_connection(source, sink, properties);
Expand Down
31 changes: 16 additions & 15 deletions lib/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,17 @@ void Environment::assemble() { // NOLINT
recursive_assemble(reactor);
}

log::Debug() << "start optimization on port graph";
this->optimize();
// this assembles all the contained environments aka enclaves
for (auto* env : contained_environments_) {
env->assemble();
}

log::Debug() << "instantiating port graph declaration";
// If this is the top level environment, then instantiate all connections.
if (top_environment_ == nullptr || top_environment_ == this) {
log::Debug() << "start optimization on port graph";
this->optimize();

log::Debug() << "instantiating port graph declaration";
log::Debug() << "graph: ";
log::Debug() << optimized_graph_;

Expand Down Expand Up @@ -136,18 +142,6 @@ void Environment::assemble() { // NOLINT
}
}
}

log::Debug() << "Building the Dependency-Graph";
for (auto* reactor : top_level_reactors_) {
build_dependency_graph(reactor);
}

calculate_indexes();

// this assembles all the contained environments aka enclaves
for (auto* env : contained_environments_) {
env->assemble();
}
}

void Environment::build_dependency_graph(Reactor* reactor) { // NOLINT
Expand Down Expand Up @@ -326,6 +320,13 @@ auto Environment::startup() -> std::thread {
auto Environment::startup(const TimePoint& start_time) -> std::thread {
validate(this->phase() == Phase::Assembly, "startup() may only be called during assembly phase!");

log::Debug() << "Building the Dependency-Graph";
for (auto* reactor : top_level_reactors_) {
build_dependency_graph(reactor);
}

calculate_indexes();

log_.debug() << "Starting the execution";
phase_ = Phase::Startup;

Expand Down