MADNESS 0.10.1
madness::MemoryMeasurer Class Reference

measure the memory usage of all FunctionImpl objects of all worlds More...

#include <memory_measurement.h>

Classes

struct  MemInfo
struct  MemKey

Public Types

typedef std::map< MemKey, MemInfo > MemInfoMapT

Public Member Functions

void clear_map ()
 reset the memory map
std::vector< std::pair< std::string, double > > memory_per_host_all_ranks (const std::vector< std::pair< std::pair< std::string, long >, double > > &mem_per_host_and_rank) const
 accumulate the memory usage of all objects of all worlds over all ranks per host
std::vector< std::pair< std::pair< std::string, long >, double > > memory_per_host_and_rank (World &world) const
 accumulate the memory usage of all objects of all worlds for this rank per host
void print_memory_map (World &world, std::string msg="")
void reduce_map (World &universe)
 gather all information of the map on rank 0 of the universe
void search_all_worlds ()
void search_world (World &world)

Static Public Member Functions

static std::map< std::string, std::pair< int, double > > host_to_nrank_and_rss_map (World &universe)
 given the hostname, return number of ranks and total rss on that node
static double max_memory (const MemInfoMapT &memmap)
 return the maximum memory usage over all hosts
static std::map< MemKey, MemInfo > measure_and_print (World &world)
 measure the memory usage of all objects of all worlds
static double min_memory (const MemInfoMapT &memmap)
 return the minimum memory usage over all hosts
static void release_free_memory ()
static double total_memory (const MemInfoMapT &memmap)
 return the total memory usage over all hosts

Private Member Functions

template<typename T, std::size_t NDIM>
void add_memory_to_map (const FunctionImpl< T, NDIM > &f)
template<typename T, std::size_t NDIM>
const FunctionImpl< T, NDIM > * cast_to_funcimpl_ptr (const uniqueidT obj_id)

Static Private Member Functions

static std::string get_hostname ()
 get the hostname of this machine, rank-local

Private Attributes

bool debug =false
MemInfoMapT world_memory_map
 keeps track of the memory usage of all objects of one or many worlds on this rank

Friends

bool operator< (const MemKey &lhs, const MemKey &other)

Detailed Description

measure the memory usage of all FunctionImpl objects of all worlds

Assuming FunctionImpl are the largest objects in a calculation data is kept as key-value pairs in a map: key=world_id,rank,hostname,NDIM, value=#functions,memory_GB

Member Typedef Documentation

◆ MemInfoMapT

Member Function Documentation

◆ add_memory_to_map()

template<typename T, std::size_t NDIM>
void madness::MemoryMeasurer::add_memory_to_map ( const FunctionImpl< T, NDIM > & f)
inlineprivate

◆ cast_to_funcimpl_ptr()

template<typename T, std::size_t NDIM>
const FunctionImpl< T, NDIM > * madness::MemoryMeasurer::cast_to_funcimpl_ptr ( const uniqueidT obj_id)
inlineprivate

◆ clear_map()

void madness::MemoryMeasurer::clear_map ( )
inline

reset the memory map

References world_memory_map.

Referenced by reduce_map().

◆ get_hostname()

std::string madness::MemoryMeasurer::get_hostname ( )
inlinestaticprivate

get the hostname of this machine, rank-local

Referenced by madness::MemoryMeasurer::MemKey::MemKey().

◆ host_to_nrank_and_rss_map()

std::map< std::string, std::pair< int, double > > madness::MemoryMeasurer::host_to_nrank_and_rss_map ( World & universe)
inlinestatic

given the hostname, return number of ranks and total rss on that node

References a, b, and madness::rank_to_host_and_rss_map().

Referenced by print_memory_map().

◆ max_memory()

double madness::MemoryMeasurer::max_memory ( const MemInfoMapT & memmap)
inlinestatic

return the maximum memory usage over all hosts

References max_memory().

Referenced by max_memory().

◆ measure_and_print()

std::map< MemKey, MemInfo > madness::MemoryMeasurer::measure_and_print ( World & world)
inlinestatic

◆ memory_per_host_all_ranks()

std::vector< std::pair< std::string, double > > madness::MemoryMeasurer::memory_per_host_all_ranks ( const std::vector< std::pair< std::pair< std::string, long >, double > > & mem_per_host_and_rank) const
inline

accumulate the memory usage of all objects of all worlds over all ranks per host

integrate out world, dim and rank, only hostname is left

Referenced by print_memory_map().

◆ memory_per_host_and_rank()

std::vector< std::pair< std::pair< std::string, long >, double > > madness::MemoryMeasurer::memory_per_host_and_rank ( World & world) const
inline

accumulate the memory usage of all objects of all worlds for this rank per host

integrate out world and dim from MemKey, result lives on rank 0 only

References a, b, and world_memory_map.

Referenced by print_memory_map().

◆ min_memory()

double madness::MemoryMeasurer::min_memory ( const MemInfoMapT & memmap)
inlinestatic

return the minimum memory usage over all hosts

References min_memory().

Referenced by min_memory().

◆ print_memory_map()

void madness::MemoryMeasurer::print_memory_map ( World & world,
std::string msg = "" )
inline

◆ reduce_map()

void madness::MemoryMeasurer::reduce_map ( World & universe)
inline

gather all information of the map on rank 0 of the universe

References clear_map(), madness::WorldGopInterface::concat0(), madness::World::gop, and world_memory_map.

Referenced by print_memory_map().

◆ release_free_memory()

void madness::MemoryMeasurer::release_free_memory ( )
inlinestatic

◆ search_all_worlds()

void madness::MemoryMeasurer::search_all_worlds ( )
inline

add all FunctionImpl<T,NDIM> objects of all worlds to the memory map the memory map is a rank-local object

References debug, madness::World::exists(), madness::World::get_default(), madness::World::get_world_ids(), madness::print(), search_world(), and madness::World::world_from_id().

Referenced by measure_and_print().

◆ search_world()

void madness::MemoryMeasurer::search_world ( World & world)
inline

add all FunctionImpl<T,NDIM> objects of the given world to the memory map the memory map is a rank-local object

References add_memory_to_map(), cast_to_funcimpl_ptr(), debug, madness::World::get_object_ids(), madness::print(), and madness::World::rank().

Referenced by search_all_worlds().

◆ total_memory()

double madness::MemoryMeasurer::total_memory ( const MemInfoMapT & memmap)
inlinestatic

return the total memory usage over all hosts

References total_memory().

Referenced by print_memory_map(), test_size(), and total_memory().

◆ operator<

Member Data Documentation

◆ debug

bool madness::MemoryMeasurer::debug =false
private

◆ world_memory_map

MemInfoMapT madness::MemoryMeasurer::world_memory_map
private

keeps track of the memory usage of all objects of one or many worlds on this rank

Referenced by add_memory_to_map(), clear_map(), measure_and_print(), memory_per_host_and_rank(), print_memory_map(), and reduce_map().


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