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.

38  {
39  // make sure that CUDA is initialised, and that the CUDAService destructor is called after this service's destructor
40  edm::Service<CUDAService> cudaService;
41  if (!cudaService->enabled())
42  return;
43  numberOfDevices_ = cudaService->numberOfDevices();
44 
45  if (config.getUntrackedParameter<bool>("memoryConstruction")) {
46  registry.watchPostModuleConstruction(this, &CUDAMonitoringService::postModuleConstruction);
47  }
48  if (config.getUntrackedParameter<bool>("memoryBeginStream")) {
49  registry.watchPostModuleBeginStream(this, &CUDAMonitoringService::postModuleBeginStream);
50  }
51  if (config.getUntrackedParameter<bool>("memoryPerModule")) {
52  registry.watchPostModuleEvent(this, &CUDAMonitoringService::postModuleEvent);
53  }
54  if (config.getUntrackedParameter<bool>("memoryPerEvent")) {
55  registry.watchPostEvent(this, &CUDAMonitoringService::postEvent);
56  }
57 }

References CUDAService::enabled(), CUDAService::numberOfDevices(), numberOfDevices_, postEvent(), postModuleBeginStream(), postModuleConstruction(), postModuleEvent(), edm::ActivityRegistry::watchPostEvent(), edm::ActivityRegistry::watchPostModuleBeginStream(), edm::ActivityRegistry::watchPostModuleConstruction(), and edm::ActivityRegistry::watchPostModuleEvent().

◆ ~CUDAMonitoringService()

CUDAMonitoringService::~CUDAMonitoringService ( )
default

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 59 of file CUDAMonitoringService.cc.

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

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

◆ postEvent()

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

Definition at line 123 of file CUDAMonitoringService.cc.

123  {
124  auto log = edm::LogPrint("CUDAMonitoringService");
125  log << "CUDA device memory after event";
126  dumpUsedMemory(log, numberOfDevices_);
127 }

References dqm-mbProfile::log, and numberOfDevices_.

Referenced by CUDAMonitoringService().

◆ postModuleBeginStream()

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

Definition at line 109 of file CUDAMonitoringService.cc.

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

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

Referenced by CUDAMonitoringService().

◆ postModuleConstruction()

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

Definition at line 103 of file CUDAMonitoringService.cc.

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

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

Referenced by CUDAMonitoringService().

◆ postModuleEvent()

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

Definition at line 116 of file CUDAMonitoringService.cc.

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

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

Referenced by CUDAMonitoringService().

Member Data Documentation

◆ numberOfDevices_

int CUDAMonitoringService::numberOfDevices_ = 0
private
edm::LogPrint
Log< level::Warning, true > LogPrint
Definition: MessageLogger.h:130
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
CUDAService::numberOfDevices
int numberOfDevices() const
Definition: CUDAService.h:24
CUDAMonitoringService::postModuleEvent
void postModuleEvent(edm::StreamContext const &sc, edm::ModuleCallingContext const &mcc)
Definition: CUDAMonitoringService.cc:116
config
Definition: config.py:1
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
CUDAMonitoringService::numberOfDevices_
int numberOfDevices_
Definition: CUDAMonitoringService.cc:35
edm::ConfigurationDescriptions::setComment
void setComment(std::string const &value)
Definition: ConfigurationDescriptions.cc:48
edm::Service
Definition: Service.h:30
CUDAMonitoringService::postEvent
void postEvent(edm::StreamContext const &sc)
Definition: CUDAMonitoringService.cc:123
CUDAMonitoringService::postModuleConstruction
void postModuleConstruction(edm::ModuleDescription const &desc)
Definition: CUDAMonitoringService.cc:103
CUDAService::enabled
bool enabled() const
Definition: CUDAService.h:22
CUDAMonitoringService::postModuleBeginStream
void postModuleBeginStream(edm::StreamContext const &, edm::ModuleCallingContext const &mcc)
Definition: CUDAMonitoringService.cc:109
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17