Skip to content

Commit 4b3a9c6

Browse files
committed
#410: termination: remove unneeded code, cleanup scheduler
1 parent cb2b519 commit 4b3a9c6

File tree

4 files changed

+7
-47
lines changed

4 files changed

+7
-47
lines changed

src/vt/scheduler/scheduler.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,11 @@ void Scheduler::resume(ThreadIDType tid) {
385385
}
386386

387387
void Scheduler::releaseEpoch(EpochType ep) {
388-
if (auto iter = pending_work_.find(ep); iter != pending_work_.end()) {
389-
auto& container = iter->second;
388+
if (auto result = pending_work_.extract(ep); result) {
389+
auto& container = result.mapped();
390390
while (container.size() > 0) {
391391
work_queue_.emplace(container.pop());
392392
}
393-
pending_work_.erase(iter);
394393
}
395394
}
396395

src/vt/scheduler/scheduler.impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void Scheduler::enqueueOrPostpone(UnitT unit) {
143143
return;
144144
}
145145
}
146-
} else if (not theTerm()->epochReleased(ep)) {
146+
} else if (not theTerm()->isEpochReleased(ep)) {
147147
pending_work_[ep].push(unit);
148148
return;
149149
}

src/vt/termination/termination.cc

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,37 +1131,14 @@ void TerminationDetector::releaseEpoch(EpochType epoch) {
11311131
// Put the epoch in the released set. The epoch any_epoch_sentinel does not
11321132
// count as a succcessor.
11331133
epoch_released_.insert(epoch);
1134-
runReleaseEpochActions(epoch);
11351134
} else {
11361135
// The user might have made a mistake if they are trying to release an epoch
11371136
// that is released-by-default (not dependent)
11381137
vtWarn("Trying to release non-dependent epoch");
11391138
}
11401139
}
11411140

1142-
void TerminationDetector::runReleaseEpochActions(EpochType epoch) {
1143-
auto iter = epoch_release_action_.find(epoch);
1144-
if (iter != epoch_release_action_.end()) {
1145-
auto actions = std::move(iter->second);
1146-
epoch_release_action_.erase(iter);
1147-
for (auto&& fn : actions) {
1148-
fn();
1149-
}
1150-
}
1151-
theSched()->releaseEpoch(epoch);
1152-
}
1153-
1154-
void TerminationDetector::onReleaseEpoch(EpochType epoch, ActionType action) {
1155-
// Run an action if an epoch has been released
1156-
bool const is_dep = isDep(epoch);
1157-
if (not is_dep or (is_dep and epochReleased(epoch))) {
1158-
action();
1159-
} else {
1160-
epoch_release_action_[epoch].push_back(action);
1161-
}
1162-
}
1163-
1164-
bool TerminationDetector::epochReleased(EpochType epoch) {
1141+
bool TerminationDetector::isEpochReleased(EpochType epoch) {
11651142
// Because of case (2), ignore dep <- no-dep because this should not be called
11661143
// unless dep is released
11671144
bool const is_dep = isDep(epoch);

src/vt/termination/termination.h

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -377,21 +377,14 @@ struct TerminationDetector :
377377
void releaseEpoch(EpochType epoch);
378378

379379
/**
380-
* \brief Action to run on release of a dependent epoch
381-
*
382-
* \param[in] epoch the epoch
383-
* \param[in] action the action
384-
*/
385-
void onReleaseEpoch(EpochType epoch, ActionType action);
386-
387-
/**
388-
* \brief Test if an epoch is dependent and if it is, if that epoch has been released
380+
* \brief Test if an epoch is dependent and if it is, if that epoch has been
381+
* released
389382
*
390383
* \param[in] epoch the epoch
391384
*
392385
* \return if it is released
393386
*/
394-
bool epochReleased(EpochType epoch);
387+
bool isEpochReleased(EpochType epoch);
395388

396389
private:
397390
/**
@@ -401,13 +394,6 @@ struct TerminationDetector :
401394
*/
402395
void cleanupReleasedEpoch(EpochType epoch);
403396

404-
/**
405-
* \brief Run all actions when an epoch is released
406-
*
407-
* \param[in] epoch the epoch to run actions for
408-
*/
409-
void runReleaseEpochActions(EpochType epoch);
410-
411397
public:
412398
/*
413399
* Directly call into a specific type of rooted epoch, can not be overridden
@@ -891,8 +877,6 @@ struct TerminationDetector :
891877
EpochStackType epoch_stack_;
892878
// released epoch list for dependent epochs
893879
std::unordered_set<EpochType> epoch_released_ = {};
894-
// release epoch action list for dependent epochs
895-
std::unordered_map<EpochType, ActionListType> epoch_release_action_ = {};
896880
};
897881

898882
}} // end namespace vt::term

0 commit comments

Comments
 (0)