16 #include "LvArrayConfig.hpp" 35 template<
typename T >
88 template<
typename U >
91 m_data( reinterpret_cast< T * >( src.
data() ) ),
119 src.m_data =
nullptr;
135 T *
const newPtr =
reinterpret_cast< T *
>( std::malloc( newCapacity *
sizeof( T ) ) );
137 std::ptrdiff_t
const overlapAmount =
math::min( newCapacity, size );
178 template<
typename INDEX_TYPE >
LVARRAY_HOST_DEVICE void free()
Free the data in the buffer but does not destroy any values.
Definition: MallocBuffer.hpp:151
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void uninitializedMove(T *const LVARRAY_RESTRICT dst, std::ptrdiff_t const size, T *const LVARRAY_RESTRICT src)
Move construct values from the source to the destination.
Definition: arrayManipulation.hpp:201
LVARRAY_HOST_DEVICE constexpr MallocBuffer(bool=true)
Constructor for creating an empty or uninitialized buffer.
Definition: MallocBuffer.hpp:52
LVARRAY_HOST_DEVICE LVARRAY_INTEL_CONSTEXPR MallocBuffer & operator=(MallocBuffer &&src)
Move assignment operator, creates a shallow copy.
Definition: MallocBuffer.hpp:114
T value_type
Alias used in the bufferManipulation functions.
Definition: MallocBuffer.hpp:41
LVARRAY_HOST_DEVICE constexpr T * data() const
Definition: MallocBuffer.hpp:169
std::ptrdiff_t m_capacity
The size of the allocation.
Definition: MallocBuffer.hpp:189
static constexpr bool hasShallowCopy
Signifies that the MallocBuffer's copy semantics are shallow.
Definition: MallocBuffer.hpp:44
T *LVARRAY_RESTRICT m_data
A pointer to the data.
Definition: MallocBuffer.hpp:186
This class implements the default behavior for the Buffer methods related to execution space...
Definition: bufferManipulation.hpp:78
constexpr LVARRAY_HOST_DEVICE std::enable_if_t<(sizeof(T)<=sizeof(U)), INDEX_TYPE > convertSize(INDEX_TYPE const numU)
Convert a number of values of type U to a number of values of type T.
Definition: typeManipulation.hpp:476
LVARRAY_HOST_DEVICE LVARRAY_FORCE_INLINE constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > min(T const a, T const b)
Definition: math.hpp:362
LVARRAY_HOST_DEVICE void reallocate(std::ptrdiff_t const size, MemorySpace const space, std::ptrdiff_t const newCapacity)
Reallocate the buffer to the new capacity.
Definition: MallocBuffer.hpp:130
Contains functions for manipulating buffers.
Contains some portable math functions.
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void free(BUFFER &buf, std::ptrdiff_t const size)
Destroy the values in the buffer and free it's memory.
Definition: bufferManipulation.hpp:188
camp::resources::Platform MemorySpace
an alias for camp::resources::Platform.
Definition: bufferManipulation.hpp:31
LVARRAY_HOST_DEVICE constexpr T & operator[](INDEX_TYPE const i) const
Definition: MallocBuffer.hpp:180
The top level namespace.
Definition: Array.hpp:24
LVARRAY_HOST_DEVICE LVARRAY_INTEL_CONSTEXPR MallocBuffer & operator=(MallocBuffer const &src)
Copy assignment operator, creates a shallow copy.
Definition: MallocBuffer.hpp:101
Contains a bunch of macro definitions.
MallocBuffer(MallocBuffer const &src, std::ptrdiff_t)
Sized copy constructor, creates a shallow copy.
Definition: MallocBuffer.hpp:66
DISABLE_HD_WARNING LVARRAY_HOST_DEVICE void destroy(T *const LVARRAY_RESTRICT ptr, std::ptrdiff_t const size)
Destory the values in the array.
Definition: arrayManipulation.hpp:152
LVARRAY_HOST_DEVICE constexpr MallocBuffer(MallocBuffer< U > const &src)
Create a shallow copy of src but with a different type.
Definition: MallocBuffer.hpp:90
Implements the Buffer interface using malloc and free.
Definition: MallocBuffer.hpp:36
LVARRAY_HOST_DEVICE std::ptrdiff_t capacity() const
Definition: MallocBuffer.hpp:162
#define LVARRAY_ERROR_IF_NE(lhs, rhs)
Raise a hard error if two values are not equal.
Definition: Macros.hpp:360
LVARRAY_HOST_DEVICE constexpr MallocBuffer(MallocBuffer &&src)
Move constructor, creates a shallow copy.
Definition: MallocBuffer.hpp:75
#define LVARRAY_HOST_DEVICE
Mark a function for both host and device usage.
Definition: Macros.hpp:600