IgANet
IGAnets - Isogeometric Analysis Networks
Loading...
Searching...
No Matches
iganet::MemoryDebugger< id > Class Template Reference

Memory debugger. More...

#include </home/runner/work/iganet/iganet/include/iganet/core/memory.hpp>

Classes

struct  MemoryObject
 Memory object. More...
 

Public Member Functions

 MemoryDebugger ()
 Default constructor.
 
template<typename T , std::size_t N>
void add (const std::string &name, const std::array< T, N > &array)
 Registers a std::array with the memory debugger.
 
template<typename T >
void add (const std::string &name, const T &obj)
 Registers a generic type with the memory debugger.
 
void add (const std::string &name, const torch::Tensor &tensor)
 Registers a torch::Tensor with the memory debugger.
 
void clear ()
 Clears the memory debugger.
 
void pretty_print (std::ostream &os=Log(log::info)) const
 Returns a string representation of the memory debugger.
 

Private Member Functions

std::string convert_bytes (int64_t bytes) const
 Converts bytes into the best human-readable unit.
 

Private Attributes

int64_t bytes_
 Counter holding the memory of registered objects in bytes.
 
int64_t counter_
 Counter holding the number of registered objects.
 
std::chrono::high_resolution_clock::time_point init_
 Reference time point.
 
std::map< std::chrono::high_resolution_clock::time_point, MemoryObjectobjects_
 Map holding the list of registered objects.
 

Detailed Description

template<std::size_t id = 0>
class iganet::MemoryDebugger< id >

Memory debugger.

Template Parameters
idCompile-time identifier used to distinguish debugger instances.

Constructor & Destructor Documentation

◆ MemoryDebugger()

template<std::size_t id = 0>
iganet::MemoryDebugger< id >::MemoryDebugger ( )
inline

Default constructor.

Member Function Documentation

◆ add() [1/3]

template<std::size_t id = 0>
template<typename T , std::size_t N>
void iganet::MemoryDebugger< id >::add ( const std::string &  name,
const std::array< T, N > &  array 
)
inline

Registers a std::array with the memory debugger.

Template Parameters
TElement type of the array.
NNumber of array elements.
Parameters
nameBase name used for the element registrations.
arrayArray whose elements are registered individually.

◆ add() [2/3]

template<std::size_t id = 0>
template<typename T >
void iganet::MemoryDebugger< id >::add ( const std::string &  name,
const T &  obj 
)
inline

Registers a generic type with the memory debugger.

Template Parameters
TType of the registered object.
Parameters
nameDescriptive name under which to register the object.
objObject whose shallow sizeof value is recorded.

◆ add() [3/3]

template<std::size_t id = 0>
void iganet::MemoryDebugger< id >::add ( const std::string &  name,
const torch::Tensor &  tensor 
)
inline

Registers a torch::Tensor with the memory debugger.

Parameters
nameDescriptive name under which to register the tensor.
tensorTensor whose element storage size is recorded.

◆ clear()

template<std::size_t id = 0>
void iganet::MemoryDebugger< id >::clear ( )
inline

Clears the memory debugger.

◆ convert_bytes()

template<std::size_t id = 0>
std::string iganet::MemoryDebugger< id >::convert_bytes ( int64_t  bytes) const
inlineprivate

Converts bytes into the best human-readable unit.

Parameters
bytesNumber of bytes to format.
Returns
A value with the most appropriate binary unit suffix.

◆ pretty_print()

template<std::size_t id = 0>
void iganet::MemoryDebugger< id >::pretty_print ( std::ostream &  os = Log(log::info)) const
inline

Returns a string representation of the memory debugger.

Parameters
osStream that receives the registered objects and total usage.

Member Data Documentation

◆ bytes_

template<std::size_t id = 0>
int64_t iganet::MemoryDebugger< id >::bytes_
private

Counter holding the memory of registered objects in bytes.

◆ counter_

template<std::size_t id = 0>
int64_t iganet::MemoryDebugger< id >::counter_
private

Counter holding the number of registered objects.

◆ init_

template<std::size_t id = 0>
std::chrono::high_resolution_clock::time_point iganet::MemoryDebugger< id >::init_
private

Reference time point.

◆ objects_

template<std::size_t id = 0>
std::map<std::chrono::high_resolution_clock::time_point, MemoryObject> iganet::MemoryDebugger< id >::objects_
private

Map holding the list of registered objects.


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