FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
FEAT::Memory::View Class Reference

Raw memory view class. More...

#include <memory_arbiter.hpp>

Inheritance diagram for FEAT::Memory::View:
FEAT::Memory::TypedView< DT_ > FEAT::Memory::TypedView< FEAT::Tiny::Vector > FEAT::Memory::TypedView< IT_ > FEAT::Memory::TypedView< FEAT::Tiny::Matrix > FEAT::Memory::TypedView< T_ >

Public Member Functions

 View ()
 default constructor More...
 
 View (const View &)=delete
 no copy allowed
 
 View (View &&other)
 move-constructor More...
 
virtual ~View ()
 virtual destructor More...
 
Access access () const
 
std::size_t bytes () const
 
void copy_from (const View &src)
 Copies the contents of another view's memory region into the memory of this memory view. More...
 
void copy_raw_from (const void *src_ptr, Location src_loc)
 Copies the contents of a given memory region into the memory of this memory view. More...
 
bool empty () const
 Checks whether the memory view has a size of 0 bytes. More...
 
void format_to_one ()
 Formats all bits of the memory view to one (yields NaN for floating point types) More...
 
void format_to_zero ()
 Formats all bits of the memory view to zero. More...
 
bool is_nullptr () const
 Checks whether the memory pointer is a nullptr. More...
 
Location location () const
 
View & operator= (const View &)=delete
 no copy-assign allowed
 
View & operator= (View &&other)
 move-assign operator More...
 
const void * raw_r () const
 Returns a const raw pointer to the memory block that grants read access. More...
 
void * raw_w ()
 Returns a raw pointer to the memory block that grants write (and read) access. More...
 
bool readable () const
 
void release () const
 Releases this view. More...
 
bool writeable () const
 

Protected Member Functions

 View (Block *blk, Location l, Access a, std::size_t b, void *p)
 protected constructor; only the Arbiter is allowed to create views via this constructor More...
 
void _reset ()
 reset all attributes to null More...
 

Protected Attributes

Access _access
 the granted memory access More...
 
Block * _block
 the block that this view belongs to More...
 
std::size_t _bytes
 the size of the memory block in bytes More...
 
Location _location
 the current memory location More...
 
void * _ptr
 the actual memory pointer (may be a main or cuda or whatever pointer) More...
 

Friends

class Arbiter
 
class Block
 

Detailed Description

Raw memory view class.

This class represents a raw view for a (region of a bigger) memory block that is managed by the Memory::Arbiter class. This class stores a void pointer and the size of the memory block in bytes and it therefore does not offer any functionality related to array elements etc. as this class has no knowledge of how the data is to be interpreted.

If you need a view for a memory block that is interpreted as an (array of) object(s) of a certain data type or class, then consider the documentation of the Memory::TypedView class template, which is derived from this class.

See Memory Views, Locations and Access Rights for more information.

Author
Peter Zajac

Definition at line 228 of file memory_arbiter.hpp.

Constructor & Destructor Documentation

◆ View() [1/3]

FEAT::Memory::View::View ( Block *  blk,
Location  l,
Access  a,
std::size_t  b,
void *  p 
)
explicitprotected

protected constructor; only the Arbiter is allowed to create views via this constructor

Definition at line 1012 of file memory_arbiter.cpp.

◆ View() [2/3]

FEAT::Memory::View::View ( )

default constructor

Definition at line 1003 of file memory_arbiter.cpp.

◆ ~View()

FEAT::Memory::View::~View ( )
virtual

virtual destructor

Definition at line 1021 of file memory_arbiter.cpp.

References _block, and _ptr.

◆ View() [3/3]

FEAT::Memory::View::View ( View &&  other)

move-constructor

Definition at line 1030 of file memory_arbiter.cpp.

Member Function Documentation

◆ _reset()

void FEAT::Memory::View::_reset ( )
protected

reset all attributes to null

Definition at line 1063 of file memory_arbiter.cpp.

References _access, _block, _bytes, _location, _ptr, and FEAT::Memory::none.

Referenced by release().

◆ access()

Access FEAT::Memory::View::access ( ) const
inline
Returns
The access rights that this view was granted to the memory region

Definition at line 324 of file memory_arbiter.hpp.

References _access.

◆ bytes()

std::size_t FEAT::Memory::View::bytes ( ) const
inline
Returns
The size of the memory view in bytes

Definition at line 286 of file memory_arbiter.hpp.

References _bytes.

Referenced by copy_from(), and FEAT::Memory::TypedView< T_ >::size().

◆ copy_from()

void FEAT::Memory::View::copy_from ( const View &  src)
inline

Copies the contents of another view's memory region into the memory of this memory view.

In other words: this function performs a deep copy of the source view.

Note
This function has no effect if &src == this.
Parameters
[in]srcA transient reference to the view whose memory is to be copied into this view's memory. The source view may be larger than this view, but it must not be smaller.

Definition at line 369 of file memory_arbiter.hpp.

References bytes(), copy_raw_from(), location(), and raw_r().

◆ copy_raw_from()

void FEAT::Memory::View::copy_raw_from ( const void *  src_ptr,
Location  src_loc 
)

Copies the contents of a given memory region into the memory of this memory view.

Parameters
[in]src_ptrA transient pointer to a memory block that is to be copied into this view's memory
[in]src_locThe location of the source memory pointer src_ptr.

