16 #include <cuda/memory_resource>
22 #include <rapidsmpf/error.hpp>
23 #include <rapidsmpf/memory/host_memory_resource.hpp>
49 cuda::mr::any_resource<cuda::mr::host_accessible> mr
94 [[nodiscard]]
rmm::cuda_stream_view
stream() const noexcept;
101 [[nodiscard]] std::
size_t size() const noexcept;
108 [[nodiscard]]
bool empty() const noexcept;
115 [[nodiscard]] std::
byte*
data() noexcept;
122 [[nodiscard]] std::
byte const*
data() const noexcept;
160 std::vector<std::uint8_t> const&
data,
178 std::vector<std::uint8_t>&&
data,
rmm::cuda_stream_view
stream
205 std::unique_ptr<
rmm::device_buffer> pinned_host_buffer,
220 std::span<std::
byte> span,
222 std::function<
void(
rmm::cuda_stream_view)> deallocate_fn
225 rmm::cuda_stream_view stream_;
226 std::span<std::
byte> span_{};
rmm::cuda_stream_view stream() const noexcept
Get the CUDA stream associated with this buffer.
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.
static HostBuffer from_owned_vector(std::vector< std::uint8_t > &&data, rmm::cuda_stream_view stream)
Construct a HostBuffer by taking ownership of a std::vector<std::uint8_t>.
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.
HostBuffer(std::size_t size, rmm::cuda_stream_view stream, cuda::mr::any_resource< cuda::mr::host_accessible > mr)
Allocate a new host buffer.
bool empty() const noexcept
Check whether the buffer is empty.
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>.
static HostBuffer from_rmm_device_buffer(std::unique_ptr< rmm::device_buffer > pinned_host_buffer, rmm::cuda_stream_view stream)
Construct a HostBuffer by taking ownership of an rmm::device_buffer.
void set_stream(rmm::cuda_stream_view stream)
Set the associated CUDA stream.
cuda::mr::resource_ref< cuda::mr::host_accessible > host_async_resource_ref
RAPIDS Multi-Processor interfaces.