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)
 
 ~CUDAMonitoringService ()=default
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

int numberOfDevices_ = 0
 

Detailed Description

Definition at line 21 of file CUDAMonitoringService.cc.

Constructor & Destructor Documentation

◆ CUDAMonitoringService()

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

Definition at line 36 of file CUDAMonitoringService.cc.

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

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

◆ ~CUDAMonitoringService()

CUDAMonitoringService::~CUDAMonitoringService ( )
default

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 54 of file CUDAMonitoringService.cc.

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

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), and edm::ConfigurationDescriptions::setComment().

◆ postEvent()

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

Definition at line 101 of file CUDAMonitoringService.cc.

101  {
102  auto log = edm::LogPrint("CUDAMonitoringService");
103  log << "CUDA device memory after event";
104  dumpUsedMemory(log, numberOfDevices_);
105 }

References dqm-mbProfile::log, and numberOfDevices_.

Referenced by CUDAMonitoringService().

◆ postModuleBeginStream()

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

Definition at line 94 of file CUDAMonitoringService.cc.

94  {
95  auto log = edm::LogPrint("CUDAMonitoringService");
96  log << "CUDA device memory after beginStream() of " << mcc.moduleDescription()->moduleLabel() << " ("
97  << mcc.moduleDescription()->moduleName() << ")";
98  dumpUsedMemory(log, numberOfDevices_);
99 }

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 88 of file CUDAMonitoringService.cc.

88  {
89  auto log = edm::LogPrint("CUDAMonitoringService");
90  log << "CUDA device memory after construction of " << desc.moduleLabel() << " (" << desc.moduleName() << ")";
91  dumpUsedMemory(log, numberOfDevices_);
92 }

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

Referenced by CUDAMonitoringService().

Member Data Documentation

◆ numberOfDevices_

int CUDAMonitoringService::numberOfDevices_ = 0
private
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
CUDAService::numberOfDevices
int numberOfDevices() const
Definition: CUDAService.h:24
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:33
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
edm::ConfigurationDescriptions::setComment
void setComment(std::string const &value)
Definition: ConfigurationDescriptions.cc:48
edm::Service
Definition: Service.h:30
edm::LogPrint
Definition: MessageLogger.h:342
CUDAMonitoringService::postEvent
void postEvent(edm::StreamContext const &sc)
Definition: CUDAMonitoringService.cc:101
CUDAMonitoringService::postModuleConstruction
void postModuleConstruction(edm::ModuleDescription const &desc)
Definition: CUDAMonitoringService.cc:88
CUDAService::enabled
bool enabled() const
Definition: CUDAService.h:22
CUDAMonitoringService::postModuleBeginStream
void postModuleBeginStream(edm::StreamContext const &, edm::ModuleCallingContext const &mcc)
Definition: CUDAMonitoringService.cc:94
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17