Skip to content

Commit

Permalink
Add prefetching ActivityRegistry signals for more transitions
Browse files Browse the repository at this point in the history
All non-Event transitions now also have prefetching related
signals.
  • Loading branch information
Dr15Jones committed Jul 12, 2022
1 parent 44487ef commit 25df583
Show file tree
Hide file tree
Showing 19 changed files with 1,370 additions and 82 deletions.
20 changes: 19 additions & 1 deletion FWCore/Framework/interface/maker/Worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,16 @@ namespace edm {
actReg_->postModuleEventPrefetchingSignal_.emit(*moduleCallingContext_.getStreamContext(), moduleCallingContext_);
}

void emitPostModuleStreamPrefetchingSignal() {
actReg_->postModuleStreamPrefetchingSignal_.emit(*moduleCallingContext_.getStreamContext(),
moduleCallingContext_);
}

void emitPostModuleGlobalPrefetchingSignal() {
actReg_->postModuleGlobalPrefetchingSignal_.emit(*moduleCallingContext_.getGlobalContext(),
moduleCallingContext_);
}

virtual bool hasAcquire() const = 0;

template <typename T>
Expand Down Expand Up @@ -422,6 +432,10 @@ namespace edm {
}
}
}
} else if constexpr (std::is_same_v<typename T::Context, StreamContext>) {
m_worker->emitPostModuleStreamPrefetchingSignal();
} else if constexpr (std::is_same_v<typename T::Context, GlobalContext>) {
m_worker->emitPostModuleGlobalPrefetchingSignal();
}

if (not excptr) {
Expand Down Expand Up @@ -916,8 +930,12 @@ namespace edm {

moduleCallingContext_.setContext(ModuleCallingContext::State::kPrefetching, parentContext, nullptr);

if (principal.branchType() == InEvent) {
if constexpr (T::isEvent_) {
actReg_->preModuleEventPrefetchingSignal_.emit(*moduleCallingContext_.getStreamContext(), moduleCallingContext_);
} else if constexpr (std::is_same_v<typename T::Context, StreamContext>) {
actReg_->preModuleStreamPrefetchingSignal_.emit(*moduleCallingContext_.getStreamContext(), moduleCallingContext_);
} else if constexpr (std::is_same_v<typename T::Context, GlobalContext>) {
actReg_->preModuleGlobalPrefetchingSignal_.emit(*moduleCallingContext_.getGlobalContext(), moduleCallingContext_);
}

workerhelper::CallImpl<T>::esPrefetchAsync(this, iTask, token, transitionInfo, iTransition);
Expand Down
49 changes: 34 additions & 15 deletions FWCore/Framework/test/global_filter_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -399,26 +399,34 @@ testGlobalFilter::testGlobalFilter()

m_transToFunc[Trans::kGlobalBeginRun] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionGlobalBegin> Traits;
edm::ParentContext nullParentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kBeginRun, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
m_transToFunc[Trans::kStreamBeginRun] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionStreamBegin> Traits;
edm::ParentContext nullParentContext;
edm::StreamContext streamContext(s_streamID0, nullptr);
edm::ParentContext nullParentContext(&streamContext);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};

m_transToFunc[Trans::kGlobalBeginLuminosityBlock] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionGlobalBegin> Traits;
edm::ParentContext nullParentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kBeginLuminosityBlock, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
m_transToFunc[Trans::kStreamBeginLuminosityBlock] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionStreamBegin> Traits;
edm::ParentContext nullParentContext;
edm::StreamContext streamContext(s_streamID0, nullptr);
edm::ParentContext nullParentContext(&streamContext);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
Expand All @@ -434,26 +442,34 @@ testGlobalFilter::testGlobalFilter()

m_transToFunc[Trans::kStreamEndLuminosityBlock] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionStreamEnd> Traits;
edm::ParentContext nullParentContext;
edm::StreamContext streamContext(s_streamID0, nullptr);
edm::ParentContext nullParentContext(&streamContext);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
m_transToFunc[Trans::kGlobalEndLuminosityBlock] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionGlobalEnd> Traits;
edm::ParentContext nullParentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kEndLuminosityBlock, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};

m_transToFunc[Trans::kStreamEndRun] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionStreamEnd> Traits;
edm::ParentContext nullParentContext;
edm::StreamContext streamContext(s_streamID0, nullptr);
edm::ParentContext nullParentContext(&streamContext);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
m_transToFunc[Trans::kGlobalEndRun] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionGlobalEnd> Traits;
edm::ParentContext nullParentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kEndLuminosityBlock, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
Expand Down Expand Up @@ -487,13 +503,16 @@ namespace {
template <typename T>
void testGlobalFilter::testTransitions(std::shared_ptr<T> iMod, Expectations const& iExpect) {
oneapi::tbb::global_control control(oneapi::tbb::global_control::max_allowed_parallelism, 1);
edm::maker::ModuleHolderT<edm::global::EDFilterBase> h(iMod, nullptr);
h.preallocate(edm::PreallocationConfiguration{});

edm::WorkerT<edm::global::EDFilterBase> w{iMod, m_desc, nullptr};
for (auto& keyVal : m_transToFunc) {
testTransition(iMod, &w, keyVal.first, iExpect, keyVal.second);
}
oneapi::tbb::task_arena arena(1);
arena.execute([&]() {
edm::maker::ModuleHolderT<edm::global::EDFilterBase> h(iMod, nullptr);
h.preallocate(edm::PreallocationConfiguration{});

edm::WorkerT<edm::global::EDFilterBase> w{iMod, m_desc, nullptr};
for (auto& keyVal : m_transToFunc) {
testTransition(iMod, &w, keyVal.first, iExpect, keyVal.second);
}
});
}

void testGlobalFilter::basicTest() {
Expand Down
31 changes: 21 additions & 10 deletions FWCore/Framework/test/global_outputmodule_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,18 @@ testGlobalOutputModule::testGlobalOutputModule()

m_transToFunc[Trans::kGlobalBeginRun] = [this](edm::Worker* iBase, edm::OutputModuleCommunicator*) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionGlobalBegin> Traits;
edm::ParentContext parentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kBeginRun, nullptr);
edm::ParentContext parentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, edm::StreamID::invalidStreamID(), parentContext);
};

