Skip to content

Commit

Permalink
Improve MessageLogger context for ProcessBlock
Browse files Browse the repository at this point in the history
Affects only MessageLogger context strings.
Handle the case where ProcessBlock transitions go
into a nonblocking wait and TBB runs another module
on the same thread. Handles this context the same as
for Run transitions.
  • Loading branch information
wddgit committed Jul 15, 2021
1 parent 0dd6d39 commit 5a777f0
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 35 deletions.
83 changes: 52 additions & 31 deletions FWCore/MessageService/plugins/MessageLogger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace {
"@beginLumi",
"@endLumi",
"@endRun",
"@kEndProcessBlock",
"@endProcessBlock",
"@endJob",
"@writeProcessBlock",
"@writeRun",
Expand Down Expand Up @@ -207,11 +207,13 @@ namespace edm {

iRegistry.watchPreallocate([this](edm::service::SystemBounds const& iBounds) {
//reserve the proper amount of space to record the transition info
constexpr unsigned int maxNumberOfConcurrentProcessBlocks = 1;
this->transitionInfoCache_.resize(iBounds.maxNumberOfStreams() +
iBounds.maxNumberOfConcurrentLuminosityBlocks() +
iBounds.maxNumberOfConcurrentRuns());
iBounds.maxNumberOfConcurrentRuns() + maxNumberOfConcurrentProcessBlocks);
lumiInfoBegin_ = iBounds.maxNumberOfStreams();
runInfoBegin_ = lumiInfoBegin_ + iBounds.maxNumberOfConcurrentLuminosityBlocks();
processBlockInfoBegin_ = runInfoBegin_ + iBounds.maxNumberOfConcurrentRuns();

setMaxLoggedErrorsSummaryIndicies(iBounds.maxNumberOfStreams());
});
Expand Down Expand Up @@ -337,9 +339,14 @@ namespace edm {
establishModule(lumiInfoBegin_ + globalContext->luminosityBlockIndex(),
iModContext,
s_globalTransitionNames[static_cast<int>(tran)]);
} else {
} else if (tran == GlobalContext::Transition::kBeginRun or tran == GlobalContext::Transition::kEndRun) {
establishModule(
runInfoBegin_ + globalContext->runIndex(), iModContext, s_globalTransitionNames[static_cast<int>(tran)]);
} else {
assert(tran == GlobalContext::Transition::kBeginProcessBlock ||
tran == GlobalContext::Transition::kAccessInputProcessBlock ||
tran == GlobalContext::Transition::kEndProcessBlock);
establishModule(processBlockInfoBegin_, iModContext, s_globalTransitionNames[static_cast<int>(tran)]);
}
} else {
auto stream = iModContext.getStreamContext();
Expand Down Expand Up @@ -455,9 +462,14 @@ namespace edm {
establishModule(lumiInfoBegin_ + globalContext->luminosityBlockIndex(),
*previous,
s_globalTransitionNames[static_cast<int>(tran)]);
} else {
} else if (tran == GlobalContext::Transition::kBeginRun or tran == GlobalContext::Transition::kEndRun) {
establishModule(
runInfoBegin_ + globalContext->runIndex(), *previous, s_globalTransitionNames[static_cast<int>(tran)]);
} else {
assert(tran == GlobalContext::Transition::kBeginProcessBlock ||
tran == GlobalContext::Transition::kAccessInputProcessBlock ||
tran == GlobalContext::Transition::kEndProcessBlock);
establishModule(processBlockInfoBegin_, *previous, s_globalTransitionNames[static_cast<int>(tran)]);
}
} else {
auto stream = previous->getStreamContext();
Expand Down Expand Up @@ -617,34 +629,34 @@ namespace edm {

//Global

void MessageLogger::preModuleBeginProcessBlock(GlobalContext const& gc, ModuleCallingContext const& mcc) {
ModuleDescription const& desc = *mcc.moduleDescription();
establishModule(desc, "@beginProcessBlock");
void MessageLogger::preModuleBeginProcessBlock(GlobalContext const&, ModuleCallingContext const& mod) {
establishModule(processBlockInfoBegin_,
mod,
s_globalTransitionNames[static_cast<int>(GlobalContext::Transition::kBeginProcessBlock)]);
}

void MessageLogger::postModuleBeginProcessBlock(GlobalContext const& gc, ModuleCallingContext const& mcc) {
ModuleDescription const& desc = *mcc.moduleDescription();
unEstablishModule(desc, "After module BeginProcessBlock");
void MessageLogger::postModuleBeginProcessBlock(GlobalContext const&, ModuleCallingContext const& mod) {
unEstablishModule(mod, "AfterModBeginProcessBlock");
}

void MessageLogger::preModuleAccessInputProcessBlock(GlobalContext const& gc, ModuleCallingContext const& mcc) {
ModuleDescription const& desc = *mcc.moduleDescription();
establishModule(desc, "@accessInputProcessBlock");
void MessageLogger::preModuleAccessInputProcessBlock(GlobalContext const&, ModuleCallingContext const& mod) {
establishModule(processBlockInfoBegin_,
mod,
s_globalTransitionNames[static_cast<int>(GlobalContext::Transition::kAccessInputProcessBlock)]);
}

void MessageLogger::postModuleAccessInputProcessBlock(GlobalContext const& gc, ModuleCallingContext const& mcc) {
ModuleDescription const& desc = *mcc.moduleDescription();
unEstablishModule(desc, "After module AccessInputProcessBlock");
void MessageLogger::postModuleAccessInputProcessBlock(GlobalContext const&, ModuleCallingContext const& mod) {
unEstablishModule(mod, "AfterModAccessInputProcessBlock");
}

void MessageLogger::preModuleEndProcessBlock(GlobalContext const& gc, ModuleCallingContext const& mcc) {
ModuleDescription const& desc = *mcc.moduleDescription();
establishModule(desc, "@endProcessBlock");
void MessageLogger::preModuleEndProcessBlock(GlobalContext const&, ModuleCallingContext const& mod) {
establishModule(processBlockInfoBegin_,
mod,
s_globalTransitionNames[static_cast<int>(GlobalContext::Transition::kEndProcessBlock)]);
}

void MessageLogger::postModuleEndProcessBlock(GlobalContext const& gc, ModuleCallingContext const& mcc) {
ModuleDescription const& desc = *mcc.moduleDescription();
unEstablishModule(desc, "After module EndProcessBlock");
void MessageLogger::postModuleEndProcessBlock(GlobalContext const&, ModuleCallingContext const& mod) {
unEstablishModule(mod, "AfterModEndProcessBlock");
}

void MessageLogger::preModuleGlobalBeginRun(GlobalContext const& context, ModuleCallingContext const& mod) {
Expand Down Expand Up @@ -796,30 +808,39 @@ namespace edm {
}

void MessageLogger::preBeginProcessBlock(GlobalContext const& gc) {
edm::MessageDrop::instance()->runEvent = "pre-events";
edm::MessageDrop::instance()->setSinglet("BeginProcessBlock");
auto& buffer = transitionInfoCache_[processBlockInfoBegin_];
auto v = fill_buffer(buffer, "pre-events");
edm::MessageDrop::instance()->runEvent = v;
edm::MessageDrop::instance()->setSinglet("PreBeginProcessBlock");
}

void MessageLogger::postBeginProcessBlock(GlobalContext const& gc) {
edm::MessageDrop::instance()->setSinglet("After BeginProcessBlock");
edm::MessageDrop::instance()->runEvent = "PostBeginProcessBlock";
edm::MessageDrop::instance()->setSinglet("PostBeginProcessBlock");
}

void MessageLogger::preAccessInputProcessBlock(GlobalContext const& gc) {
edm::MessageDrop::instance()->runEvent = "pre-events";
edm::MessageDrop::instance()->setSinglet("AccessInputProcessBlock");
auto& buffer = transitionInfoCache_[processBlockInfoBegin_];
auto v = fill_buffer(buffer, "pre-events");
edm::MessageDrop::instance()->runEvent = v;
edm::MessageDrop::instance()->setSinglet("PreAccessInputProcessBlock");
}

void MessageLogger::postAccessInputProcessBlock(GlobalContext const& gc) {
edm::MessageDrop::instance()->setSinglet("After AccessInputProcessBlock");
edm::MessageDrop::instance()->runEvent = "PostAccessInputProcessBlock";
edm::MessageDrop::instance()->setSinglet("PostAccessInputProcessBlock");
}

void MessageLogger::preEndProcessBlock(GlobalContext const& gc) {
edm::MessageDrop::instance()->runEvent = "post-events";
edm::MessageDrop::instance()->setSinglet("EndProcessBlock");
auto& buffer = transitionInfoCache_[processBlockInfoBegin_];
auto v = fill_buffer(buffer, "post-events");
edm::MessageDrop::instance()->runEvent = v;
edm::MessageDrop::instance()->setSinglet("PreEndProcessBlock");
}

void MessageLogger::postEndProcessBlock(GlobalContext const& gc) {
edm::MessageDrop::instance()->setSinglet("After EndProcessBlock");
edm::MessageDrop::instance()->runEvent = "PostEndProcessBlock";
edm::MessageDrop::instance()->setSinglet("PostEndProcessBlock");
}

void MessageLogger::preGlobalBeginRun(GlobalContext const& iContext) // change log 14
Expand Down
1 change: 1 addition & 0 deletions FWCore/MessageService/plugins/MessageLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ namespace edm {
std::vector<std::array<char, 64>> transitionInfoCache_;
unsigned int lumiInfoBegin_ = 0;
unsigned int runInfoBegin_ = 0;
unsigned int processBlockInfoBegin_ = 0;

std::set<std::string> debugEnabledModules_;
std::map<std::string, messagelogger::ELseverityLevel> suppression_levels_;
Expand Down
8 changes: 4 additions & 4 deletions FWCore/MessageService/test/unit_test_outputs/u33_all.log
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ T1 beginJob warning with identifier 11 event 0
%MSG-w cat_BJ: UTC_V1:ssm_1b@beginJob pre-events
T1 beginJob warning with identifier 12 event 0
%MSG
%MSG-e TestMessageLogger: BeginProcessBlock pre-events
%MSG-e TestMessageLogger: PreBeginProcessBlock pre-events
test message from TestService::preBeginProcessBlock
%MSG
%MSG-i cat_BPB: UTC_V1:ssm_1a@beginProcessBlock pre-events
Expand Down Expand Up @@ -105,7 +105,7 @@ test message from TestService::preGlobalEndLumi
%MSG-e TestMessageLogger: PreGlobalEndRun End Run: 1
test message from TestService::preGlobalEndRun
%MSG
%MSG-e TestMessageLogger: EndProcessBlock post-events
%MSG-e TestMessageLogger: PreEndProcessBlock post-events
test message from TestService::preEndProcessBlock
%MSG
%MSG-i cat_EPB: UTC_V1:ssm_1a@endProcessBlock post-events
Expand Down Expand Up @@ -139,8 +139,8 @@ MessageLogger Summary
16 cat_BJ -w UTC_V1:ssm_1b@be 1 1
17 cat_BL -w UTC_V1:ssm_1a@be 1 1
18 cat_BL -w UTC_V1:ssm_1b@be 1 1
19 TestMessageLogger -e BeginProcessBloc 1 1
20 TestMessageLogger -e EndProcessBlock 1 1
19 TestMessageLogger -e PreBeginProcessB 1 1
20 TestMessageLogger -e PreEndProcessBlo 1 1
21 TestMessageLogger -e PreGlobalBeginLu 1 1
22 TestMessageLogger -e PreGlobalBeginRu 1 1
23 TestMessageLogger -e PreGlobalEndLumi 1 1
Expand Down

0 comments on commit 5a777f0

Please sign in to comment.