GADGET-4
memory Class Reference

#include <mymalloc.h>

Inherits setcomm.

Public Member Functions

 memory ()
 
void mymalloc_init (int maxmemsize, enum restart_options restartflag)
 Initialize memory manager. More...
 
void * mymalloc_movable_fullinfo (void *ptr, const char *varname, size_t n, const char *func, const char *file, int line, int movable_flag, int clear_flag, char *originflag)
 Allocate a movable memory block and store the relative information. More...
 
void * myrealloc_movable_fullinfo (void *p, size_t n, const char *func, const char *file, int line, int movable_flag)
 Reallocate an existing movable memory block. More...
 
void myfree_movable_fullinfo (void *p, const char *func, const char *file, int line, int movable_flag)
 Deallocate a movable memory block. More...
 
void * myfree_query_last_block (void)
 
size_t roundup_to_multiple_of_cacheline_size (size_t n)
 
void report_detailed_memory_usage_of_largest_task (void)
 Output memory usage for the task with the greatest amount of memory allocated. More...
 
void check_maxmemsize_setting (int maxmemsize)
 
int myMPI_Win_allocate_shared (MPI_Aint size, int disp_unit, MPI_Info info, MPI_Comm comm, void *baseptr, MPI_Win *win)
 
int myMPI_Win_shared_query (MPI_Win win, int rank, MPI_Aint *size, int *disp_unit, void *baseptr)
 
double getAllocatedBytesInMB (void)
 
template<typename T >
T * alloc (T *&ptr, const char *varname, size_t n, const char *func, const char *file, int linenr)
 
template<typename T >
T * alloc_movable (T *&ptr, const char *varname, size_t n, const char *func, const char *file, int linenr)
 
template<typename T >
T * realloc (T *&ptr, const char *varname, size_t n, const char *func, const char *file, int linenr)
 
template<typename T >
T * realloc_movable (T *&ptr, const char *varname, size_t n, const char *func, const char *file, int linenr)
 
void dealloc (void *ptr, const char *func, const char *file, int linenr)
 
void dealloc_movable (void *ptr, const char *func, const char *file, int linenr)
 
void dump_memory_table (void)
 Dump the buffer where the memory information is stored to the standard output. More...
 
- Public Member Functions inherited from setcomm
 setcomm (MPI_Comm Comm)
 
 setcomm (const char *str)
 
void initcomm (MPI_Comm Comm)
 
void mpi_printf (const char *fmt,...)
 
void determine_compute_nodes (void)
 

Public Attributes

size_t AllocatedBytes
 
size_t FreeBytes
 
char * Base
 
- Public Attributes inherited from setcomm
MPI_Comm Communicator
 
int NTask
 
int ThisTask
 
int PTask
 
int ThisNode
 
int NumNodes = 0
 
int TasksInThisNode
 
int RankInThisNode
 
int MinTasksPerNode
 
int MaxTasksPerNode
 
long long MemoryOnNode
 
long long SharedMemoryOnNode
 

Detailed Description

Definition at line 42 of file mymalloc.h.

Constructor & Destructor Documentation

◆ memory()

memory ( )
inline

Definition at line 45 of file mymalloc.h.

Member Function Documentation

◆ alloc()

T * alloc ( T *&  ptr,
const char *  varname,
size_t  n,
const char *  func,
const char *  file,
int  linenr 
)
inline

Definition at line 74 of file mymalloc.h.

◆ alloc_movable()

T * alloc_movable ( T *&  ptr,
const char *  varname,
size_t  n,
const char *  func,
const char *  file,
int  linenr 
)
inline

Definition at line 80 of file mymalloc.h.

◆ check_maxmemsize_setting()

void check_maxmemsize_setting ( int  maxmemsize)

Definition at line 684 of file mymalloc.cc.

◆ dealloc()

void dealloc ( void *  ptr,
const char *  func,
const char *  file,
int  linenr 
)
inline

Definition at line 97 of file mymalloc.h.

◆ dealloc_movable()

void dealloc_movable ( void *  ptr,
const char *  func,
const char *  file,
int  linenr 
)
inline

Definition at line 99 of file mymalloc.h.

◆ dump_memory_table()

void dump_memory_table ( void  )

Dump the buffer where the memory information is stored to the standard output.

Definition at line 355 of file mymalloc.cc.

◆ getAllocatedBytesInMB()

double getAllocatedBytesInMB ( void  )
inline