m_transToFunc[Trans::kGlobalBeginLuminosityBlock] = [this](edm::Worker* iBase, edm::OutputModuleCommunicator*) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionGlobalBegin> Traits;
edm::ParentContext parentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kBeginLuminosityBlock, nullptr);
edm::ParentContext parentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, edm::StreamID::invalidStreamID(), parentContext);
};
Expand All @@ -217,7 +221,9 @@ testGlobalOutputModule::testGlobalOutputModule()

m_transToFunc[Trans::kGlobalEndLuminosityBlock] = [this](edm::Worker* iBase, edm::OutputModuleCommunicator* iComm) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionGlobalEnd> Traits;
edm::ParentContext parentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kEndLuminosityBlock, nullptr);
edm::ParentContext parentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, edm::StreamID::invalidStreamID(), parentContext);
edm::FinalWaitingTask task;
Expand All @@ -233,7 +239,9 @@ testGlobalOutputModule::testGlobalOutputModule()

m_transToFunc[Trans::kGlobalEndRun] = [this](edm::Worker* iBase, edm::OutputModuleCommunicator* iComm) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionGlobalEnd> Traits;
edm::ParentContext parentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kEndLuminosityBlock, nullptr);
edm::ParentContext parentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, edm::StreamID::invalidStreamID(), parentContext);
edm::FinalWaitingTask task;
Expand Down Expand Up @@ -300,12 +308,15 @@ template <typename T>
void testGlobalOutputModule::testTransitions(std::shared_ptr<T> iMod, Expectations const& iExpect) {
oneapi::tbb::global_control control(oneapi::tbb::global_control::max_allowed_parallelism, 1);

iMod->doPreallocate(m_preallocConfig);
edm::WorkerT<edm::global::OutputModuleBase> w{iMod, m_desc, m_params.actions_};
edm::OutputModuleCommunicatorT<edm::global::OutputModuleBase> comm(iMod.get());
for (auto& keyVal : m_transToFunc) {
testTransition(iMod, &w, &comm, keyVal.first, iExpect, keyVal.second);
}
oneapi::tbb::task_arena arena(1);
arena.execute([&]() {
iMod->doPreallocate(m_preallocConfig);
edm::WorkerT<edm::global::OutputModuleBase> w{iMod, m_desc, m_params.actions_};
edm::OutputModuleCommunicatorT<edm::global::OutputModuleBase> comm(iMod.get());
for (auto& keyVal : m_transToFunc) {
testTransition(iMod, &w, &comm, keyVal.first, iExpect, keyVal.second);
}
});
}

void testGlobalOutputModule::basicTest() {
Expand Down
50 changes: 34 additions & 16 deletions FWCore/Framework/test/global_producer_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -363,26 +363,34 @@ testGlobalProducer::testGlobalProducer()

m_transToFunc[Trans::kGlobalBeginRun] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionGlobalBegin> Traits;
edm::ParentContext nullParentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kBeginRun, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
m_transToFunc[Trans::kStreamBeginRun] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionStreamBegin> Traits;
edm::ParentContext nullParentContext;
edm::StreamContext streamContext(s_streamID0, nullptr);
edm::ParentContext nullParentContext(&streamContext);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};

