Flow123d  DF_patch_fe_data_tables-9d4017b
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes | List of all members
ArenaResource< Resource > Class Template Reference

#include <arena_resource.hh>

Inheritance diagram for ArenaResource< Resource >:
Inheritance graph
[legend]
Collaboration diagram for ArenaResource< Resource >:
Collaboration graph
[legend]

Public Member Functions

 ArenaResource (size_t buffer_size, size_t simd_alignment, std::pmr::memory_resource *upstream=ArenaResource< Resource >::upstream_resource())
 Constructor. Creates assembly arena. More...
 
 ~ArenaResource ()=default
 
ArenaResourceget_child_arena ()
 
void print_space ()
 Compute and print free space and used space of arena buffer. Development method. More...
 
Resource & resource ()
 Getter for resource. More...
 
template<class T >
T * allocate_8 (size_t n_items)
 Allocate and return data pointer of n_item array of type T (alignment to length 8 bytes) More...
 
template<class T >
T * allocate_simd (size_t n_items)
 Allocate and return data pointer of n_item array of type T (alignment to length given by simd_alignment constructor argument) More...
 
void reset ()
 

Protected Member Functions

 ArenaResource (void *buffer, size_t buffer_size, size_t simd_alignment, std::pmr::memory_resource *upstream=ArenaResource< Resource >::upstream_resource())
 Inner constructor, used only in construction of child arena. More...
 
void * raw_allocate (size_t bytes, size_t alignment)
 
void * do_allocate (size_t bytes, size_t alignment) override
 Override do_allocate to handle allocation logic. More...
 
void do_deallocate (FMT_UNUSED void *p, FMT_UNUSED size_t bytes, FMT_UNUSED size_t alignment) override
 Override do_deallocate (no-op for monotonic buffer) More...
 
bool do_is_equal (const std::pmr::memory_resource &other) const noexcept override
 Override do_is_equal for memory resource comparison. More...
 

Static Protected Member Functions

static std::pmr::memory_resource * upstream_resource ()
 Returns different upstream resource in debug / release mode. More...
 

Private Attributes

std::pmr::memory_resource * upstream_
 Pointer to upstream. More...
 
void * buffer_
 Pointer to buffer. More...
 
size_t buffer_size_
 Size of buffer. More...
 
size_t used_size_
 Temporary data member, will be removed. More...
 
Resource resource_
 Resource of arena. More...
 
size_t simd_alignment_
 Size of SIMD alignment. More...
 
bool full_data_
 Flag signs full data (child arena is created) More...
 

Detailed Description

template<class Resource>
class ArenaResource< Resource >

Definition at line 31 of file arena_resource.hh.

Constructor & Destructor Documentation

◆ ArenaResource() [1/2]

template<class Resource >
ArenaResource< Resource >::ArenaResource ( void *  buffer,
size_t  buffer_size,
size_t  simd_alignment,
std::pmr::memory_resource *  upstream = ArenaResource<Resource>::upstream_resource() 
)
inlineprotected

Inner constructor, used only in construction of child arena.

Definition at line 34 of file arena_resource.hh.

Here is the caller graph for this function:

◆ ArenaResource() [2/2]

template<class Resource >
ArenaResource< Resource >::ArenaResource ( size_t  buffer_size,
size_t  simd_alignment,
std::pmr::memory_resource *  upstream = ArenaResource<Resource>::upstream_resource() 
)
inline

Constructor. Creates assembly arena.

Definition at line 57 of file arena_resource.hh.

◆ ~ArenaResource()

template<class Resource >
ArenaResource< Resource >::~ArenaResource ( )
default

Member Function Documentation

◆ allocate_8()

template<class Resource >
template<class T >
T* ArenaResource< Resource >::allocate_8 ( size_t  n_items)
inline

Allocate and return data pointer of n_item array of type T (alignment to length 8 bytes)

Definition at line 103 of file arena_resource.hh.

