|
|
Go to the documentation of this file.
45 if (
config.getUntrackedParameter<
bool>(
"memoryConstruction")) {
48 if (
config.getUntrackedParameter<
bool>(
"memoryBeginStream")) {
51 if (
config.getUntrackedParameter<
bool>(
"memoryPerModule")) {
54 if (
config.getUntrackedParameter<
bool>(
"memoryPerEvent")) {
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");
71 descriptions.
add(
"CUDAMonitoringService",
desc);
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?");
80 void dumpUsedMemory(
T&
log,
int num) {
84 constexpr
auto mbytes = 1 << 20;
85 for (
int i = 0;
i <
num; ++
i) {
86 size_t freeMemory, totalMemory;
88 cudaCheck(cudaMemGetInfo(&freeMemory, &totalMemory));
90 <<
i <<
": " << (totalMemory - freeMemory) / mbytes <<
" MB used / " << totalMemory / mbytes <<
" MB total";
91 auto found = cachingDeviceAllocatorStatus.find(
i);
92 if (
found != cachingDeviceAllocatorStatus.end()) {
93 auto const& cached =
found->second;
94 log <<
"; CachingDeviceAllocator " << cached.live / mbytes <<
" MB live "
95 <<
"(" << cached.liveRequested / mbytes <<
" MB requested) " << cached.free / mbytes <<
" MB free "
96 << (cached.live + cached.free) / mbytes <<
" MB total cached";
105 log <<
"CUDA device memory after construction of " <<
desc.moduleLabel() <<
" (" <<
desc.moduleName() <<
")";
125 log <<
"CUDA device memory after event";
~CUDAMonitoringService()=default
std::string const & moduleLabel() const
Log< level::Warning, true > LogPrint
std::string const & moduleName() const
#define DEFINE_FWK_SERVICE(type)
ModuleDescription const * moduleDescription() const
int numberOfDevices() const
void postModuleEvent(edm::StreamContext const &sc, edm::ModuleCallingContext const &mcc)
void watchPostModuleBeginStream(PostModuleBeginStream::slot_type const &iSlot)
CUDAMonitoringService(edm::ParameterSet const &iConfig, edm::ActivityRegistry &iRegistry)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
allocator::GpuCachedBytes deviceAllocatorStatus()
void watchPostModuleConstruction(PostModuleConstruction::slot_type const &iSlot)
void watchPostEvent(PostEvent::slot_type const &iSlot)
void setComment(std::string const &value)
void postEvent(edm::StreamContext const &sc)
void postModuleConstruction(edm::ModuleDescription const &desc)
void postModuleBeginStream(edm::StreamContext const &, edm::ModuleCallingContext const &mcc)
#define cudaCheck(ARG,...)
void watchPostModuleEvent(PostModuleEvent::slot_type const &iSlot)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)