m_transToFunc[Trans::kGlobalBeginLuminosityBlock] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionGlobalBegin> Traits;
edm::ParentContext nullParentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kBeginLuminosityBlock, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
m_transToFunc[Trans::kStreamBeginLuminosityBlock] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionStreamBegin> Traits;
edm::ParentContext nullParentContext;
edm::StreamContext streamContext(s_streamID0, nullptr);
edm::ParentContext nullParentContext(&streamContext);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
Expand All @@ -398,26 +406,34 @@ testGlobalProducer::testGlobalProducer()

m_transToFunc[Trans::kStreamEndLuminosityBlock] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionStreamEnd> Traits;
edm::ParentContext nullParentContext;
edm::StreamContext streamContext(s_streamID0, nullptr);
edm::ParentContext nullParentContext(&streamContext);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
m_transToFunc[Trans::kGlobalEndLuminosityBlock] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionGlobalEnd> Traits;
edm::ParentContext nullParentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kEndLuminosityBlock, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};

m_transToFunc[Trans::kStreamEndRun] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionStreamEnd> Traits;
edm::ParentContext nullParentContext;
edm::StreamContext streamContext(s_streamID0, nullptr);
edm::ParentContext nullParentContext(&streamContext);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
m_transToFunc[Trans::kGlobalEndRun] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionGlobalEnd> Traits;
edm::ParentContext nullParentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kEndLuminosityBlock, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
Expand Down Expand Up @@ -451,14 +467,16 @@ namespace {
template <typename T>
void testGlobalProducer::testTransitions(std::shared_ptr<T> iMod, Expectations const& iExpect) {
oneapi::tbb::global_control control(oneapi::tbb::global_control::max_allowed_parallelism, 1);

edm::maker::ModuleHolderT<edm::global::EDProducerBase> h(iMod, nullptr);
h.preallocate(edm::PreallocationConfiguration{});

edm::WorkerT<edm::global::EDProducerBase> w{iMod, m_desc, nullptr};
for (auto& keyVal : m_transToFunc) {
testTransition(iMod, &w, keyVal.first, iExpect, keyVal.second);
}
oneapi::tbb::task_arena arena(1);
arena.execute([&]() {
edm::maker::ModuleHolderT<edm::global::EDProducerBase> h(iMod, nullptr);
h.preallocate(edm::PreallocationConfiguration{});

edm::WorkerT<edm::global::EDProducerBase> w{iMod, m_desc, nullptr};
for (auto& keyVal : m_transToFunc) {
testTransition(iMod, &w, keyVal.first, iExpect, keyVal.second);
}
});
}

void testGlobalProducer::basicTest() {
Expand Down
32 changes: 24 additions & 8 deletions FWCore/Framework/test/limited_filter_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -427,26 +427,34 @@ testLimitedFilter::testLimitedFilter()

m_transToFunc[Trans::kGlobalBeginRun] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionGlobalBegin> Traits;
edm::ParentContext nullParentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kBeginRun, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
m_transToFunc[Trans::kStreamBeginRun] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionStreamBegin> Traits;
edm::ParentContext nullParentContext;
edm::StreamContext streamContext(s_streamID0, nullptr);
edm::ParentContext nullParentContext(&streamContext);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};

m_transToFunc[Trans::kGlobalBeginLuminosityBlock] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionGlobalBegin> Traits;
edm::ParentContext nullParentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kBeginLuminosityBlock, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
m_transToFunc[Trans::kStreamBeginLuminosityBlock] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionStreamBegin> Traits;
edm::ParentContext nullParentContext;
edm::StreamContext streamContext(s_streamID0, nullptr);
edm::ParentContext nullParentContext(&streamContext);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
Expand All @@ -462,26 +470,34 @@ testLimitedFilter::testLimitedFilter()

m_transToFunc[Trans::kStreamEndLuminosityBlock] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionStreamEnd> Traits;
edm::ParentContext nullParentContext;
edm::StreamContext streamContext(s_streamID0, nullptr);
edm::ParentContext nullParentContext(&streamContext);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
m_transToFunc[Trans::kGlobalEndLuminosityBlock] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::LuminosityBlockPrincipal, edm::BranchActionGlobalEnd> Traits;
edm::ParentContext nullParentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kEndLuminosityBlock, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::LumiTransitionInfo info(*m_lbp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};

m_transToFunc[Trans::kStreamEndRun] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionStreamEnd> Traits;
edm::ParentContext nullParentContext;
edm::StreamContext streamContext(s_streamID0, nullptr);
edm::ParentContext nullParentContext(&streamContext);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
m_transToFunc[Trans::kGlobalEndRun] = [this](edm::Worker* iBase) {
typedef edm::OccurrenceTraits<edm::RunPrincipal, edm::BranchActionGlobalEnd> Traits;
edm::ParentContext nullParentContext;
edm::GlobalContext gc(edm::GlobalContext::Transition::kEndLuminosityBlock, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
Expand Down
Loading

0 comments on commit 25df583

Please sign in to comment.