13 template<
typename TElem,
typename TDim,
typename TIdx>
20 template<
typename TElem,
typename TDim,
typename TIdx>
27 template<
typename TElem,
typename TDim,
typename TIdx>
32 return buf.m_spBufImpl->m_dev;
37 template<
typename TElem,
typename TDim,
typename TIdx>
44 template<
typename TElem,
typename TDim,
typename TIdx>
51 template<
typename TElem,
typename TDim,
typename TIdx>
61 template<
typename TElem,
typename TDim,
typename TIdx>
66 return buf.m_spBufImpl->m_pMem;
71 return buf.m_spBufImpl->m_pMem;
76 template<
typename TElem,
typename TDim,
typename TIdx>
83 return buf.m_spBufImpl->m_pMem;
87 throw std::runtime_error(
"The buffer is not accessible from the given device!");
95 return buf.m_spBufImpl->m_pMem;
99 throw std::runtime_error(
"The buffer is not accessible from the given device!");
105 template<
typename TElem,
typename TDim,
typename TIdx>
115 template<
typename TElem,
typename TDim,
typename TIdx>
122 template<
typename TElem,
typename TDim,
typename TIdx>
137 template<
typename TElem,
typename TDim,
typename TIdx>
140 template<
typename TExtent>
148#if defined(ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT)
150 ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT > 0
151 && ((ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT & (ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT - 1)) == 0),
152 "If defined, ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT must be a power of 2.");
153 constexpr std::size_t alignment =
static_cast<std::size_t
>(ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT);
159 static_assert(std::is_empty_v<Allocator>,
"AllocCpuAligned is expected to be stateless");
160 auto* memPtr = alpaka::malloc<TElem>(Allocator{},
static_cast<std::size_t
>(
getExtentProduct(extent)));
161 auto deleter = [](TElem* ptr) {
alpaka::free(Allocator{}, ptr); };
168 template<
typename TDim>
174 template<
typename TElem,
typename TDim,
typename TIdx>
177 template<
typename TQueue,
typename TExtent>
183 std::is_same_v<Dev<TQueue>,
DevCpu>,
184 "The BufCpu buffer can only be used with a queue on a DevCpu device!");
190#if defined(ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT)
192 ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT > 0
193 && ((ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT & (ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT - 1)) == 0),
194 "If defined, ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT must be a power of 2.");
195 constexpr std::size_t alignment =
static_cast<std::size_t
>(ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT);
201 static_assert(std::is_empty_v<Allocator>,
"AllocCpuAligned is expected to be stateless");
202 auto* memPtr = alpaka::malloc<TElem>(Allocator{},
static_cast<std::size_t
>(
getExtentProduct(extent)));
203 auto deleter = [l_queue = std::move(queue)](TElem* ptr)
mutable
225 template<
typename TElem,
typename TDim,
typename TIdx>
228 template<
typename TExtent>
235 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.