Skip to content

Commit

Permalink
#410: termination: remove unneeded code, cleanup scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Oct 31, 2023
1 parent cb2b519 commit 4b3a9c6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 47 deletions.
5 changes: 2 additions & 3 deletions src/vt/scheduler/scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,11 @@ void Scheduler::resume(ThreadIDType tid) {
}

void Scheduler::releaseEpoch(EpochType ep) {
if (auto iter = pending_work_.find(ep); iter != pending_work_.end()) {
auto& container = iter->second;
if (auto result = pending_work_.extract(ep); result) {
auto& container = result.mapped();
while (container.size() > 0) {
work_queue_.emplace(container.pop());
}
pending_work_.erase(iter);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vt/scheduler/scheduler.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void Scheduler::enqueueOrPostpone(UnitT unit) {
return;
}
}
} else if (not theTerm()->epochReleased(ep)) {
} else if (not theTerm()->isEpochReleased(ep)) {
pending_work_[ep].push(unit);
return;
}
Expand Down
25 changes: 1 addition & 24 deletions src/vt/termination/termination.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1131,37 +1131,14 @@ void TerminationDetector::releaseEpoch(EpochType epoch) {
// Put the epoch in the released set. The epoch any_epoch_sentinel does not
// count as a succcessor.
epoch_released_.insert(epoch);
runReleaseEpochActions(epoch);
} else {
// The user might have made a mistake if they are trying to release an epoch
// that is released-by-default (not dependent)
vtWarn("Trying to release non-dependent epoch");
}
}

void TerminationDetector::runReleaseEpochActions(EpochType epoch) {
auto iter = epoch_release_action_.find(epoch);
if (iter != epoch_release_action_.end()) {
auto actions = std::move(iter->second);
epoch_release_action_.erase(iter);
for (auto&& fn : actions) {
fn();
}
}
theSched()->releaseEpoch(epoch);
}

void TerminationDetector::onReleaseEpoch(EpochType epoch, ActionType action) {
// Run an action if an epoch has been released
bool const is_dep = isDep(epoch);
if (not is_dep or (is_dep and epochReleased(epoch))) {
action();
} else {
epoch_release_action_[epoch].push_back(action);
}
}

bool TerminationDetector::epochReleased(EpochType epoch) {
bool TerminationDetector::isEpochReleased(EpochType epoch) {
// Because of case (2), ignore dep <- no-dep because this should not be called
// unless dep is released
bool const is_dep = isDep(epoch);
Expand Down
22 changes: 3 additions & 19 deletions src/vt/termination/termination.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,21 +377,14 @@ struct TerminationDetector :
void releaseEpoch(EpochType epoch);

/**
* \brief Action to run on release of a dependent epoch
*
* \param[in] epoch the epoch
* \param[in] action the action
*/
void onReleaseEpoch(EpochType epoch, ActionType action);

/**
* \brief Test if an epoch is dependent and if it is, if that epoch has been released
* \brief Test if an epoch is dependent and if it is, if that epoch has been
* released
*
* \param[in] epoch the epoch
*
* \return if it is released
*/
bool epochReleased(EpochType epoch);
bool isEpochReleased(EpochType epoch);

private:
/**
Expand All @@ -401,13 +394,6 @@ struct TerminationDetector :
*/
void cleanupReleasedEpoch(EpochType epoch);

/**
* \brief Run all actions when an epoch is released
*
* \param[in] epoch the epoch to run actions for
*/
void runReleaseEpochActions(EpochType epoch);

public:
/*
* Directly call into a specific type of rooted epoch, can not be overridden
Expand Down Expand Up @@ -891,8 +877,6 @@ struct TerminationDetector :
EpochStackType epoch_stack_;
// released epoch list for dependent epochs
std::unordered_set<EpochType> epoch_released_ = {};
// release epoch action list for dependent epochs
std::unordered_map<EpochType, ActionListType> epoch_release_action_ = {};
};

}} // end namespace vt::term
Expand Down

0 comments on commit 4b3a9c6

Please sign in to comment.