Definition at line 1098 of file memory_arbiter.cpp.

References _bytes, _location, _ptr, FEAT::Memory::cuda, FEAT::Memory::main, FEAT::Memory::memcopy_cuda(), FEAT::Memory::memcopy_cuda_to_main(), FEAT::Memory::memcopy_main(), FEAT::Memory::memcopy_main_to_cuda(), writeable(), XABORTM, and XASSERT.

Referenced by FEAT::LAFEM::Container< DT_, IT_ >::_deserialize(), FEAT::Memory::TypedView< T_ >::convert_from(), and copy_from().

◆ empty()

bool FEAT::Memory::View::empty ( ) const
inline

Checks whether the memory view has a size of 0 bytes.

Definition at line 272 of file memory_arbiter.hpp.

References _bytes.

Referenced by format_to_one(), and format_to_zero().

◆ format_to_one()

void FEAT::Memory::View::format_to_one ( )

Formats all bits of the memory view to one (yields NaN for floating point types)

Definition at line 1085 of file memory_arbiter.cpp.

References _bytes, _location, _ptr, empty(), FEAT::Memory::memset_cuda(), FEAT::Memory::memset_main(), and writeable().

◆ format_to_zero()

void FEAT::Memory::View::format_to_zero ( )

Formats all bits of the memory view to zero.

Definition at line 1072 of file memory_arbiter.cpp.

References _bytes, _location, _ptr, empty(), FEAT::Memory::memset_cuda(), FEAT::Memory::memset_main(), and writeable().

◆ is_nullptr()

bool FEAT::Memory::View::is_nullptr ( ) const
inline

Checks whether the memory pointer is a nullptr.

Definition at line 280 of file memory_arbiter.hpp.

References _ptr.

◆ location()

Location FEAT::Memory::View::location ( ) const
inline
Returns
The location of the memory that this view maps to; is always a single location

Definition at line 318 of file memory_arbiter.hpp.

References _location.

Referenced by FEAT::Memory::TypedView< T_ >::convert_from(), copy_from(), and FEAT::Memory::TypedView< T_ >::format().

◆ operator=()

View & FEAT::Memory::View::operator= ( View &&  other)

move-assign operator

Definition at line 1041 of file memory_arbiter.cpp.

References _access, _block, _bytes, _location, _ptr, and release().

◆ raw_r()

const void * FEAT::Memory::View::raw_r ( ) const
inline

Returns a const raw pointer to the memory block that grants read access.

Definition at line 311 of file memory_arbiter.hpp.

References _ptr.

Referenced by FEAT::LAFEM::Container< DT_, IT_ >::_serialize(), and copy_from().

◆ raw_w()

void * FEAT::Memory::View::raw_w ( )
inline

Returns a raw pointer to the memory block that grants write (and read) access.

Attention
This function will throw an exception if you call this function on a memory view that was created without write access rights!

Definition at line 301 of file memory_arbiter.hpp.

References _ptr, and writeable().

◆ readable()

bool FEAT::Memory::View::readable ( ) const
inline
Returns
Checks whether this view was granted read access rights to the memory region

Definition at line 330 of file memory_arbiter.hpp.

References FEAT::Memory::read.

◆ release()

◆ writeable()

bool FEAT::Memory::View::writeable ( ) const
inline
Returns
Checks whether this view was granted write access rights to the memory region

Definition at line 336 of file memory_arbiter.hpp.

References FEAT::Memory::write.

Referenced by copy_raw_from(), format_to_one(), format_to_zero(), FEAT::Memory::TypedView< T_ >::get_w(), and raw_w().

Friends And Related Function Documentation

◆ Arbiter

friend class Arbiter
friend

Definition at line 231 of file memory_arbiter.hpp.

◆ Block

friend class Block
friend

Definition at line 232 of file memory_arbiter.hpp.

Member Data Documentation

◆ _access

Access FEAT::Memory::View::_access
protected

the granted memory access

Definition at line 240 of file memory_arbiter.hpp.

Referenced by _reset(), access(), and operator=().

◆ _block

Block* FEAT::Memory::View::_block
protected

the block that this view belongs to

Definition at line 236 of file memory_arbiter.hpp.

Referenced by ~View(), _reset(), operator=(), and release().

◆ _bytes

std::size_t FEAT::Memory::View::_bytes
protected

the size of the memory block in bytes

Definition at line 242 of file memory_arbiter.hpp.

Referenced by _reset(), bytes(), copy_raw_from(), empty(), format_to_one(), format_to_zero(), and operator=().

◆ _location

Location FEAT::Memory::View::_location
protected

the current memory location

Definition at line 238 of file memory_arbiter.hpp.

Referenced by _reset(), copy_raw_from(), format_to_one(), format_to_zero(), location(), and operator=().

◆ _ptr

void* FEAT::Memory::View::_ptr
protected

the actual memory pointer (may be a main or cuda or whatever pointer)

Definition at line 244 of file memory_arbiter.hpp.

Referenced by ~View(), _reset(), copy_raw_from(), format_to_one(), format_to_zero(), FEAT::Memory::TypedView< T_ >::get_r(), FEAT::Memory::TypedView< T_ >::get_w(), is_nullptr(), operator=(), raw_r(), and raw_w().


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