◆ allocate_simd()

template<class Resource >
template<class T >
T* ArenaResource< Resource >::allocate_simd ( size_t  n_items)
inline

Allocate and return data pointer of n_item array of type T (alignment to length given by simd_alignment constructor argument)

Definition at line 110 of file arena_resource.hh.

Here is the caller graph for this function:

◆ do_allocate()

template<class Resource >
void* ArenaResource< Resource >::do_allocate ( size_t  bytes,
size_t  alignment 
)
inlineoverrideprotected

Override do_allocate to handle allocation logic.

Definition at line 141 of file arena_resource.hh.

◆ do_deallocate()

template<class Resource >
void ArenaResource< Resource >::do_deallocate ( FMT_UNUSED void *  p,
FMT_UNUSED size_t  bytes,
FMT_UNUSED size_t  alignment 
)
inlineoverrideprotected

Override do_deallocate (no-op for monotonic buffer)

Definition at line 146 of file arena_resource.hh.

◆ do_is_equal()

template<class Resource >
bool ArenaResource< Resource >::do_is_equal ( const std::pmr::memory_resource &  other) const
inlineoverrideprotectednoexcept

Override do_is_equal for memory resource comparison.

Definition at line 151 of file arena_resource.hh.

◆ get_child_arena()

template<class Resource >
ArenaResource* ArenaResource< Resource >::get_child_arena ( )
inline

Create and return child arena.

Child arena is created in free space of actual arena. Actual arena is marked as full (flag full_data_) and cannot allocate new data.

Definition at line 78 of file arena_resource.hh.

◆ print_space()

template<class Resource >
void ArenaResource< Resource >::print_space ( )
inline

Compute and print free space and used space of arena buffer. Development method.

Definition at line 88 of file arena_resource.hh.

◆ raw_allocate()

template<class Resource >
void* ArenaResource< Resource >::raw_allocate ( size_t  bytes,
size_t  alignment 
)
inlineprotected

Definition at line 128 of file arena_resource.hh.

Here is the caller graph for this function:

◆ reset()

template<class Resource >
void ArenaResource< Resource >::reset ( )
inline

Definition at line 116 of file arena_resource.hh.

◆ resource()

template<class Resource >
Resource& ArenaResource< Resource >::resource ( )
inline

Getter for resource.

Definition at line 97 of file arena_resource.hh.

◆ upstream_resource()

template<class Resource >
static std::pmr::memory_resource* ArenaResource< Resource >::upstream_resource ( )
inlinestaticprotected

Returns different upstream resource in debug / release mode.

Definition at line 47 of file arena_resource.hh.

Member Data Documentation

◆ buffer_

template<class Resource >
void* ArenaResource< Resource >::buffer_
private

Pointer to buffer.

Definition at line 157 of file arena_resource.hh.

◆ buffer_size_

template<class Resource >
size_t ArenaResource< Resource >::buffer_size_
private

Size of buffer.

Definition at line 158 of file arena_resource.hh.

◆ full_data_

template<class Resource >
bool ArenaResource< Resource >::full_data_
private

Flag signs full data (child arena is created)

Definition at line 162 of file arena_resource.hh.

◆ resource_

template<class Resource >
Resource ArenaResource< Resource >::resource_
private

Resource of arena.

Definition at line 160 of file arena_resource.hh.

◆ simd_alignment_

template<class Resource >
size_t ArenaResource< Resource >::simd_alignment_
private

Size of SIMD alignment.

Definition at line 161 of file arena_resource.hh.

◆ upstream_

template<class Resource >
std::pmr::memory_resource* ArenaResource< Resource >::upstream_
private

Pointer to upstream.

Definition at line 156 of file arena_resource.hh.

◆ used_size_

template<class Resource >
size_t ArenaResource< Resource >::used_size_
private

Temporary data member, will be removed.

Definition at line 159 of file arena_resource.hh.


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