20 #include <rapidsmpf/error.hpp>
21 #include <rapidsmpf/memory/host_memory_resource.hpp>
22 #include <rapidsmpf/memory/pinned_memory_resource.hpp>
99 [[nodiscard]]
rmm::cuda_stream_view
stream() const noexcept;
106 [[nodiscard]] std::
size_t size() const noexcept;
113 [[nodiscard]]
bool empty() const noexcept;
120 [[nodiscard]] std::
byte*
data() noexcept;
127 [[nodiscard]] std::
byte const*
data() const noexcept;
165 std::vector<std::uint8_t> const&
data,
184 std::vector<std::uint8_t>&&
data,
214 std::unique_ptr<
rmm::device_buffer> pinned_host_buffer,
229 std::span<std::
byte> span,
235 rmm::cuda_stream_view stream_;
237 std::span<std::
byte> span_{};
239 std::unique_ptr<void, OwnedStorageDeleter> owned_storage_{
nullptr, [](
void*) {}};
rmm::cuda_stream_view stream() const noexcept
Get the CUDA stream associated with this buffer.
static HostBuffer from_owned_vector(std::vector< std::uint8_t > &&data, rmm::cuda_stream_view stream, rmm::host_async_resource_ref mr)
Construct a HostBuffer by taking ownership of a std::vector<std::uint8_t>.
std::size_t size() const noexcept
Get the size of the buffer in bytes.
void deallocate_async() noexcept
Stream-ordered deallocates the buffer, if allocated.
std::vector< std::uint8_t > copy_to_uint8_vector() const
Copy the contents of the buffer into a host std::vector.
std::byte * data() noexcept
Get a pointer to the buffer data.
static HostBuffer from_rmm_device_buffer(std::unique_ptr< rmm::device_buffer > pinned_host_buffer, rmm::cuda_stream_view stream, PinnedMemoryResource &mr)
Construct a HostBuffer by taking ownership of an rmm::device_buffer.
bool empty() const noexcept
Check whether the buffer is empty.
std::function< void(void *)> OwnedStorageDeleter
Type-erased deleter for owned storage.
HostBuffer(std::size_t size, rmm::cuda_stream_view stream, rmm::host_async_resource_ref mr)
Allocate a new host buffer.
static HostBuffer from_uint8_vector(std::vector< std::uint8_t > const &data, rmm::cuda_stream_view stream, rmm::host_async_resource_ref mr)
Construct a HostBuffer by copying data from a std::vector<std::uint8_t>.
void set_stream(rmm::cuda_stream_view stream)
Set the associated CUDA stream.
Memory resource that provides pinned (page-locked) host memory using a pool.
detail::cccl_async_resource_ref< cuda::mr::resource_ref< cuda::mr::host_accessible > > host_async_resource_ref
RAPIDS Multi-Processor interfaces.