Definition at line 71 of file mymalloc.h.

◆ myfree_movable_fullinfo()

void myfree_movable_fullinfo ( void *  p,
const char *  func,
const char *  file,
int  line,
int  movable_flag 
)

Deallocate a movable memory block.

For this operation to be successful all the blocks allocated after the block that has to be freed must be of movable type.

Parameters
ppointer to the memory block to be deallocated
funcname of function that has called the deallocation routine (usually given by the FUNCTION macro)
filefile where the function that has called the deallocation routine resides (usually given by the FILE macro)
lineline number of file where the deallocation routine was called (usually given by the LINE macro)

Definition at line 490 of file mymalloc.cc.

◆ myfree_query_last_block()

void * myfree_query_last_block ( void  )

Definition at line 473 of file mymalloc.cc.

◆ mymalloc_init()

void mymalloc_init ( int  maxmemsize,
enum restart_options  restartflag 
)

Initialize memory manager.

This function initializes the memory manager. In particular, it sets the global variables of the module to their initial value and allocates the memory for the stack.

Definition at line 58 of file mymalloc.cc.

◆ mymalloc_movable_fullinfo()

void * mymalloc_movable_fullinfo ( void *  ptr,
const char *  varname,
size_t  n,
const char *  func,
const char *  file,
int  line,
int  movable_flag,
int  clear_flag,
char *  callorigin 
)

Allocate a movable memory block and store the relative information.

Parameters
ptrpointer to the initial memory address of the block
varnamename of the variable to be stored in the allocated block
nsize of the memory block in bytes
funcname of function that has called the allocation routine (usually given by the FUNCTION macro)
filefile where the function that has called the allocation routine resides (usually given by the FILE macro)
lineline number of file where the allocation routine was called (usually given by the LINE macro)
Returns
a pointer to the beginning of the allocated memory block

Definition at line 402 of file mymalloc.cc.

◆ myMPI_Win_allocate_shared()

int myMPI_Win_allocate_shared ( MPI_Aint  size,
int  disp_unit,
MPI_Info  info,
MPI_Comm  comm,
void *  baseptr,
MPI_Win *  win 
)

Definition at line 177 of file mymalloc.cc.

◆ myMPI_Win_shared_query()

int myMPI_Win_shared_query ( MPI_Win  win,
int  rank,
MPI_Aint *  size,
int *  disp_unit,
void *  baseptr 
)

Definition at line 250 of file mymalloc.cc.

◆ myrealloc_movable_fullinfo()

void * myrealloc_movable_fullinfo ( void *  p,
size_t  n,
const char *  func,
const char *  file,
int  line,
int  movable_flag 
)

Reallocate an existing movable memory block.

For this operation to be successful all the blocks allocated after the block that has to be reallocated must be of movable type.

Parameters
ppointer to the existing memory block to be reallocated
nthe new size of the memory block in bytes
funcname of function that has called the reallocation routine (usually given by the FUNCTION macro)
filefile where the function that has called the reallocation routine resides (usually given by the FILE macro)
lineline number of file where the reallocation routine was called (usually given by the LINE macro)
Returns
a pointer to the beginning of the newly allocated memory block

Definition at line 591 of file mymalloc.cc.

◆ realloc()

T * realloc ( T *&  ptr,
const char *  varname,
size_t  n,
const char *  func,
const char *  file,
int  linenr 
)
inline

Definition at line 86 of file mymalloc.h.

◆ realloc_movable()

T * realloc_movable ( T *&  ptr,
const char *  varname,
size_t  n,
const char *  func,
const char *  file,
int  linenr 
)
inline

Definition at line 92 of file mymalloc.h.

◆ report_detailed_memory_usage_of_largest_task()

void report_detailed_memory_usage_of_largest_task ( void  )

Output memory usage for the task with the greatest amount of memory allocated.

Definition at line 311 of file mymalloc.cc.

◆ roundup_to_multiple_of_cacheline_size()

size_t roundup_to_multiple_of_cacheline_size ( size_t  n)

Definition at line 465 of file mymalloc.cc.

Member Data Documentation

◆ AllocatedBytes

size_t AllocatedBytes

Definition at line 47 of file mymalloc.h.

◆ Base

char* Base

Base pointer (initial memory address) of the stack.

Definition at line 49 of file mymalloc.h.

◆ FreeBytes

size_t FreeBytes

Definition at line 48 of file mymalloc.h.


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