CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
ModuleAllocMonitor Class Reference

Public Member Functions

 ModuleAllocMonitor (edm::ParameterSet const &iPS, edm::ActivityRegistry &iAR)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &iDesc)
 

Private Member Functions

bool forThisModule (unsigned int iID)
 

Private Attributes

edm::service::moduleAlloc::Filter filter_
 
std::vector< int > moduleIDs_
 
std::vector< std::string > moduleNames_
 
std::atomic< unsigned int > nEventsStarted_ {0}
 
unsigned int nEventsToSkip_ = 0
 

Detailed Description

Definition at line 240 of file ModuleAllocMonitor.cc.

Constructor & Destructor Documentation

◆ ModuleAllocMonitor()

ModuleAllocMonitor::ModuleAllocMonitor ( edm::ParameterSet const &  iPS,
edm::ActivityRegistry iAR 
)
inline

Definition at line 242 of file ModuleAllocMonitor.cc.

References cms::perftools::AllocMonitorRegistry::createAndRegisterMonitor(), makeListRunsInFiles::description, spr::find(), newFWLiteAna::found, edm::ParameterSet::getUntrackedParameter(), cms::perftools::AllocMonitorRegistry::instance(), label, edm::service::moduleAlloc::setupFile(), jetUpdater_cfi::sort, AlCaHLTBitMon_QueryRunRegistry::string, funct::void, edm::ActivityRegistry::watchPostESModuleRegistration(), edm::ActivityRegistry::watchPreModuleConstruction(), and edm::ActivityRegistry::watchPreSourceEvent().

243  : moduleNames_(iPS.getUntrackedParameter<std::vector<std::string>>("moduleNames")),
244  nEventsToSkip_(iPS.getUntrackedParameter<unsigned int>("nEventsToSkip")),
245  filter_(&moduleIDs_) {
247 
248  if (nEventsToSkip_ > 0) {
249  filter_.setGlobalKeep(false);
250  }
251  if (not moduleNames_.empty()) {
252  iAR.watchPreModuleConstruction([this](auto const& description) {
253  auto found = std::find(moduleNames_.begin(), moduleNames_.end(), description.moduleLabel());
254  if (found != moduleNames_.end()) {
255  moduleIDs_.push_back(description.id());
256  std::sort(moduleIDs_.begin(), moduleIDs_.end());
257  }
258  });
259 
260  iAR.watchPostESModuleRegistration([this](auto const& iDescription) {
261  auto label = iDescription.label_;
262  if (label.empty()) {
263  label = iDescription.type_;
264  }
265  auto found = std::find(moduleNames_.begin(), moduleNames_.end(), label);
266  if (found != moduleNames_.end()) {
267  //NOTE: we want the id to start at 1 not 0
268  moduleIDs_.push_back(-1 * (iDescription.id_ + 1));
269  std::sort(moduleIDs_.begin(), moduleIDs_.end());
270  }
271  });
272  }
273  if (nEventsToSkip_ > 0) {
274  iAR.watchPreSourceEvent([this](auto) {
275  ++nEventsStarted_;
277  filter_.setGlobalKeep(true);
278  }
279  });
280  }
281  edm::service::moduleAlloc::setupFile(iPS.getUntrackedParameter<std::string>("fileName"), iAR, &filter_);
282  }
void watchPostESModuleRegistration(PostESModuleRegistration::slot_type const &iSlot)
void watchPreModuleConstruction(PreModuleConstruction::slot_type const &iSlot)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::atomic< unsigned int > nEventsStarted_
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
char const * label
static AllocMonitorRegistry & instance()
void setupFile(std::string const &iFileName, edm::ActivityRegistry &iRegistry, Filter const *iFilter)
edm::service::moduleAlloc::Filter filter_
std::vector< int > moduleIDs_
std::vector< std::string > moduleNames_
void watchPreSourceEvent(PreSourceEvent::slot_type const &iSlot)

Member Function Documentation

◆ fillDescriptions()

static void ModuleAllocMonitor::fillDescriptions ( edm::ConfigurationDescriptions iDesc)
inlinestatic

Definition at line 284 of file ModuleAllocMonitor.cc.

References edm::ConfigurationDescriptions::addDefault(), edm::ParameterSetDescription::addUntracked(), and AlCaHLTBitMon_QueryRunRegistry::string.

284  {
286  ps.addUntracked<std::string>("fileName");
287  ps.addUntracked<std::vector<std::string>>("moduleNames", std::vector<std::string>());
288  ps.addUntracked<unsigned int>("nEventsToSkip", 0);
289  iDesc.addDefault(ps);
290  }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void addDefault(ParameterSetDescription const &psetDescription)

◆ forThisModule()

bool ModuleAllocMonitor::forThisModule ( unsigned int  iID)
inlineprivate

Definition at line 293 of file ModuleAllocMonitor.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::lst::binary_search(), and or.

293  {
294  return (moduleNames_.empty() or std::binary_search(moduleIDs_.begin(), moduleIDs_.end(), iID));
295  }
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE int binary_search(const unsigned int *data, unsigned int search_val, unsigned int ndata)
Definition: Hit.h:59
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::vector< int > moduleIDs_
std::vector< std::string > moduleNames_

Member Data Documentation

◆ filter_

edm::service::moduleAlloc::Filter ModuleAllocMonitor::filter_
private

Definition at line 300 of file ModuleAllocMonitor.cc.

◆ moduleIDs_

std::vector<int> ModuleAllocMonitor::moduleIDs_
private

Definition at line 297 of file ModuleAllocMonitor.cc.

◆ moduleNames_

std::vector<std::string> ModuleAllocMonitor::moduleNames_
private

Definition at line 296 of file ModuleAllocMonitor.cc.

◆ nEventsStarted_

std::atomic<unsigned int> ModuleAllocMonitor::nEventsStarted_ {0}
private

Definition at line 299 of file ModuleAllocMonitor.cc.

◆ nEventsToSkip_

unsigned int ModuleAllocMonitor::nEventsToSkip_ = 0
private

Definition at line 298 of file ModuleAllocMonitor.cc.