Skip to content

Commit

Permalink
#1943: add vt_checks in scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
stmcgovern committed Sep 16, 2022
1 parent e2fbf74 commit b4f3709
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/vt/scheduler/base_unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,14 @@ namespace vt { namespace sched {
void BaseUnit::execute() {
if (r_) {
r_->run();
if (not r_->isDone()) {
auto tid = r_->getThreadID();
theSched()->suspend(tid, std::move(r_));
}
#if vt_check_enabled(fcontext)
if (not r_->isDone()) {
auto tid = r_->getThreadID();
theSched()->suspend(tid, std::move(r_));
}
#endif
delete r_;
r_ = nullptr;
} else if (work_) {
work_();
}
Expand Down
6 changes: 6 additions & 0 deletions src/vt/scheduler/scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,15 @@ void Scheduler::runWorkUnit(UnitType& work) {

workUnitCount.increment(1);

#if vt_check_enabled(mpi_access_guards)
++action_depth_;
#endif

work();

#if vt_check_enabled(mpi_access_guards)
--action_depth_;
#endif

#if vt_check_enabled(mpi_access_guards)
if (action_depth_ == 0) {
Expand Down
4 changes: 4 additions & 0 deletions src/vt/scheduler/suspended_units.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace vt { namespace sched {
void SuspendedUnits::addSuspended(
ThreadIDType tid, RunnablePtrType runnable, PriorityType p
) {
#if vt_check_enabled(fcontext)
vtAssert(runnable->isSuspended(), "Runnable must be suspended to add");

units_.emplace(
Expand All @@ -59,15 +60,18 @@ void SuspendedUnits::addSuspended(
detail::SuspendedRunnable{std::move(runnable), p}
)
);
#endif
}

void SuspendedUnits::resumeRunnable(ThreadIDType tid) {
#if vt_check_enabled(fcontext)
auto iter = units_.find(tid);
vtAbortIf(iter == units_.end(), "Must have valid thread ID to resume");
auto r = std::move(iter->second.runnable_);
auto p = iter->second.priority_;
theSched()->enqueue(p, std::move(r));
units_.erase(iter);
#endif
}

}} /* end namespace vt::sched */

0 comments on commit b4f3709

Please sign in to comment.