MAIA bb96820c
Multiphysics at AIA
|
This class is a ScratchSpace. More...
#include <scratch.h>
Classes | |
struct | p_ |
Public Types | |
using | value_type = T |
using | reference = value_type & |
using | const_reference = const value_type & |
using | pointer = value_type * |
using | const_pointer = const value_type * |
using | iterator = pointer |
using | const_iterator = const_pointer |
using | difference_type = long |
using | size_type = std::size_t |
using | value_type = T |
using | reference = typename Storage::reference |
using | const_reference = typename Storage::const_reference |
using | pointer = typename Storage::pointer |
using | const_pointer = typename Storage::const_pointer |
using | iterator = typename Storage::iterator |
using | const_iterator = typename Storage::const_iterator |
using | size_type = MLong |
Public Member Functions | |
ScratchSpace (MInt num, const MString &name, const MString &varname) | |
1D Scratch constructor More... | |
ScratchSpace (MInt num0, MInt num1, const MString &name, const MString &varname) | |
2D Scratch constructor More... | |
ScratchSpace (MInt num0, MInt num1, MInt num2, const MString &name, const MString &varname) | |
3D Scratch constructor More... | |
~ScratchSpace () | |
Destructor. More... | |
template<class Integral > | |
reference | operator[] (const Integral) |
1D Scratch access More... | |
template<class Integral > | |
reference | operator() (const Integral) |
1D Scratch access More... | |
template<class Integral > | |
reference | operator() (const Integral, const Integral) |
2D Scratch access More... | |
template<class Integral > | |
reference | operator() (const Integral, const Integral, const Integral) |
3D Scratch access More... | |
template<class Integral > | |
const_reference | operator[] (const Integral i) const |
1D Scratch const access More... | |
template<class Integral > | |
const_reference | operator() (const Integral i) const |
1D Scratch const access More... | |
template<class Integral > | |
const_reference | operator() (const Integral, const Integral) const |
2D Scratch const access More... | |
template<class Integral > | |
const_reference | operator() (const Integral, const Integral, const Integral) const |
3D Scratch const access More... | |
ScratchSpace< T > & | operator= (ScratchSpace< T > &) |
copy entries of S to this, given there is enough space available More... | |
iterator | begin () |
iterator | cbegin () const |
iterator | end () |
iterator | cend () const |
pointer | data () |
const_pointer | data () const |
MInt | size0 () const |
MInt | size1 () const |
MInt | size2 () const |
size_t | getMemsize () const |
size_type | size () const |
MBool | empty () const |
void | fill (T val) |
fill the scratch with a given value More... | |
MString | printSelf () const override |
Returns a string summing up this scratch space element information. More... | |
MString | printSelfReport () const override |
Returns a shortened string summing up this scratch space element information. More... | |
T * | getPointer () const |
Deprecated: use begin() instead! More... | |
ScratchSpace ()=delete | |
ScratchSpace (const ScratchSpace< T > &)=delete | |
void * | operator new (std::size_t)=delete |
void * | operator new (std::size_t, void *p)=delete |
void * | operator new[] (std::size_t)=delete |
void * | operator new[] (std::size_t, void *p)=delete |
void | operator delete (void *)=delete |
void | operator delete (void *p, void *)=delete |
void | operator delete[] (void *)=delete |
void | operator delete[] (void *p, void *)=delete |
ScratchSpace (const size_type size_, const MString &, const MString &) | |
ScratchSpace (const size_type size0, const size_type size1, const MString &, const MString &) | |
size_type | size () const |
void | fill (const T value) |
reference | operator[] (const size_type pos) |
reference | operator() (const size_type pos) |
const_reference | operator[] (const size_type pos) const |
const_reference | operator() (const size_type pos) const |
reference | operator() (const size_type i, const size_type j) |
const_reference | operator() (const size_type i, const size_type j) const |
T * | getPointer () |
pointer | data () |
const_pointer | data () const |
iterator | begin () |
iterator | end () |
iterator | cbegin () const |
iterator | cend () const |
MInt | size0 () const |
MInt | size1 () const |
MInt | size2 () const |
Public Member Functions inherited from ScratchSpaceBase | |
ScratchSpaceBase (size_t num, size_t size, MString name, MString varname) | |
Constructor. More... | |
virtual MString | printSelfReport () const =0 |
virtual MString | printSelf () const =0 |
Public Attributes | |
pointer | p |
Deprecated: use [] instead! More... | |
p_ | p |
Public Attributes inherited from ScratchSpaceBase | |
const size_t | m_memsize |
const size_t | m_memsizePadded |
const MString | m_calling_function |
const MString | m_variable_name |
MInt | m_object_id {} |
MBool | m_nonterminal |
MBool | m_destroy |
Private Types | |
using | Storage = std::vector< T > |
Private Member Functions | |
void | init () |
extended constructor functionality More... | |
void | checkForEmptyScratch () const |
Checks if scratch space is empty before returning a pointer to it. More... | |
template<class Integral > | |
void | testBounds (const Integral &i) const |
Assert the bounds of 1D acces to an array. More... | |
template<class Integral > | |
MBool | checkBounds (const Integral &i) const |
template<class Integral > | |
MBool | checkBounds (const Integral &i, maia::maia_unsigned) const |
template<class Integral > | |
MBool | checkBounds (const Integral &i, maia::maia_signed) const |
Private Attributes | |
pointer | last |
const MInt | m_size0 |
const MInt | m_size1 |
const MInt | m_size2 |
size_type | m_size0 |
size_type | m_size1 |
size_type | m_size2 |
Storage | m_data |
Friends | |
template<class > | |
std::ostream & | operator<< (std::ostream &os, const ScratchSpace &s) |
Print contents of scratch space object. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from ScratchSpaceBase | |
static const uintptr_t | ALIGNMENT_BOUNDARY = MAIA_SCRATCH_ALIGNMENT_BOUNDARY |
This class is a derivative of ScratchSpaceBase and is responsible for the management of the scratch space to be allocated. Scratch objects partially model the container concept and should be usable with some, but not all, STL algorithms.
using ScratchSpace< T >::const_iterator = const_pointer |
using ScratchSpace< T >::const_iterator = typename Storage::const_iterator |
using ScratchSpace< T >::const_pointer = const value_type* |
using ScratchSpace< T >::const_pointer = typename Storage::const_pointer |
using ScratchSpace< T >::const_reference = const value_type& |
using ScratchSpace< T >::const_reference = typename Storage::const_reference |
using ScratchSpace< T >::difference_type = long |
using ScratchSpace< T >::iterator = pointer |
using ScratchSpace< T >::iterator = typename Storage::iterator |
using ScratchSpace< T >::pointer = value_type* |
using ScratchSpace< T >::pointer = typename Storage::pointer |
using ScratchSpace< T >::reference = value_type& |
using ScratchSpace< T >::reference = typename Storage::reference |
using ScratchSpace< T >::size_type = std::size_t |
using ScratchSpace< T >::size_type = MLong |
|
private |
using ScratchSpace< T >::value_type = T |
using ScratchSpace< T >::value_type = T |
ScratchSpace< T >::ScratchSpace | ( | MInt | num, |
const MString & | name, | ||
const MString & | varname | ||
) |
Constructor.
Allocates a scratch space element of a certain type. If not enough memory is available provided by the Scratch class, it terminates the program run. Otherwise the properties of this management object are set and a pointer to this object is stored in the management list of the Scratch class. If a maximum of memory of the Scratch is used, the state stored to be outputed at the end of the program run to enable memory analysis.
[num] | num number of elements in array |
[name] | name the name of the calling function |
[varname] | varname the name of the array variable |
Note: If MAIA_EXTRA_DEBUG is defined writes a SCRATCH_DOUBLE_ALLOCATION WARNING at run-time if allocation of two variables with the same name is performed.
ScratchSpace< T >::ScratchSpace | ( | MInt | num0, |
MInt | num1, | ||
const MString & | name, | ||
const MString & | varname | ||
) |
Constructor for 2D scratch.
This is the 2D-extension of the 1D constructor above. Unfortunately, the order of constructor arguments prohibits the use of a constructor default value for the second dimension, so most of the code here is redundant.
ScratchSpace< T >::ScratchSpace | ( | MInt | num0, |
MInt | num1, | ||
MInt | num2, | ||
const MString & | name, | ||
const MString & | varname | ||
) |
Constructor for 3D scratch.
This is the 3D-extension of the 1D constructor above. Unfortunately, the order of constructor arguments prohibits the use of constructor default values for the second and third dimension, so most of the code here is redundant.
ScratchSpace< T >::~ScratchSpace |
Removes this scratch space elemet from the list of all scratch elements.
Only delete if we are at the last element (guaranteed by C++)
|
delete |
|
delete |
|
inline |
|
inline |
|
inline |
Definition at line 273 of file scratch.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
Note: the check is only performed if NDEBUG is not defined, and MAIA_EXTRA_DEBUG is defined.
Definition at line 738 of file scratch.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
Content was moved from the constructor body to this function since it is the same for all above constructors (Lennart)
Check if allocation would exceed the available scratch space:
Check for double allocation:
Definition at line 451 of file scratch.h.
|
delete |
|
delete |
|
delete |
|
delete |
|
delete |
|
delete |
|
delete |
|
delete |
|
inline |
Definition at line 631 of file scratch.h.
|
inline |
Access the i-th element of the scratch object.
[i] | Index of Integral type. |
[Integral] | Type that models the Integral concept. |
Note: if NDEBUG is not defined, the array bounds are checked: i >= 0 and i < size. If bound checking fails the program will terminate with a SCRATCH_OUT_OF_BOUNDS ERROR.
|
inline |
2D and 3D Scratch access
Note: this would probably result in a compilation error if m_sizeX
Definition at line 656 of file scratch.h.
|
inline |
Definition at line 677 of file scratch.h.
|
inline |
Definition at line 666 of file scratch.h.
|
inline |
Definition at line 687 of file scratch.h.
|
inline |
|
inline |
|
inline |
|
inline |
ScratchSpace< T > & ScratchSpace< T >::operator= | ( | ScratchSpace< T > & | S | ) |
|
inline |
|
inline |
For 1D access the [] operator is also provided, the () operator should be preferred.
|
inline |
|
inline |
|
overridevirtual |
Implements ScratchSpaceBase.
|
overridevirtual |
This function is used in the report process for tracking the occasion of maximal memory usage during program execution.
Implements ScratchSpaceBase.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineprivate |
Note: the condition is tested by checkBounds, which is overloaded for signed and unsigned indices using the maia::is_unsigned trait.
Definition at line 601 of file scratch.h.
|
friend |
T | Element type. |
[in] | os | Stream object to write to. |
[in] | s | Scratch space object. |
Note: if T is not convertible to string, the contents are not printed.
Definition at line 722 of file scratch.h.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
pointer ScratchSpace< T >::p |
p_ ScratchSpace< T >::p |