14 template<
typename TElem,
typename TDim,
typename TIdx>
21 template<
typename TElem,
typename TDim,
typename TIdx>
28 template<
typename TElem,
typename TDim,
typename TIdx>
33 return buf.m_spBufImpl->m_dev;
38 template<
typename TElem,
typename TDim,
typename TIdx>
45 template<
typename TElem,
typename TDim,
typename TIdx>
52 template<
typename TElem,
typename TDim,
typename TIdx>
62 template<
typename TElem,
typename TDim,
typename TIdx>
67 return buf.m_spBufImpl->m_pMem;
72 return buf.m_spBufImpl->m_pMem;
77 template<
typename TElem,
typename TDim,
typename TIdx>
84 return buf.m_spBufImpl->m_pMem;
88 throw std::runtime_error(
"The buffer is not accessible from the given device!");
96 return buf.m_spBufImpl->m_pMem;
100 throw std::runtime_error(
"The buffer is not accessible from the given device!");
106 template<
typename TElem,
typename TDim,
typename TIdx>
116 template<
typename TElem,
typename TDim,
typename TIdx>
123 template<
typename TElem,
typename TDim,
typename TIdx>
138 template<
typename TElem,
typename TDim,
typename TIdx>
141 template<
typename TExtent>
149#if defined(ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT)
151 ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT > 0
152 && ((ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT & (ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT - 1)) == 0),
153 "If defined, ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT must be a power of 2.");
154 constexpr std::size_t alignment =
static_cast<std::size_t
>(ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT);
160 static_assert(std::is_empty_v<Allocator>,
"AllocCpuAligned is expected to be stateless");
161 auto* memPtr = alpaka::malloc<TElem>(Allocator{},
static_cast<std::size_t
>(
getExtentProduct(extent)));
162 auto deleter = [](TElem* ptr) {
alpaka::free(Allocator{}, ptr); };
169 template<
typename TDim>
175 template<
typename TElem,
typename TDim,
typename TIdx>
178 template<
typename TQueue,
typename TExtent>
184 std::is_same_v<Dev<TQueue>,
DevCpu>,
185 "The BufCpu buffer can only be used with a queue on a DevCpu device!");
191#if defined(ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT)
193 ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT > 0
194 && ((ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT & (ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT - 1)) == 0),
195 "If defined, ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT must be a power of 2.");
196 constexpr std::size_t alignment =
static_cast<std::size_t
>(ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT);
202 static_assert(std::is_empty_v<Allocator>,
"AllocCpuAligned is expected to be stateless");
203 auto* memPtr = alpaka::malloc<TElem>(Allocator{},
static_cast<std::size_t
>(
getExtentProduct(extent)));
204 auto deleter = [l_queue = std::move(queue)](TElem* ptr)
mutable
226 template<
typename TElem,
typename TDim,
typename TIdx>
229 template<
typename TExtent>
236 return allocBuf<TElem, TIdx>(host, extent);
#define ALPAKA_DEBUG_MINIMAL_LOG_SCOPE
The CPU boost aligned allocator.
The CPU memory buffer template implementing muting accessors.
std::shared_ptr< TBufImpl > m_spBufImpl
ALPAKA_NO_HOST_ACC_WARNING static ALPAKA_FN_HOST_ACC constexpr auto zeros() -> Vec< TDim, TVal >
Zero value constructor.
constexpr std::size_t defaultAlignment
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto getExtentProduct(T const &object) -> Idx< T >
ALPAKA_FN_HOST auto free(TAlloc const &alloc, T const *const ptr) -> void
Frees the memory identified by the given pointer.
ALPAKA_FN_HOST auto getDev(T const &t)
ALPAKA_FN_HOST auto enqueue(TQueue &queue, TTask &&task) -> void
Queues the given task in the given queue.
static ALPAKA_FN_HOST auto allocAsyncBuf(TQueue queue, TExtent const &extent) -> BufCpu< TElem, TDim, TIdx >
The stream-ordered memory allocator trait.
The pinned/mapped memory allocator trait.
static ALPAKA_FN_HOST auto allocBuf(DevCpu const &dev, TExtent const &extent) -> BufCpu< TElem, TDim, TIdx >
The memory allocator trait.
The memory buffer type trait.
The dimension getter type trait.
static ALPAKA_FN_HOST auto getDev(BufCpu< TElem, TDim, TIdx > const &buf) -> DevCpu
ALPAKA_FN_HOST auto operator()(BufCpu< TElem, TDim, TIdx > const &buf)
The GetExtents trait for getting the extents of an object as an alpaka::Vec.
ALPAKA_FN_HOST auto operator()(BufCpu< TElem, TDim, TIdx > const &) const -> Vec< TDim, TIdx >
The GetOffsets trait for getting the offsets of an object as an alpaka::Vec.
static ALPAKA_FN_HOST auto getPtrDev(BufCpu< TElem, TDim, TIdx > &buf, DevCpu const &dev) -> TElem *
static ALPAKA_FN_HOST auto getPtrDev(BufCpu< TElem, TDim, TIdx > const &buf, DevCpu const &dev) -> TElem const *
The pointer on device get trait.
static ALPAKA_FN_HOST auto getPtrNative(BufCpu< TElem, TDim, TIdx > &buf) -> TElem *
static ALPAKA_FN_HOST auto getPtrNative(BufCpu< TElem, TDim, TIdx > const &buf) -> TElem const *
The native pointer get trait.
The stream-ordered memory allocation capability trait.
The pinned/mapped memory allocation capability trait.
static ALPAKA_FN_HOST auto makeConstBuf(BufCpu< TElem, TDim, TIdx > &&buf) -> ConstBufCpu< TElem, TDim, TIdx >
static ALPAKA_FN_HOST auto makeConstBuf(BufCpu< TElem, TDim, TIdx > const &buf) -> ConstBufCpu< TElem, TDim, TIdx >
The trait to transform a mutable buffer into a constant one.