https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
 
processor_id_type _my_rank
 this objects rank
 
processor_id_type _nrank
 number of ranks in the object's communicator
 
const std::vector< unsigned int > & _hardware_id
 hardware IDs for each MPI rank (valid on rank zero only)
 
unsigned long long _memory_total
 total RAM installed in the local node
 
std::vector< unsigned long long > _hardware_memory_total
 total RAM for each hardware ID (node) (valid on rank zero only)
 

Private Member Functions

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

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()),
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}
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition MooseError.h:345
unsigned long long _memory_total
total RAM installed in the local node
const std::vector< unsigned int > & _hardware_id
hardware IDs for each MPI rank (valid on rank zero only)
std::vector< unsigned long long > _hardware_memory_total
total RAM for each hardware ID (node) (valid on rank zero only)
processor_id_type _nrank
number of ranks in the object's communicator
const Parallel::Communicator & _mur_communicator
communicator for this object
processor_id_type _my_rank
this objects rank
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:174
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition MooseBase.h:87
const std::vector< unsigned int > & rankHardwareIds() const
Vector containing the hardware ID for each PID.
Definition RankMap.h:56
processor_id_type size() const
processor_id_type rank() const
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
const Parallel::Communicator & comm() const
std::size_t getTotalRAM()
get the total amount of physical RAM available
Definition MemoryUtils.C:59

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: