MPI-SCATCI  2.0
An MPI version of SCATCI
memorymanager_module Module Reference

Memory manager module. More...

Data Types

type  memorymanager
 This is a simple class to handle memory management tracking. More...
 

Functions/Subroutines

subroutine memorymanager_ctor (this, total_memory)
 Constructor, used to initialize total available memory. More...
 
subroutine init_memory (this, total_memory)
 Same as constructor, used to reinitialize te memory again (not really used) More...
 
subroutine track_memory (this, elem_size, nelem, stat, array_name)
 Tracks memory allocation, usually called after an allocation. More...
 
subroutine free_memory (this, elem_size, nelem)
 Tracks memory deallocation, usually called before a deallocation. More...
 
integer(longint) function get_available_memory (this)
 Get currently available memory. More...
 
integer(longint) function get_scaled_available_memory (this, scale_)
 Get currently available memory scaled. More...
 
subroutine print_memory_report (this)
 Prints a very simple memory report. More...
 

Variables

type(memorymanager), public master_memory
 This is the global memory manager. More...
 

Detailed Description

Memory manager module.

Authors
A Al-Refaie
Date
2017

This module has an extremely basic memory management system in place, this will hopefully be upgraded in due time

Note
30/01/2017 - Ahmed Al-Refaie: Initial revision.
16/01/2019 - Jakub Benda: Unifom coding style and expanded documentation.

Function/Subroutine Documentation

◆ free_memory()

subroutine memorymanager_module::free_memory ( class(memorymanager this,
integer, intent(in)  elem_size,
integer, intent(in)  nelem 
)
private

Tracks memory deallocation, usually called before a deallocation.

Authors
A Al-Refaie
Date
2017
Parameters
[in,out]thisManager object to update.
[in]elem_sizeSize in byte of each element
[in]nelemNumber of elements of size elem_size

Definition at line 166 of file MemoryManager_module.f90.

◆ get_available_memory()

integer(longint) function memorymanager_module::get_available_memory ( class(memorymanager this)
private

Get currently available memory.

Authors
A Al-Refaie
Date
2017
Returns
Total memory in bytes

Definition at line 194 of file MemoryManager_module.f90.

◆ get_scaled_available_memory()

integer(longint) function memorymanager_module::get_scaled_available_memory ( class(memorymanager this,
real(wp), intent(in)  scale_ 
)
private

Get currently available memory scaled.

Authors
A Al-Refaie
Date
2017

This is particularly useful when trying to determine how many elements we can fit into memory by giving a margin of safety

Parameters
[in,out]thisManager object to update.
[in]scale_Scale valued of available memory (0.0 - 1.0).
Returns
Total memory in bytes

Definition at line 213 of file MemoryManager_module.f90.

◆ init_memory()

subroutine memorymanager_module::init_memory ( class(memorymanager this,
integer(longint), intent(in)  total_memory 
)
private

Same as constructor, used to reinitialize te memory again (not really used)

Authors
A Al-Refaie
Date
2017
Parameters
[in,out]thisManager object to update.
[in]total_memoryTotal available memory for the process in bytes

Definition at line 99 of file MemoryManager_module.f90.

◆ memorymanager_ctor()

subroutine memorymanager_module::memorymanager_ctor ( class(memorymanager this,
integer(longint), intent(in)  total_memory 
)
private

Constructor, used to initialize total available memory.

Authors
A Al-Refaie
Date
2017
Parameters
[in,out]thisManager object to update.
[in]total_memoryTotal available memory for the process in bytes

Definition at line 80 of file MemoryManager_module.f90.

◆ print_memory_report()

subroutine memorymanager_module::print_memory_report ( class(memorymanager this)
private

Prints a very simple memory report.

Authors
A Al-Refaie
Date
2017

Definition at line 231 of file MemoryManager_module.f90.

◆ track_memory()

subroutine memorymanager_module::track_memory ( class(memorymanager this,
integer, intent(in)  elem_size,
integer, intent(in)  nelem,
integer, intent(in)  stat,
character(len=*), intent(in)  array_name 
)
private

Tracks memory allocation, usually called after an allocation.

Authors
A Al-Refaie
Date
2017
Parameters
[in,out]thisManager object to update.
[in]elem_sizeSize in byte of each element
[in]nelemNumber of elements of size elem_size
[in]staterror Value after an allocate call
[in]array_nameAssigned name of array, used to debug where a memory allocation error occured.

Definition at line 121 of file MemoryManager_module.f90.

Variable Documentation

◆ master_memory

type(memorymanager), public memorymanager_module::master_memory

This is the global memory manager.

Authors
A Al-Refaie
Date
2017

No other memory manager can exist

Definition at line 69 of file MemoryManager_module.f90.