TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
TRUSTTravPool< _TYPE_ > Class Template Reference

#include <TRUSTTravPool.h>

Public Types

using block_ptr_t = std::shared_ptr<std::vector<_TYPE_, TVAlloc<_TYPE_> > >

Public Member Functions

 TRUSTTravPool ()=delete

Static Public Member Functions

static block_ptr_t GetFreeBlock (int sz)
static block_ptr_t ResizeBlock (block_ptr_t p, int new_sz)
static void ReleaseBlock (block_ptr_t)
static void ClearPool ()
static void DeleteOnDevice ()
static void PrintStats ()

Detailed Description

template<typename _TYPE_>
class TRUSTTravPool< _TYPE_ >

Pool of memory blocks used when requesting temporary storage (Trav arrays)

Purely static methods. One pool per base type (int, double, etc...).

The implementation details are in the .cpp file.

Definition at line 31 of file TRUSTTravPool.h.

Member Typedef Documentation

◆ block_ptr_t

template<typename _TYPE_>
using TRUSTTravPool< _TYPE_ >::block_ptr_t = std::shared_ptr<std::vector<_TYPE_, TVAlloc<_TYPE_> > >

Definition at line 34 of file TRUSTTravPool.h.

Constructor & Destructor Documentation

◆ TRUSTTravPool()

template<typename _TYPE_>
TRUSTTravPool< _TYPE_ >::TRUSTTravPool ( )
delete

Member Function Documentation

◆ ClearPool()

template<typename _TYPE_>
void TRUSTTravPool< _TYPE_ >::ClearPool ( )
static

Empty the TRUSTTrav pool explicitely.

Definition at line 235 of file TRUSTTravPool.cpp.

◆ DeleteOnDevice()

template<typename _TYPE_>
void TRUSTTravPool< _TYPE_ >::DeleteOnDevice ( )
static

◆ GetFreeBlock()

template<typename _TYPE_>
TRUSTTravPool< _TYPE_ >::block_ptr_t TRUSTTravPool< _TYPE_ >::GetFreeBlock ( int sz)
static

Retrieve a free block of size sz.

This takes the last available block from the list of the corresponding size, or returns a newly allocated block if none is available in the block.

Definition at line 115 of file TRUSTTravPool.cpp.

◆ PrintStats()

template<typename _TYPE_>
void TRUSTTravPool< _TYPE_ >::PrintStats ( )
static

Debug method printing useful stats.

Definition at line 261 of file TRUSTTravPool.cpp.

◆ ReleaseBlock()

template<typename _TYPE_>
void TRUSTTravPool< _TYPE_ >::ReleaseBlock ( block_ptr_t )
static

Release a block.

This is invoked from the dtor of TRUSTArray and makes the memory block available again by registering it in the pool of free blocks. We don't register blocks of size 0.

Definition at line 200 of file TRUSTTravPool.cpp.

◆ ResizeBlock()

template<typename _TYPE_>
TRUSTTravPool< _TYPE_ >::block_ptr_t TRUSTTravPool< _TYPE_ >::ResizeBlock ( block_ptr_t p,
int new_sz )
static

"Resize" a temporary Trav block - two possible strategies: Strategy 1

  • get a new free block of the new size
  • copy the former data into it
  • release the former small block (and so make it available for future potential use by another Trav)
  • danger: can lead to clottering of the pool if many incremental resize() are done (typically append_line() in a for loop...) -> mitigation: when the number of elements in the pool becomes too large, raise a warning Strategy 2
  • simply resize the underlying vector, hence completely forgetting the previous block which is never registered in the pool.
  • danger: can also lead to clottering of the pool if doing { DoubleTrav a(1); a.resize(10); } many times -> the array of size 10 is registered at each destruction (because it was always arrays of size 1 that were requested ...) -> same mitigation as above.

Definition at line 164 of file TRUSTTravPool.cpp.


The documentation for this class was generated from the following files:
  • /home/docs/checkouts/readthedocs.org/user_builds/cea-trust-platform/checkouts/v1.9.8/src/Kernel/Math/TRUSTTravPool.h
  • /home/docs/checkouts/readthedocs.org/user_builds/cea-trust-platform/checkouts/v1.9.8/src/Kernel/Math/TRUSTTravPool.cpp