Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prefetching ActivityRegistry signals for more transitions #38708

Merged
merged 1 commit into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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::kEndRun, 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::kEndRun, 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::kEndRun, 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::kEndRun, nullptr);
edm::ParentContext nullParentContext(&gc);
iBase->setActivityRegistry(m_actReg);
edm::RunTransitionInfo info(*m_rp, *m_es);
doWork<Traits>(iBase, info, nullParentContext);
};
Expand Down
Loading