Skip to content

Commit

Permalink
Add debugging support for DAG (#536)
Browse files Browse the repository at this point in the history
* Add debugging support for DAG

* Revert "Add debugging support for DAG"

This reverts commit 7ba728f.

* Add debugging support for DAG

* Reset DAG after scheduler being reset
  • Loading branch information
furuame authored Oct 30, 2024
1 parent 1477609 commit d63b335
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions sparta/sparta/kernel/DAG.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ namespace sparta
VertexMap gops_;
bool finalized_ = false;
sparta::Scheduler* my_scheduler_ = nullptr;
const log::MessageSource debug_logger_;
};//End class DAG


Expand Down
27 changes: 17 additions & 10 deletions sparta/src/DAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,17 @@ namespace sparta
num_groups_(1),
early_cycle_detect_(check_cycles),
gops_(),
my_scheduler_(scheduler)
my_scheduler_(scheduler),
debug_logger_(scheduler,
sparta::log::categories::DEBUG,
"Scheduler's constructing DAG debug messages")
{
initializeDAG_();

// Enable early cycle detection when the debug logger is
// enabled for the convenience of debugging ...
if(debug_logger_.observed()){
early_cycle_detect_ = true;
}
}

void DAG::initializeDAG_()
Expand Down Expand Up @@ -171,20 +178,20 @@ namespace sparta
dest_vertex->setInDAG(true);
}

// TODO: REMOVE DEBUGGING STATEMENTS
//std::cout << "DAG::link()" << std::endl;
//std::cout << "\t" << std::string(*source_vertex) << " -> " << std::string(*dest_vertex) << std::endl;
if(SPARTA_EXPECT_FALSE(debug_logger_)){
debug_logger_ << SPARTA_CURRENT_COLOR_GREEN
<< "=== SCHEDULER: Add DAG link for "
<< reason << ": "
<< SPARTA_CURRENT_COLOR_NORMAL
<< std::string(*source_vertex) << " -> "
<< std::string(*dest_vertex);
}

if (source_vertex->link(e_factory_, dest_vertex, reason)) {
if (early_cycle_detect_ && detectCycle()) {
throw CycleException(getCycles_());
}
}

// TODO: DEBUGGING - remove this
//if (detectCycle()) {
//throw CycleException(getCycles_());
//}
}


Expand Down
2 changes: 1 addition & 1 deletion sparta/src/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ void Scheduler::reset()
enterTeardown(); // On RootTreeNode
clearEvents();

dag_.reset(new DAG(this, false));
dag_finalized_ = false;
dag_.reset(new DAG(this, false));

tick_quantum_allocator_.clear();
}
Expand Down

0 comments on commit d63b335

Please sign in to comment.