alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
ConstBufUniformCudaHipRt.hpp
Go to the documentation of this file.
1/* Copyright 2025 Alexander Matthes, Benjamin Worpitz, Matthias Werner, René Widera, Andrea Bocci, Jan Stephan,
2 * Bernhard Manfred Gruber, Antonio Di Pilato, Anton Reinhard
3 * SPDX-License-Identifier: MPL-2.0
4 */
5
6#pragma once
7
10#include "alpaka/core/Hip.hpp"
12#include "alpaka/dev/Traits.hpp"
18#include "alpaka/vec/Vec.hpp"
19
20#include <cstddef>
21#include <functional>
22#include <memory>
23#include <type_traits>
24
25#if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) || defined(ALPAKA_ACC_GPU_HIP_ENABLED)
26
27namespace alpaka
28{
29 // Forward declarations.
30 struct ApiCudaRt;
31 struct ApiHipRt;
32 template<typename TApi, typename TElem, typename TDim, typename TIdx>
33 class BufUniformCudaHipRt;
34
35 //! The CUDA/HIP memory buffer.
36 template<typename TApi, typename TElem, typename TDim, typename TIdx>
37 struct ConstBufUniformCudaHipRt : internal::ViewAccessOps<ConstBufUniformCudaHipRt<TApi, TElem, TDim, TIdx>>
38 {
39 static_assert(!std::is_const_v<TElem>, "The elem type of the buffer must not be const");
40 static_assert(!std::is_const_v<TIdx>, "The idx type of the buffer must not be const!");
41
42 //! Constructor
43 template<typename TExtent, typename Deleter>
46 TElem* const pMem,
47 Deleter deleter,
48 TExtent const& extent,
49 std::size_t pitchBytes)
50 : m_spBufImpl{std::make_shared<detail::BufUniformCudaHipRtImpl<TApi, TElem, TDim, TIdx>>(
51 dev,
52 pMem,
53 std::move(deleter),
54 extent,
55 pitchBytes)}
56 {
57 }
58
60 : m_spBufImpl{buf.m_spBufImpl}
61 {
62 }
63
65 : m_spBufImpl{std::move(buf.m_spBufImpl)}
66 {
67 }
68
69 private:
70 std::shared_ptr<detail::BufUniformCudaHipRtImpl<TApi, TElem, TDim, TIdx>> m_spBufImpl;
71
77 };
78
79} // namespace alpaka
80
84
85#endif
The generic memory buffer template implementing muting accessors.
The CUDA/HIP RT device handle.
#define ALPAKA_FN_HOST
Definition Common.hpp:40
The alpaka accelerator library.
STL namespace.
ALPAKA_FN_HOST ConstBufUniformCudaHipRt(BufUniformCudaHipRt< TApi, TElem, TDim, TIdx > &&buf)
ALPAKA_FN_HOST ConstBufUniformCudaHipRt(DevUniformCudaHipRt< TApi > const &dev, TElem *const pMem, Deleter deleter, TExtent const &extent, std::size_t pitchBytes)
Constructor.
ALPAKA_FN_HOST ConstBufUniformCudaHipRt(BufUniformCudaHipRt< TApi, TElem, TDim, TIdx > const &buf)
The device get trait.
Definition Traits.hpp:27
The GetExtents trait for getting the extents of an object as an alpaka::Vec.
Definition Traits.hpp:37
Customization point for getPitchesInBytes. The default implementation uses the extent to calculate th...
Definition Traits.hpp:103
The pointer on device get trait.
Definition Traits.hpp:58
The native pointer get trait.
Definition Traits.hpp:54