AlignedAllocInterface class
dip::ExternalInterface
that allocates aligned data.
Contents
- Reference
Image data allocated by this external interface have each scan line aligned on a alignment
-byte boundary.
That is, the pointer to the first pixel of each scan line is aligned. This is accomplished by padding the
scan lines so that their length is a multiple of alignment
.
If alignment
is larger than alignof(std::max_align_t)
, then the first scan line is additionally aligned
by padding to its left: a larger buffer is allocated and std::align()
is used to get the aligned pointer.
The class is designed as a singleton: dip::AlignedAllocInterface::GetInstance
returns a pointer to a unique instance.
The alignment, in bytes, is passed to GetInstance
as a template parameter.
For example, here we create an allocator that guarantees 4-byte (32-bits) alignment:
ExternalInterface* ei = dip::AlignedAllocInterface::GetInstance<4>();
The scanline dimension is the first dimension.
Base classes
-
class dip::
ExternalInterface abstract - Support for external interfaces.
Functions
- auto AllocateData(void*& origin, dip::DataType dataType, dip::UnsignedArray const& sizes, dip::IntegerArray& strides, dip::Tensor const& tensor, dip::sint& tensorStride) -> dip::DataSegment override
- Called by
dip::Image::Forge
. -
template<dip::uint alignment>static auto GetInstance() -> dip::AlignedAllocInterface*
- Singleton interface, templated in the
alignment
parameter. Only one instance is needed for each distinct alignment.alignment
is in bytes.