12#if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) || defined(ALPAKA_ACC_GPU_HIP_ENABLED) 
   17    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
   24    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
   31    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
   37            return buf.m_spBufImpl->m_dev;
 
 
 
   42    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
   49    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
   56    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
   66    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
   72            return buf.m_spBufImpl->m_pMem;
 
 
   77            return buf.m_spBufImpl->m_pMem;
 
 
 
   82    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
   91                return buf.m_spBufImpl->m_pMem;
 
   95                throw std::runtime_error(
"The buffer is not accessible from the given device!");
 
 
  105                return buf.m_spBufImpl->m_pMem;
 
  109                throw std::runtime_error(
"The buffer is not accessible from the given device!");
 
 
 
  114    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
  126    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
  137    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
  144    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
  151            TElem* pDev(
nullptr);
 
  155                const_cast<void*
>(
reinterpret_cast<void const*
>(
getPtrNative(buf))),
 
 
  165            TElem* pDev(
nullptr);
 
 
 
  174    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
  191    template<
typename TApi, 
typename TElem, 
typename Dim, 
typename TIdx>
 
  194        template<
typename TExtent>
 
  202            void* memPtr = 
nullptr;
 
  203            std::size_t rowPitchInBytes = 0u;
 
  206                if constexpr(Dim::value == 0)
 
  210                else if constexpr(Dim::value == 1)
 
  213                        TApi::malloc(&memPtr, 
static_cast<std::size_t
>(
getWidth(extent)) * 
sizeof(TElem)));
 
  215                else if constexpr(Dim::value == 2)
 
  220                        static_cast<std::size_t
>(
getWidth(extent)) * 
sizeof(TElem),
 
  221                        static_cast<std::size_t
>(
getHeight(extent))));
 
  223                else if constexpr(Dim::value == 3)
 
  225                    typename TApi::Extent_t 
const extentVal = TApi::makeExtent(
 
  226                        static_cast<std::size_t
>(
getWidth(extent)) * 
sizeof(TElem),
 
  227                        static_cast<std::size_t
>(
getHeight(extent)),
 
  228                        static_cast<std::size_t
>(
getDepth(extent)));
 
  229                    typename TApi::PitchedPtr_t pitchedPtrVal;
 
  230                    pitchedPtrVal.ptr = 
nullptr;
 
  232                    memPtr = pitchedPtrVal.ptr;
 
  233                    rowPitchInBytes = pitchedPtrVal.pitch;
 
  236#    if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL 
  237            std::cout << __func__;
 
  238            if constexpr(Dim::value >= 1)
 
  239                std::cout << 
" ew: " << 
getWidth(extent);
 
  240            if constexpr(Dim::value >= 2)
 
  241                std::cout << 
" eh: " << 
getHeight(extent);
 
  242            if constexpr(Dim::value >= 3)
 
  243                std::cout << 
" ed: " << 
getDepth(extent);
 
  244            std::cout << 
" ptr: " << memPtr;
 
  245            if constexpr(Dim::value >= 2)
 
  246                std::cout << 
" rowpitch: " << rowPitchInBytes;
 
  247            std::cout << std::endl;
 
  251                reinterpret_cast<TElem*
>(memPtr),
 
 
 
  259    template<
typename TApi, 
typename TDim>
 
  265    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
  268        template<
typename TQueue>
 
  274            std::size_t bytes, pitch;
 
  275            if constexpr(TDim::value == 0)
 
  277                bytes = pitch = 
sizeof(TElem);
 
  279            else if constexpr(TDim::value == 1)
 
  281                bytes = pitch = 
static_cast<std::size_t
>(extent.back()) * 
sizeof(TElem);
 
  285                std::size_t 
const width = 
static_cast<std::size_t
>(extent.back()) * 
sizeof(TElem);
 
  293                constexpr std::size_t alignment = 128;
 
  294                pitch = (width + alignment - 1) / alignment * alignment;
 
  298                auto aligned = alpaka::castVec<std::size_t>(extent);
 
  299                aligned.back() = pitch;
 
  300                bytes = aligned.prod() - pitch + width;
 
  303            auto const& dev = 
getDev(queue);
 
  305            void* memPtr = 
nullptr;
 
  308#    if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL 
  309            std::cout << __func__;
 
  310            if constexpr(Dim::value >= 1)
 
  311                std::cout << 
" ew: " << 
getWidth(extent);
 
  312            if constexpr(Dim::value >= 2)
 
  313                std::cout << 
" eh: " << 
getHeight(extent);
 
  314            if constexpr(Dim::value >= 3)
 
  315                std::cout << 
" ed: " << 
getDepth(extent);
 
  316            std::cout << 
" ptr: " << memPtr;
 
  317            if constexpr(Dim::value >= 2)
 
  318                std::cout << 
" rowpitch: " << pitch;
 
  319            std::cout << std::endl;
 
  323                reinterpret_cast<TElem*
>(memPtr),
 
  324                [q = std::move(queue)](TElem* ptr)
 
 
 
  332    template<
typename TApi>
 
  338    template<
typename TApi, 
typename TElem, 
typename TDim, 
typename TIdx>
 
  341        template<
typename TExtent>
 
  351            TElem* memPtr = 
nullptr;
 
  353                reinterpret_cast<void**
>(&memPtr),
 
  355                TApi::hostMallocMapped | TApi::hostMallocPortable));
 
 
 
#define ALPAKA_DEBUG_MINIMAL_LOG_SCOPE
 
The CPU memory buffer template implementing muting accessors.
 
ALPAKA_NO_HOST_ACC_WARNING static ALPAKA_FN_HOST_ACC constexpr auto zeros() -> Vec< TDim, TVal >
Zero value constructor.
 
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto getExtentProduct(T const &object) -> Idx< T >
 
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto getHeight(TExtent const &extent=TExtent()) -> Idx< TExtent >
 
ALPAKA_FN_HOST auto getPtrNative(TView const &view) -> Elem< TView > const *
Gets the native pointer of the memory view.
 
ALPAKA_FN_HOST auto getDev(T const &t)
 
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto getDepth(TExtent const &extent=TExtent()) -> Idx< TExtent >
 
typename trait::DimType< T >::type Dim
The dimension type trait alias template to remove the ::type.
 
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto getWidth(TExtent const &extent=TExtent()) -> Idx< TExtent >
 
The stream-ordered memory allocator trait.
 
The pinned/mapped memory allocator trait.
 
The memory allocator trait.
 
The memory buffer type trait.
 
The dimension getter type trait.
 
ALPAKA_FN_HOST auto operator()(BufUniformCudaHipRt< TApi, TElem, TDim, TIdx > const &buf)
 
The GetExtents trait for getting the extents of an object as an alpaka::Vec.
 
The GetOffsets trait for getting the offsets of an object as an alpaka::Vec.
 
Customization point for getPitchesInBytes. The default implementation uses the extent to calculate th...
 
The pointer on device get trait.
 
The native pointer get trait.
 
The stream-ordered memory allocation capability trait.
 
The pinned/mapped memory allocation capability trait.
 
The trait to transform a mutable buffer into a constant one.