www.mooseframework.org
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
MemoryUsageReporter Class Reference

Mix-in class for querying memory metrics used by MemoryUsage and VectorMemoryUsage. More...

#include <MemoryUsageReporter.h>

Inheritance diagram for MemoryUsageReporter:
[legend]

Public Member Functions

 MemoryUsageReporter (const MooseObject *moose_object)
 

Protected Attributes

const Parallel::Communicator & _mur_communicator
 communicator for this object More...
 
processor_id_type _my_rank
 this objects rank More...
 
processor_id_type _nrank
 number of ranks in the object's communicator More...
 
const std::vector< unsigned int > & _hardware_id
 hardware IDs for each MPI rank (valid on rank zero only) More...
 
unsigned long long _memory_total
 total RAM installed in the local node More...
 
std::vector< unsigned long long > _hardware_memory_total
 total RAM for each hardware ID (node) (valid on rank zero only) More...
 

Private Member Functions

void sharedMemoryRanksBySplitCommunicator ()
 Use a share memory type communicator split (MPI3) More...
 
void sharedMemoryRanksByProcessorname ()
 Identify hardware by MPI processor name. More...
 

Detailed Description

Mix-in class for querying memory metrics used by MemoryUsage and VectorMemoryUsage.

Definition at line 19 of file MemoryUsageReporter.h.

Constructor & Destructor Documentation

◆ MemoryUsageReporter()

MemoryUsageReporter::MemoryUsageReporter ( const MooseObject moose_object)

Definition at line 14 of file MemoryUsageReporter.C.

15  : _mur_communicator(moose_object->comm()),
17  _nrank(_mur_communicator.size()),
18  _hardware_id(moose_object->getMooseApp().rankMap().rankHardwareIds())
19 {
20  // get total available ram
22  if (!_memory_total)
23  mooseWarning("Unable to query hardware memory size in ", moose_object->name());
24 
25  // gather all per node memory to processor zero
26  std::vector<unsigned long long> memory_totals(_nrank);
27  _mur_communicator.gather(0, _memory_total, memory_totals);
28 
29  // validate and store per node memory
30  if (_my_rank == 0)
31  {
32  for (std::size_t i = 0; i < _nrank; ++i)
33  {
34  auto id = _hardware_id[i];
35  if (id == _hardware_memory_total.size())
36  {
37  _hardware_memory_total.resize(id + 1);
38  _hardware_memory_total[id] = memory_totals[i];
39  }
40  else if (_hardware_memory_total[id] != memory_totals[i])
41  mooseWarning("Inconsistent total memory reported by ranks on the same hardware node in ",
42  moose_object->name());
43  }
44  }
45 }
const Parallel::Communicator & _mur_communicator
communicator for this object
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:333
const Parallel::Communicator & comm() const
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
std::vector< unsigned long long > _hardware_memory_total
total RAM for each hardware ID (node) (valid on rank zero only)
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition: MooseBase.h:45
const RankMap & rankMap()
The RankMap is a useful object for determining how the processes are laid out on the physical nodes o...
Definition: MooseApp.h:128
unsigned long long _memory_total
total RAM installed in the local node
std::size_t getTotalRAM()
get the total amount of physical RAM available
Definition: MemoryUtils.C:59
const std::vector< unsigned int > & rankHardwareIds() const
Vector containing the hardware ID for each PID.
Definition: RankMap.h:56
processor_id_type _nrank
number of ranks in the object&#39;s communicator
processor_id_type _my_rank
this objects rank
const std::vector< unsigned int > & _hardware_id
hardware IDs for each MPI rank (valid on rank zero only)

Member Function Documentation

◆ sharedMemoryRanksByProcessorname()

void MemoryUsageReporter::sharedMemoryRanksByProcessorname ( )
private

Identify hardware by MPI processor name.

◆ sharedMemoryRanksBySplitCommunicator()

void MemoryUsageReporter::sharedMemoryRanksBySplitCommunicator ( )
private

Use a share memory type communicator split (MPI3)

Member Data Documentation

◆ _hardware_id

const std::vector<unsigned int>& MemoryUsageReporter::_hardware_id
protected

hardware IDs for each MPI rank (valid on rank zero only)

Definition at line 35 of file MemoryUsageReporter.h.

Referenced by VectorMemoryUsage::finalize(), MemoryUsageReporter(), and VectorMemoryUsage::VectorMemoryUsage().

◆ _hardware_memory_total

std::vector<unsigned long long> MemoryUsageReporter::_hardware_memory_total
protected

total RAM for each hardware ID (node) (valid on rank zero only)

Definition at line 41 of file MemoryUsageReporter.h.

Referenced by VectorMemoryUsage::finalize(), MemoryUsageReporter(), and VectorMemoryUsage::VectorMemoryUsage().

◆ _memory_total

unsigned long long MemoryUsageReporter::_memory_total
protected

total RAM installed in the local node

Definition at line 38 of file MemoryUsageReporter.h.

Referenced by MemoryUsageReporter().

◆ _mur_communicator

const Parallel::Communicator& MemoryUsageReporter::_mur_communicator
protected

communicator for this object

Definition at line 26 of file MemoryUsageReporter.h.

Referenced by MemoryUsageReporter().

◆ _my_rank

processor_id_type MemoryUsageReporter::_my_rank
protected

◆ _nrank

processor_id_type MemoryUsageReporter::_nrank
protected

number of ranks in the object's communicator

Definition at line 32 of file MemoryUsageReporter.h.

Referenced by VectorMemoryUsage::finalize(), MemoryUsageReporter(), and VectorMemoryUsage::VectorMemoryUsage().


The documentation for this class was generated from the following files: