CMS 3D CMS Logo

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

Public Member Functions

 CUDAMonitoringService (edm::ParameterSet const &iConfig, edm::ActivityRegistry &iRegistry)
 
void postEvent (edm::StreamContext const &sc)
 
void postModuleBeginStream (edm::StreamContext const &, edm::ModuleCallingContext const &mcc)
 
void postModuleConstruction (edm::ModuleDescription const &desc)
 
void postModuleEvent (edm::StreamContext const &sc, edm::ModuleCallingContext const &mcc)
 
 ~CUDAMonitoringService ()=default
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

int numberOfDevices_ = 0
 

Detailed Description

Definition at line 22 of file CUDAMonitoringService.cc.

Constructor & Destructor Documentation

◆ CUDAMonitoringService()

CUDAMonitoringService::CUDAMonitoringService ( edm::ParameterSet const &  iConfig,
edm::ActivityRegistry iRegistry 
)

Definition at line 38 of file CUDAMonitoringService.cc.

References ecalDigis_cff::cuda, numberOfDevices_, or, postEvent(), postModuleBeginStream(), postModuleConstruction(), postModuleEvent(), edm::ActivityRegistry::watchPostEvent(), edm::ActivityRegistry::watchPostModuleBeginStream(), edm::ActivityRegistry::watchPostModuleConstruction(), and edm::ActivityRegistry::watchPostModuleEvent().

38  {
39  // make sure that CUDA is initialised, and that the CUDAService destructor is called after this service's destructor
41  if (not cuda or not cuda->enabled())
42  return;
43 
44  numberOfDevices_ = cuda->numberOfDevices();
45 
46  if (config.getUntrackedParameter<bool>("memoryConstruction")) {
47  registry.watchPostModuleConstruction(this, &CUDAMonitoringService::postModuleConstruction);
48  }
49  if (config.getUntrackedParameter<bool>("memoryBeginStream")) {
50  registry.watchPostModuleBeginStream(this, &CUDAMonitoringService::postModuleBeginStream);
51  }
52  if (config.getUntrackedParameter<bool>("memoryPerModule")) {
53  registry.watchPostModuleEvent(this, &CUDAMonitoringService::postModuleEvent);
54  }
55  if (config.getUntrackedParameter<bool>("memoryPerEvent")) {
56  registry.watchPostEvent(this, &CUDAMonitoringService::postEvent);
57  }
58 }
Definition: config.py:1
void postEvent(edm::StreamContext const &sc)
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
void postModuleConstruction(edm::ModuleDescription const &desc)
void postModuleBeginStream(edm::StreamContext const &, edm::ModuleCallingContext const &mcc)
void postModuleEvent(edm::StreamContext const &sc, edm::ModuleCallingContext const &mcc)

◆ ~CUDAMonitoringService()

CUDAMonitoringService::~CUDAMonitoringService ( )
default

Member Function Documentation

◆ fillDescriptions()

void CUDAMonitoringService::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 60 of file CUDAMonitoringService.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and edm::ConfigurationDescriptions::setComment().

60  {
62 
63  desc.addUntracked<bool>("memoryConstruction", false)
64  ->setComment("Print memory information for each device after the construction of each module");
65  desc.addUntracked<bool>("memoryBeginStream", true)
66  ->setComment("Print memory information for each device after the beginStream() of each module");
67  desc.addUntracked<bool>("memoryPerModule", true)
68  ->setComment("Print memory information for each device after the event of each module");
69  desc.addUntracked<bool>("memoryPerEvent", true)
70  ->setComment("Print memory information for each device after each event");
71 
72  descriptions.add("CUDAMonitoringService", desc);
73  descriptions.setComment(
74  "The memory information is the global state of the device. This gets confusing if there are multiple processes "
75  "running on the same device. Probably the information retrieval should be re-thought?");
76 }
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ postEvent()

void CUDAMonitoringService::postEvent ( edm::StreamContext const &  sc)

Definition at line 124 of file CUDAMonitoringService.cc.

References dqm-mbProfile::log, and numberOfDevices_.

Referenced by CUDAMonitoringService().

124  {
125  auto log = edm::LogPrint("CUDAMonitoringService");
126  log << "CUDA device memory after event";
127  dumpUsedMemory(log, numberOfDevices_);
128 }
Log< level::Warning, true > LogPrint

◆ postModuleBeginStream()

void CUDAMonitoringService::postModuleBeginStream ( edm::StreamContext const &  ,
edm::ModuleCallingContext const &  mcc 
)

Definition at line 110 of file CUDAMonitoringService.cc.

References dqm-mbProfile::log, edm::ModuleCallingContext::moduleDescription(), edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::moduleName(), and numberOfDevices_.

Referenced by CUDAMonitoringService().

110  {
111  auto log = edm::LogPrint("CUDAMonitoringService");
112  log << "CUDA device memory after beginStream() of " << mcc.moduleDescription()->moduleLabel() << " ("
113  << mcc.moduleDescription()->moduleName() << ")";
114  dumpUsedMemory(log, numberOfDevices_);
115 }
Log< level::Warning, true > LogPrint

◆ postModuleConstruction()

void CUDAMonitoringService::postModuleConstruction ( edm::ModuleDescription const &  desc)

Definition at line 104 of file CUDAMonitoringService.cc.

References submitPVResolutionJobs::desc, dqm-mbProfile::log, and numberOfDevices_.

Referenced by CUDAMonitoringService().

104  {
105  auto log = edm::LogPrint("CUDAMonitoringService");
106  log << "CUDA device memory after construction of " << desc.moduleLabel() << " (" << desc.moduleName() << ")";
107  dumpUsedMemory(log, numberOfDevices_);
108 }
Log< level::Warning, true > LogPrint

◆ postModuleEvent()

void CUDAMonitoringService::postModuleEvent ( edm::StreamContext const &  sc,
edm::ModuleCallingContext const &  mcc 
)

Definition at line 117 of file CUDAMonitoringService.cc.

References dqm-mbProfile::log, edm::ModuleCallingContext::moduleDescription(), edm::ModuleDescription::moduleLabel(), edm::ModuleDescription::moduleName(), and numberOfDevices_.

Referenced by CUDAMonitoringService().

117  {
118  auto log = edm::LogPrint("CUDAMonitoringService");
119  log << "CUDA device memory after processing an event by " << mcc.moduleDescription()->moduleLabel() << " ("
120  << mcc.moduleDescription()->moduleName() << ")";
121  dumpUsedMemory(log, numberOfDevices_);
122 }
Log< level::Warning, true > LogPrint

Member Data Documentation

◆ numberOfDevices_

int CUDAMonitoringService::numberOfDevices_ = 0
private