escript
Revision_
|
Taipan array manager, C++ version. Based on TaipanMemManager C module by Lutz Gross. More...
#include <Taipan.h>
Classes | |
struct | Taipan_MemTable |
struct | Taipan_StatTable |
Public Types | |
typedef long | size_type |
Public Member Functions | |
Taipan () | |
Default constructor for Taipan data-array manager. More... | |
~Taipan () | |
Default destructor for Taipan data-array manager. More... | |
double * | new_array (size_type dim, size_type N) |
Taipan data-array allocator. More... | |
void | delete_array (double *array) |
Taipan data-array deallocator. More... | |
void | release_unused_arrays () |
frees all arrays that are currently unused. More... | |
int | num_arrays () |
Calculate the total number of arrays currently under management. More... | |
int | num_arrays (size_type N) |
Calculate the total number of arrays of N blocks currently under management. More... | |
int | num_free (size_type N) |
Calculate the total number of free arrays of N blocks currently under management. More... | |
long | num_elements () |
Return the total number of array elements currently under management. More... | |
void | dump_stats () |
Print out statistics on the memory under management. More... | |
void | clear_stats () |
Clear record of statistics on the memory under management. More... | |
Private Types | |
typedef struct escript::Taipan::Taipan_StatTable | Taipan_StatTable |
typedef struct escript::Taipan::Taipan_MemTable | Taipan_MemTable |
Private Member Functions | |
void | operator= (const Taipan &c) |
Private Attributes | |
Taipan_StatTable * | statTable |
Taipan_MemTable * | memTable_Root |
long | totalElements |
Taipan array manager, C++ version. Based on TaipanMemManager C module by Lutz Gross.
Description: Taipan: data-array manager.
The Taipan data-array manager holds a set of (dim x N) arrays distributed across a number of threads. If a (dim x N) array is requested via the Taipan allocator, the buffer of managed arrays is searched for a free array of this size on the current number of threads. If none is available, a new one is allocated and added to the buffer of managed arrays.
When a managed array is deallocated, the array is marked as free but not returned to the system as long as at least one array of N is in use. Otherwise all arrays of N are deallocated as it is assumed that these arrays not be used anymore. The exceptions to this strategy are arrays with N=0 or N=1, these arrays are never deallocated, but are kept for possible reuse.
typedef long escript::Taipan::size_type |
|
private |
|
private |
escript::Taipan::Taipan | ( | ) |
Default constructor for Taipan data-array manager.
Description: Default constructor for Taipan data-array manager.
Preconditions: Describe any preconditions
Throws: Describe any exceptions thrown
References clear_stats(), and statTable.
escript::Taipan::~Taipan | ( | ) |
Default destructor for Taipan data-array manager.
Description: Default destructor for Taipan data-array manager.
Preconditions: Describe any preconditions
Throws: Describe any exceptions thrown
References escript::Taipan::Taipan_MemTable::array, escript::Taipan::Taipan_MemTable::dim, dump_stats(), memTable_Root, escript::Taipan::Taipan_MemTable::N, escript::Taipan::Taipan_MemTable::next, statTable, and totalElements.
void escript::Taipan::clear_stats | ( | ) |
Clear record of statistics on the memory under management.
References escript::Taipan::Taipan_StatTable::allocated_elements, escript::Taipan::Taipan_StatTable::allocations, escript::Taipan::Taipan_StatTable::deallocated_elements, escript::Taipan::Taipan_StatTable::deallocations, escript::Taipan::Taipan_StatTable::frees, escript::Taipan::Taipan_StatTable::max_tab_size, escript::Taipan::Taipan_StatTable::requests, statTable, and totalElements.
Referenced by Taipan().
void escript::Taipan::delete_array | ( | double * | array | ) |
Taipan data-array deallocator.
The parameter "array" should be an array object that was returned by Taipan::new_array.
References escript::Taipan::Taipan_MemTable::array, escript::Taipan::Taipan_StatTable::deallocated_elements, escript::Taipan::Taipan_StatTable::deallocations, escript::Taipan::Taipan_MemTable::dim, escript::Taipan::Taipan_MemTable::free, escript::Taipan::Taipan_StatTable::frees, memTable_Root, paso::N, escript::Taipan::Taipan_MemTable::N, escript::Taipan::Taipan_MemTable::next, statTable, and totalElements.
Referenced by escript::DataTypes::DataVectorTaipan::copyFromArray(), escript::DataTypes::DataVectorTaipan::operator=(), escript::DataTypes::DataVectorTaipan::resize(), and escript::DataTypes::DataVectorTaipan::~DataVectorTaipan().
void escript::Taipan::dump_stats | ( | ) |
Print out statistics on the memory under management.
References escript::Taipan::Taipan_StatTable::allocated_elements, escript::Taipan::Taipan_StatTable::allocations, escript::Taipan::Taipan_StatTable::deallocated_elements, escript::Taipan::Taipan_StatTable::deallocations, escript::Taipan::Taipan_StatTable::frees, escript::Taipan::Taipan_StatTable::max_tab_size, num_arrays(), num_elements(), escript::Taipan::Taipan_StatTable::requests, statTable, and totalElements.
Referenced by ~Taipan().
Taipan data-array allocator.
The parameter "dim" defines the contiguous "blocksize" within the array. Where the array is allocated accross multiple threads, it will be split on block boundaries only. N defines the number of "blocks" in the array.
References escript::Taipan::Taipan_StatTable::allocated_elements, escript::Taipan::Taipan_StatTable::allocations, escript::Taipan::Taipan_MemTable::array, escript::Taipan::Taipan_MemTable::dim, escript::Taipan::Taipan_MemTable::free, escript::Taipan::Taipan_StatTable::max_tab_size, memTable_Root, paso::N, escript::Taipan::Taipan_MemTable::N, escript::Taipan::Taipan_MemTable::next, escript::Taipan::Taipan_MemTable::numThreads, escript::Taipan::Taipan_StatTable::requests, statTable, and totalElements.
Referenced by escript::DataTypes::DataVectorTaipan::copyFromArray(), escript::DataTypes::DataVectorTaipan::DataVectorTaipan(), escript::DataTypes::DataVectorTaipan::operator=(), and escript::DataTypes::DataVectorTaipan::resize().
int escript::Taipan::num_arrays | ( | ) |
Calculate the total number of arrays currently under management.
References memTable_Root, escript::Taipan::Taipan_MemTable::next, and totalElements.
Referenced by dump_stats(), and num_arrays().
int escript::Taipan::num_arrays | ( | size_type | N | ) |
Calculate the total number of arrays of N blocks currently under management.
References memTable_Root, escript::Taipan::Taipan_MemTable::N, escript::Taipan::Taipan_MemTable::next, num_arrays(), and totalElements.
long escript::Taipan::num_elements | ( | ) |
Return the total number of array elements currently under management.
References totalElements.
Referenced by dump_stats().
int escript::Taipan::num_free | ( | size_type | N | ) |
Calculate the total number of free arrays of N blocks currently under management.
References escript::Taipan::Taipan_MemTable::free, memTable_Root, escript::Taipan::Taipan_MemTable::N, escript::Taipan::Taipan_MemTable::next, and totalElements.
|
inlineprivate |
Declared (private) as a precaution to ensure that noone tries to copy instances.
void escript::Taipan::release_unused_arrays | ( | ) |
frees all arrays that are currently unused.
References escript::Taipan::Taipan_MemTable::array, escript::Taipan::Taipan_StatTable::deallocated_elements, escript::Taipan::Taipan_StatTable::deallocations, escript::Taipan::Taipan_MemTable::dim, escript::Taipan::Taipan_MemTable::free, memTable_Root, escript::Taipan::Taipan_MemTable::N, escript::Taipan::Taipan_MemTable::next, statTable, and totalElements.
Referenced by escript::DataTypes::releaseUnusedMemory().
|
private |
Referenced by delete_array(), new_array(), num_arrays(), num_free(), release_unused_arrays(), and ~Taipan().
|
private |
Referenced by clear_stats(), delete_array(), dump_stats(), new_array(), release_unused_arrays(), Taipan(), and ~Taipan().
|
private |
Referenced by clear_stats(), delete_array(), dump_stats(), new_array(), num_arrays(), num_elements(), num_free(), release_unused_arrays(), and ~Taipan().