Skip to content

Commit 6002914

Browse files
authored
Merge pull request #48774 from Parsifal-2045/fts_unsupportedSignal48062
Add support for `{pre,post}ModuleEventDelayedGet` signals to the `FastTimerService`
2 parents 4eb6ddc + bdca867 commit 6002914

File tree

2 files changed

+44
-35
lines changed

2 files changed

+44
-35
lines changed

HLTrigger/Timer/plugins/FastTimerService.cc

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,16 @@ FastTimerService::Resources FastTimerService::AtomicResources::operator+(Resourc
174174

175175
// ResourcesPerModule
176176

177-
FastTimerService::ResourcesPerModule::ResourcesPerModule() noexcept : total(), events(0), has_acquire(false) {}
177+
FastTimerService::ResourcesPerModule::ResourcesPerModule() noexcept : total(), events(0) {}
178178

179179
void FastTimerService::ResourcesPerModule::reset() noexcept {
180180
total.reset();
181181
events = 0;
182-
has_acquire = false;
183182
}
184183

185184
FastTimerService::ResourcesPerModule& FastTimerService::ResourcesPerModule::operator+=(ResourcesPerModule const& other) {
186185
total += other.total;
187186
events += other.events;
188-
has_acquire = has_acquire or other.has_acquire;
189187
return *this;
190188
}
191189

@@ -261,6 +259,7 @@ void FastTimerService::ResourcesPerJob::reset() {
261259
total.reset();
262260
overhead.reset();
263261
idle.reset();
262+
source.reset();
264263
eventsetup.reset();
265264
event.reset();
266265
for (auto& module : highlight)
@@ -275,6 +274,7 @@ FastTimerService::ResourcesPerJob& FastTimerService::ResourcesPerJob::operator+=
275274
total += other.total;
276275
overhead += other.overhead;
277276
idle += other.idle;
277+
source += other.source;
278278
eventsetup += other.eventsetup;
279279
event += other.event;
280280
assert(highlight.size() == other.highlight.size());
@@ -696,8 +696,7 @@ void FastTimerService::PlotsPerJob::book(dqm::reco::DQMStore::IBooker& booker,
696696
event_ex_.book(booker, "explicit", "Event (explicit)", event_ranges, lumisections, byls);
697697
overhead_.book(booker, "overhead", "Overhead", event_ranges, lumisections, byls);
698698
idle_.book(booker, "idle", "Idle", event_ranges, lumisections, byls);
699-
700-
modules_[job.source().id()].book(booker, "source", "Source", module_ranges, lumisections, byls);
699+
source_.book(booker, "source", "Source", event_ranges, lumisections, byls);
701700

702701
if (transitions) {
703702
lumi_.book(booker, "lumi", "LumiSection transitions", event_ranges, lumisections, byls);
@@ -733,6 +732,7 @@ void FastTimerService::PlotsPerJob::fill(ProcessCallGraph const& job, ResourcesP
733732
event_ex_.fill(data.event, ls);
734733
overhead_.fill(data.overhead, ls);
735734
idle_.fill(data.idle, ls);
735+
source_.fill(data.source, ls);
736736

737737
// fill highltight plots
738738
for (unsigned int group : boost::irange(0ul, highlight_.size()))
@@ -972,6 +972,10 @@ void FastTimerService::lookupInitializationComplete(edm::PathsAndConsumesOfModul
972972
highlight_modules_[group].modules.reserve(labels.size());
973973
// convert the module labels in module ids
974974
for (unsigned int i = 0; i < modules; ++i) {
975+
if (i == callgraph_.source().id()) {
976+
// skip the source module
977+
continue;
978+
}
975979
auto const& label = callgraph_.module(i).moduleLabel();
976980
if (std::binary_search(labels.begin(), labels.end(), label))
977981
highlight_modules_[group].modules.push_back(i);
@@ -1130,8 +1134,7 @@ void FastTimerService::printEvent(T& out, ResourcesPerJob const& data) const {
11301134
printHeader(out, "Event");
11311135
printEventHeader(out, "Modules");
11321136
auto const& source_d = callgraph_.source();
1133-
auto const& source = data.modules[source_d.id()];
1134-
printEventLine(out, source.total, source_d.moduleLabel());
1137+
printEventLine(out, data.source, source_d.moduleLabel());
11351138
auto const& proc_d = callgraph_.processDescription();
11361139
auto const& proc = data.process;
11371140
printEventLine(out, proc.total, "process " + proc_d.name_);
@@ -1143,7 +1146,7 @@ void FastTimerService::printEvent(T& out, ResourcesPerJob const& data) const {
11431146
printEventLine(out, data.total, "total");
11441147
out << '\n';
11451148
printEventHeader(out, "Processes and Paths");
1146-
printEventLine(out, source.total, source_d.moduleLabel());
1149+
printEventLine(out, data.source, source_d.moduleLabel());
11471150
printEventLine(out, proc.total, "process " + proc_d.name_);
11481151
for (unsigned int p = 0; p < proc.paths.size(); ++p) {
11491152
auto const& name = proc_d.paths_[p].name_;
@@ -1277,8 +1280,7 @@ void FastTimerService::printSummary(T& out, ResourcesPerJob const& data, std::st
12771280
printHeader(out, label);
12781281
printSummaryHeader(out, "Modules", true);
12791282
auto const& source_d = callgraph_.source();
1280-
auto const& source = data.modules[source_d.id()];
1281-
printSummaryLine(out, source.total, data.events, source.events, source_d.moduleLabel());
1283+
printSummaryLine(out, data.source, data.events, source_d.moduleLabel());
12821284
auto const& proc_d = callgraph_.processDescription();
12831285
auto const& proc = data.process;
12841286
printSummaryLine(out, proc.total, data.events, "process " + proc_d.name_);
@@ -1293,7 +1295,7 @@ void FastTimerService::printSummary(T& out, ResourcesPerJob const& data, std::st
12931295
printSummaryLine(out, data.idle, data.events, "idle");
12941296
out << '\n';
12951297
printPathSummaryHeader(out, "Processes and Paths");
1296-
printSummaryLine(out, source.total, data.events, source_d.moduleLabel());
1298+
printSummaryLine(out, data.source, data.events, source_d.moduleLabel());
12971299
printSummaryLine(out, proc.total, data.events, "process " + proc_d.name_);
12981300
for (unsigned int p = 0; p < proc.paths.size(); ++p) {
12991301
auto const& name = proc_d.paths_[p].name_;
@@ -1365,9 +1367,14 @@ void FastTimerService::writeSummaryJSON(ResourcesPerJob const& data, std::string
13651367
// write the resources used by every module
13661368
j["modules"] = json::array();
13671369
for (unsigned int i = 0; i < callgraph_.size(); ++i) {
1368-
auto const& module = callgraph_.module(i);
1369-
auto const& data_m = data.modules[i];
1370-
j["modules"].push_back(encodeToJSON(module, data_m));
1370+
if (i == callgraph_.source().id()) {
1371+
j["modules"].push_back(
1372+
encodeToJSON(callgraph_.source().moduleName(), callgraph_.source().moduleLabel(), data.events, data.source));
1373+
} else {
1374+
auto const& module = callgraph_.module(i);
1375+
auto const& data_m = data.modules[i];
1376+
j["modules"].push_back(encodeToJSON(module, data_m));
1377+
}
13711378
}
13721379

13731380
// add an entry for the non-event transitions, modules, and idle states
@@ -1390,8 +1397,9 @@ void FastTimerService::postEvent(edm::StreamContext const& sc) {
13901397

13911398
// measure the event resources as the sum of all modules' resources
13921399
auto& data = stream.process.total;
1393-
for (unsigned int id : process.modules_)
1400+
for (unsigned int id : process.modules_) {
13941401
data += stream.modules[id].total;
1402+
}
13951403
stream.total += data;
13961404

13971405
// handle the summaries and fill the plots
@@ -1400,8 +1408,7 @@ void FastTimerService::postEvent(edm::StreamContext const& sc) {
14001408
stream.event_measurement.measure_and_store(stream.event);
14011409

14021410
// add to the event resources those used by source (which is not part of any process)
1403-
unsigned int id = 0;
1404-
stream.total += stream.modules[id].total;
1411+
stream.total += stream.source;
14051412

14061413
// highlighted modules
14071414
for (unsigned int group : boost::irange(0ul, highlight_modules_.size()))
@@ -1438,13 +1445,9 @@ void FastTimerService::preSourceEvent(edm::StreamID sid) {
14381445
}
14391446

14401447
void FastTimerService::postSourceEvent(edm::StreamID sid) {
1441-
edm::ModuleDescription const& md = callgraph_.source();
1442-
unsigned int id = md.id();
14431448
auto& stream = streams_[sid];
1444-
auto& module = stream.modules[id];
14451449

1446-
thread().measure_and_store(module.total);
1447-
++stream.modules[id].events;
1450+
thread().measure_and_accumulate(stream.source);
14481451
}
14491452

14501453
void FastTimerService::prePathEvent(edm::StreamContext const& sc, edm::PathContext const& pc) {
@@ -1492,7 +1495,6 @@ void FastTimerService::postModuleEventAcquire(edm::StreamContext const& sc, edm:
14921495
auto& stream = streams_[sid];
14931496
auto& module = stream.modules[id];
14941497

1495-
module.has_acquire = true;
14961498
thread().measure_and_store(module.total);
14971499
}
14981500

@@ -1509,20 +1511,29 @@ void FastTimerService::postModuleEvent(edm::StreamContext const& sc, edm::Module
15091511
auto& stream = streams_[sid];
15101512
auto& module = stream.modules[id];
15111513

1512-
if (module.has_acquire) {
1513-
thread().measure_and_accumulate(module.total);
1514-
} else {
1515-
thread().measure_and_store(module.total);
1516-
}
1514+
thread().measure_and_accumulate(module.total);
15171515
++module.events;
15181516
}
15191517

15201518
void FastTimerService::preModuleEventDelayedGet(edm::StreamContext const& sc, edm::ModuleCallingContext const& mcc) {
1521-
unsupportedSignal(__func__);
1519+
edm::ModuleDescription const& md = *mcc.moduleDescription();
1520+
unsigned int id = md.id();
1521+
unsigned int sid = sc.streamID().value();
1522+
auto& stream = streams_[sid];
1523+
auto& module = stream.modules[id];
1524+
1525+
if (mcc.state() == edm::ModuleCallingContext::State::kRunning) {
1526+
thread().measure_and_accumulate(module.total);
1527+
}
15221528
}
15231529

15241530
void FastTimerService::postModuleEventDelayedGet(edm::StreamContext const& sc, edm::ModuleCallingContext const& mcc) {
1525-
unsupportedSignal(__func__);
1531+
unsigned int sid = sc.streamID().value();
1532+
auto& stream = streams_[sid];
1533+
1534+
if (mcc.state() == edm::ModuleCallingContext::State::kRunning) {
1535+
thread().measure_and_accumulate(stream.source);
1536+
}
15261537
}
15271538

15281539
void FastTimerService::preModuleEventPrefetching(edm::StreamContext const& sc, edm::ModuleCallingContext const& mcc) {
@@ -1542,12 +1553,9 @@ void FastTimerService::preEventReadFromSource(edm::StreamContext const& sc, edm:
15421553

15431554
void FastTimerService::postEventReadFromSource(edm::StreamContext const& sc, edm::ModuleCallingContext const& mcc) {
15441555
if (mcc.state() == edm::ModuleCallingContext::State::kPrefetching) {
1545-
edm::ModuleDescription const& md = callgraph_.source();
1546-
unsigned int id = md.id();
15471556
auto& stream = streams_[sc.streamID()];
1548-
auto& module = stream.modules[id];
15491557

1550-
thread().measure_and_accumulate(module.total);
1558+
thread().measure_and_accumulate(stream.source);
15511559
}
15521560
}
15531561

HLTrigger/Timer/plugins/FastTimerService.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ class FastTimerService : public tbb::task_scheduler_observer {
268268
public:
269269
Resources total;
270270
unsigned events;
271-
bool has_acquire; // whether this module has an acquire() method
272271
};
273272

274273
struct ResourcesPerPath {
@@ -311,6 +310,7 @@ class FastTimerService : public tbb::task_scheduler_observer {
311310
AtomicResources overhead;
312311
AtomicResources eventsetup;
313312
AtomicResources idle;
313+
AtomicResources source;
314314
Resources event; // total time etc. spent between preSourceEvent and postEvent
315315
Measurement event_measurement;
316316
std::vector<Resources> highlight;
@@ -439,6 +439,7 @@ class FastTimerService : public tbb::task_scheduler_observer {
439439
PlotsPerElement event_ex_;
440440
PlotsPerElement overhead_;
441441
PlotsPerElement idle_;
442+
PlotsPerElement source_;
442443
// resources spent in the modules' lumi and run transitions
443444
PlotsPerElement lumi_;
444445
PlotsPerElement run_;

0 commit comments

Comments
 (0)