#include <MemoryStorage.h>
Public Types | |
typedef ValueType | value_type |
A class template to provide an interface that can act similar to STL vectors but with different MemorySpace— HOST (cpu) , DEVICE (gpu), etc,. More... | |
typedef ValueType * | pointer |
typedef ValueType & | reference |
typedef const ValueType & | const_reference |
typedef ValueType * | iterator |
typedef const ValueType * | const_iterator |
Public Member Functions | |
MemoryStorage ()=default | |
MemoryStorage (const MemoryStorage &u) | |
Copy constructor for a MemoryStorage. More... | |
MemoryStorage (MemoryStorage &&u) noexcept | |
Move constructor for a Vector. More... | |
MemoryStorage (size_type size, ValueType initVal=ValueType()) | |
Constructor for Vector with size and initial value arguments. More... | |
~MemoryStorage () | |
Destructor. More... | |
void | setValue (const ValueType val) |
Set all the entries to a given value. More... | |
iterator | begin () |
Return iterator pointing to the beginning of point data. More... | |
const_iterator | begin () const |
Return iterator pointing to the beginning of Vector data. More... | |
iterator | end () |
Return iterator pointing to the end of Vector data. More... | |
const_iterator | end () const |
Return iterator pointing to the end of Vector data. More... | |
MemoryStorage & | operator= (const MemoryStorage &rhs) |
Copy assignment operator. More... | |
MemoryStorage & | operator= (MemoryStorage &&rhs) noexcept |
Move assignment constructor. More... | |
void | resize (size_type size, ValueType initVal=ValueType()) |
Deallocates and then resizes Vector with new size and initial value arguments. More... | |
size_type | size () const |
Returns the dimension of the Vector. More... | |
ValueType * | data () noexcept |
Return the raw pointer to the Vector. More... | |
const ValueType * | data () const noexcept |
Return the raw pointer to the Vector without modifying the values. More... | |
template<dftefe::utils::MemorySpace memorySpaceDst> | |
void | copyTo (MemoryStorage< ValueType, memorySpaceDst > &dstMemoryStorage) const |
Copies the data to a MemoryStorage object in a different memory space. This provides a seamless interface to copy back and forth between memory spaces , including between the same memory spaces. More... | |
template<dftefe::utils::MemorySpace memorySpaceDst> | |
void | copyTo (MemoryStorage< ValueType, memorySpaceDst > &dstMemoryStorage, const size_type N, const size_type srcOffset, const size_type dstOffset) const |
Copies the data to a MemoryStorage object in a different memory space. This provides a seamless interface to copy back and forth between memory spaces , including between the same memory spaces. This is a more granular version of the above copyTo function as it provides transfer from a specific portion of the source MemoryStorage to a specific portion of the destination MemoryStorage. More... | |
template<dftefe::utils::MemorySpace memorySpaceSrc> | |
void | copyFrom (const MemoryStorage< ValueType, memorySpaceSrc > &srcMemoryStorage) |
Copies data from a MemoryStorage object in a different memory space. This provides a seamless interface to copy back and forth between memory spaces, including between the same memory spaces. More... | |
template<dftefe::utils::MemorySpace memorySpaceSrc> | |
void | copyFrom (MemoryStorage< ValueType, memorySpaceSrc > &srcMemoryStorage, const size_type N, const size_type srcOffset, const size_type dstOffset) |
Copies data from a MemoryStorage object in a different memory space. This provides a seamless interface to copy back and forth between memory spaces, including between the same memory spaces. This is a more granular version of the above copyFrom function as it provides transfer from a specific portion of the source MemoryStorage to a specific portion of the destination MemoryStorage. More... | |
template<dftefe::utils::MemorySpace memorySpaceDst> | |
void | copyTo (ValueType *dst) const |
Copies the data to a memory pointed by a raw pointer This provides a seamless interface to copy back and forth between memory spaces, including between the same memory spaces. More... | |
template<dftefe::utils::MemorySpace memorySpaceDst> | |
void | copyTo (ValueType *dst, const size_type N, const size_type srcOffset, const size_type dstOffset) const |
Copies the data to a memory pointer by a raw pointer. This provides a seamless interface to copy back and forth between memory spaces , including between the same memory spaces. This is a more granular version of the above copyTo function as it provides transfer from a specific portion of the source MemoryStorage to a specific portion of the destination pointer. More... | |
template<dftefe::utils::MemorySpace memorySpaceSrc> | |
void | copyFrom (const ValueType *src) |
Copies data from a memory pointed by a raw pointer into the MemoryStorage object. This provides a seamless interface to copy back and forth between memory spaces, including between the same memory spaces. More... | |
template<dftefe::utils::MemorySpace memorySpaceSrc> | |
void | copyFrom (const ValueType *src, const size_type N, const size_type srcOffset, const size_type dstOffset) |
Copies data from a memory pointer by a raw pointer into the MemoryStorage object. This provides a seamless interface to copy back and forth between memory spaces, including between the same memory spaces. This is a more granular version of the above copyFrom function as it provides transfer from a specific portion of the source memory to a specific portion of the destination MemoryStorage. More... | |
void | copyTo (std::vector< ValueType > &dst) const |
Copies the data to a C++ STL vector, which always resides in the CPU. This provides a seamless interface to copy from any memory space to a C++ STL vector, including the case where source memory space is HOST (i.e., it resides on the CPU) More... | |
void | copyTo (std::vector< ValueType > &dst, const size_type N, const size_type srcOffset, const size_type dstOffset) const |
Copies the data to a C++ STL vector, which always resides in the CPU. This provides a seamless interface to copy from any memory space to a C++ STL vector, including the case where source memory space is HOST (i.e., it resides on the CPU). This is a more granular version of the above copyToSTL function as it provides transfer from a specific portion of the MemoryStorage to a specific portion of the destination STL vector. More... | |
void | copyFrom (const std::vector< ValueType > &src) |
Copies data from a C++ STL vector to the MemoryStorage object, which always resides on a CPU. This provides a seamless interface to copy from any memory space, including the case where the same memory spaces is HOST(i.e., the MemoryStorage is on CPU). More... | |
void | copyFrom (const std::vector< ValueType > &src, const size_type N, const size_type srcOffset, const size_type dstOffset) |
Copies data from a C++ STL vector to the MemoryStorage object, which always resides on a CPU. This provides a seamless interface to copy from any memory space, including the case where the same memory spaces is HOST(i.e., the MemoryStorage is on CPU). This is a more granular version of the above copyFromSTL function as it provides transfer from a specific portion of the source STL vector to to a specific portion of the destination MemoryStorage. More... | |
Private Attributes | |
ValueType * | d_data = nullptr |
size_type | d_size = 0 |
typedef const ValueType* dftefe::utils::MemoryStorage< ValueType, memorySpace >::const_iterator |
typedef const ValueType& dftefe::utils::MemoryStorage< ValueType, memorySpace >::const_reference |
typedef ValueType* dftefe::utils::MemoryStorage< ValueType, memorySpace >::iterator |
typedef ValueType* dftefe::utils::MemoryStorage< ValueType, memorySpace >::pointer |
typedef ValueType& dftefe::utils::MemoryStorage< ValueType, memorySpace >::reference |
typedef ValueType dftefe::utils::MemoryStorage< ValueType, memorySpace >::value_type |
A class template to provide an interface that can act similar to STL vectors but with different MemorySpace— HOST (cpu) , DEVICE (gpu), etc,.
ValueType | The underlying value type for the MemoryStorage (e.g., int, double, complex<double>, etc.) |
memorySpace | The memory space in which the MemoryStorage needs to reside |
|
default |
dftefe::utils::MemoryStorage< ValueType, memorySpace >::MemoryStorage | ( | const MemoryStorage< ValueType, memorySpace > & | u | ) |
Copy constructor for a MemoryStorage.
[in] | u | MemoryStorage object to copy from |
|
noexcept |
Move constructor for a Vector.
[in] | u | Vector object to move from |
|
explicit |
Constructor for Vector with size and initial value arguments.
[in] | size | size of the Vector |
[in] | initVal | initial value of elements of the Vector |
dftefe::utils::MemoryStorage< ValueType, memorySpace >::~MemoryStorage |
Destructor.
MemoryStorage< ValueType, memorySpace >::iterator dftefe::utils::MemoryStorage< ValueType, memorySpace >::begin |
Return iterator pointing to the beginning of point data.
MemoryStorage< ValueType, memorySpace >::const_iterator dftefe::utils::MemoryStorage< ValueType, memorySpace >::begin |
Return iterator pointing to the beginning of Vector data.
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::copyFrom | ( | const MemoryStorage< ValueType, memorySpaceSrc > & | srcMemoryStorage | ) |
Copies data from a MemoryStorage object in a different memory space. This provides a seamless interface to copy back and forth between memory spaces, including between the same memory spaces.
memorySpaceSrc | memory space of the source MemoryStorage from which to copy |
[in] | srcMemoryStorage | reference to the source MemoryStorage |
utils::LengthError | exception if the size of underlying MemoryStorage is less than size of srcMemoryStorage |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::copyFrom | ( | const std::vector< ValueType > & | src | ) |
Copies data from a C++ STL vector to the MemoryStorage object, which always resides on a CPU. This provides a seamless interface to copy from any memory space, including the case where the same memory spaces is HOST(i.e., the MemoryStorage is on CPU).
[in] | src | const reference to the source C++ STL vector from which the data needs to be copied. |
utils::LengthError | exception if the size of the MemoryStorage is less than the size of the src |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::copyFrom | ( | const std::vector< ValueType > & | src, |
const size_type | N, | ||
const size_type | srcOffset, | ||
const size_type | dstOffset | ||
) |
Copies data from a C++ STL vector to the MemoryStorage object, which always resides on a CPU. This provides a seamless interface to copy from any memory space, including the case where the same memory spaces is HOST(i.e., the MemoryStorage is on CPU). This is a more granular version of the above copyFromSTL function as it provides transfer from a specific portion of the source STL vector to to a specific portion of the destination MemoryStorage.
[in] | src | const reference to the source C++ STL vector from which the data needs to be copied. |
[in] | N | number of entries of the source pointer that needs to be copied to the destination MemoryStorage |
[in] | srcOffset | offset relative to the start of the source STL vector from which we need to copy data |
[in] | dstOffset | offset relative to the start of the destination MemoryStorage to which we need to copy data |
utils::LengthError | exception if the size of src is less than N + srcOffset |
utils::LengthError | exception if the size of the MemoryStorage is less thant N + dstOffset |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::copyFrom | ( | const ValueType * | src | ) |
Copies data from a memory pointed by a raw pointer into the MemoryStorage object. This provides a seamless interface to copy back and forth between memory spaces, including between the same memory spaces.
memorySpaceSrc | memory space of the source pointer from which to copy |
[in] | src | pointer to the source memory |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::copyFrom | ( | const ValueType * | src, |
const size_type | N, | ||
const size_type | srcOffset, | ||
const size_type | dstOffset | ||
) |
Copies data from a memory pointer by a raw pointer into the MemoryStorage object. This provides a seamless interface to copy back and forth between memory spaces, including between the same memory spaces. This is a more granular version of the above copyFrom function as it provides transfer from a specific portion of the source memory to a specific portion of the destination MemoryStorage.
memorySpaceSrc | memory space of the source pointer from which to copy |
[in] | src | pointer to the source memory |
[in] | N | number of entries of the source pointer that needs to be copied to the destination MemoryStorage |
[in] | srcOffset | offset relative to the start of the source pointer from which we need to copy data |
[in] | dstOffset | offset relative to the start of the destination MemoryStorage to which we need to copy data |
utils::LengthError | exception if the size of the MemoryStorage is less than N + dstOffset |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::copyFrom | ( | MemoryStorage< ValueType, memorySpaceSrc > & | srcMemoryStorage, |
const size_type | N, | ||
const size_type | srcOffset, | ||
const size_type | dstOffset | ||
) |
Copies data from a MemoryStorage object in a different memory space. This provides a seamless interface to copy back and forth between memory spaces, including between the same memory spaces. This is a more granular version of the above copyFrom function as it provides transfer from a specific portion of the source MemoryStorage to a specific portion of the destination MemoryStorage.
memorySpaceSrc | memory space of the source MemoryStorage from which to copy |
[in] | srcMemoryStorage | reference to the source MemoryStorage |
[in] | N | number of entries of the source MemoryStorage that needs to be copied to the destination MemoryStorage |
[in] | srcOffset | offset relative to the start of the source MemoryStorage from which we need to copy data |
[in] | dstOffset | offset relative to the start of the destination MemoryStorage to which we need to copy data |
utils::LengthError | exception if the size of srcMemoryStorage is less than N + srcOffset |
utils::LengthError | exception if the size of underlying MemoryStorage is less than N + dstOffset |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::copyTo | ( | MemoryStorage< ValueType, memorySpaceDst > & | dstMemoryStorage | ) | const |
Copies the data to a MemoryStorage object in a different memory space. This provides a seamless interface to copy back and forth between memory spaces , including between the same memory spaces.
memorySpaceDst | memory space of the destination MemoryStorage |
[in] | dstMemoryStorage | reference to the destination MemoryStorage. It must be pre-allocated appropriately |
[out] | dstMemoryStorage | reference to the destination MemoryStorage with the data copied into it |
utils::LengthError | exception if the size of dstMemoryStorage is less than underlying MemoryStorage |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::copyTo | ( | MemoryStorage< ValueType, memorySpaceDst > & | dstMemoryStorage, |
const size_type | N, | ||
const size_type | srcOffset, | ||
const size_type | dstOffset | ||
) | const |
Copies the data to a MemoryStorage object in a different memory space. This provides a seamless interface to copy back and forth between memory spaces , including between the same memory spaces. This is a more granular version of the above copyTo function as it provides transfer from a specific portion of the source MemoryStorage to a specific portion of the destination MemoryStorage.
memorySpaceDst | memory space of the destination MemoryStorage |
[in] | dstMemoryStorage | reference to the destination MemoryStorage. It must be pre-allocated appropriately |
[in] | N | number of entries of the source MemoryStorage that needs to be copied to the destination MemoryStorage |
[in] | srcOffset | offset relative to the start of the source MemoryStorage from which we need to copy data |
[in] | dstOffset | offset relative to the start of the destination MemoryStorage to which we need to copy data |
[out] | dstMemoryStorage | reference to the destination MemoryStorage with the data copied into it |
utils::LengthError | exception if the size of dstMemoryStorage is less than N + dstOffset |
utils::LengthError | exception if the size of underlying MemoryStorage is less than N + srcOffset |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::copyTo | ( | std::vector< ValueType > & | dst | ) | const |
Copies the data to a C++ STL vector, which always resides in the CPU. This provides a seamless interface to copy from any memory space to a C++ STL vector, including the case where source memory space is HOST (i.e., it resides on the CPU)
[in] | dst | reference to the destination C++ STL vector to which the data needs to be copied. |
[out] | dst | reference to the destination C++ STL vector with the data copied into it |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::copyTo | ( | std::vector< ValueType > & | dst, |
const size_type | N, | ||
const size_type | srcOffset, | ||
const size_type | dstOffset | ||
) | const |
Copies the data to a C++ STL vector, which always resides in the CPU. This provides a seamless interface to copy from any memory space to a C++ STL vector, including the case where source memory space is HOST (i.e., it resides on the CPU). This is a more granular version of the above copyToSTL function as it provides transfer from a specific portion of the MemoryStorage to a specific portion of the destination STL vector.
[in] | dst | reference to the destination C++ STL vector to which the data needs to be copied. |
[in] | N | number of entries of the source MemoryStorage that needs to be copied to the destination pointer |
[in] | srcOffset | offset relative to the start of the source MemoryStorage from which we need to copy data |
[in] | dstOffset | offset relative to the start of the STL vector to which we need to copy data |
[out] | dst | reference to the destination C++ STL vector with the data copied into it |
utils::LengthError | exception if the size of the MemoryStorage is less than N + srcOffset |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::copyTo | ( | ValueType * | dst | ) | const |
Copies the data to a memory pointed by a raw pointer This provides a seamless interface to copy back and forth between memory spaces, including between the same memory spaces.
memorySpaceDst | memory space of the destination pointer |
[in] | dst | pointer to the destination. It must be pre-allocated appropriately |
[out] | dst | pointer to the destination with the data copied into it |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::copyTo | ( | ValueType * | dst, |
const size_type | N, | ||
const size_type | srcOffset, | ||
const size_type | dstOffset | ||
) | const |
Copies the data to a memory pointer by a raw pointer. This provides a seamless interface to copy back and forth between memory spaces , including between the same memory spaces. This is a more granular version of the above copyTo function as it provides transfer from a specific portion of the source MemoryStorage to a specific portion of the destination pointer.
memorySpaceDst | memory space of the destination pointer |
[in] | dst | pointer to the destination. It must be pre-allocated appropriately |
[in] | N | number of entries of the source MemoryStorage that needs to be copied to the destination pointer |
[in] | srcOffset | offset relative to the start of the source MemoryStorage from which we need to copy data |
[in] | dstOffset | offset relative to the start of the destination pointer to which we need to copy data |
[out] | dst | pointer to the destination with the data copied into it |
utils::LengthError | exception if the size of the MemoryStorage is less than N + srcOffset |
|
noexcept |
Return the raw pointer to the Vector without modifying the values.
|
noexcept |
Return the raw pointer to the Vector.
MemoryStorage< ValueType, memorySpace >::iterator dftefe::utils::MemoryStorage< ValueType, memorySpace >::end |
Return iterator pointing to the end of Vector data.
MemoryStorage< ValueType, memorySpace >::const_iterator dftefe::utils::MemoryStorage< ValueType, memorySpace >::end |
Return iterator pointing to the end of Vector data.
MemoryStorage< ValueType, memorySpace > & dftefe::utils::MemoryStorage< ValueType, memorySpace >::operator= | ( | const MemoryStorage< ValueType, memorySpace > & | rhs | ) |
Copy assignment operator.
[in] | rhs | the rhs Vector from which to copy |
|
noexcept |
Move assignment constructor.
[in] | rhs | the rhs Vector from which to move |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::resize | ( | size_type | size, |
ValueType | initVal = ValueType() |
||
) |
Deallocates and then resizes Vector with new size and initial value arguments.
[in] | size | size of the Vector |
[in] | initVal | initial value of elements of the Vector |
void dftefe::utils::MemoryStorage< ValueType, memorySpace >::setValue | ( | const ValueType | val | ) |
Set all the entries to a given value.
[in] | val | The value to which the entries are to be set |
size_type dftefe::utils::MemoryStorage< ValueType, memorySpace >::size |
Returns the dimension of the Vector.
|
private |
|
private |