Public Types | Public Member Functions | Friends | List of all members
raft_proto::buffer< T > Struct Template Reference

A container which may or may not own its own data on host or device. More...

#include <buffer.hpp>

Collaboration diagram for raft_proto::buffer< T >:
Collaboration graph

Public Types

using index_type = std::size_t
 
using value_type = T
 
using data_store = std::variant< non_owning_buffer< device_type::cpu, T >, non_owning_buffer< device_type::gpu, T >, owning_buffer< device_type::cpu, T >, owning_buffer< device_type::gpu, T > >
 

Public Member Functions

 buffer ()
 
 buffer (index_type size, device_type mem_type=device_type::cpu, int device=0, cuda_stream stream=0)
 
 buffer (T *input_data, index_type size, device_type mem_type=device_type::cpu, int device=0)
 
 buffer (buffer< T > const &other, device_type mem_type, int device=0, cuda_stream stream=cuda_stream{})
 Construct one buffer from another in the given memory location (either on host or on device) A buffer constructed in this way is owning and will copy the data from the original location. More...
 
 buffer (buffer< T > const &other, cuda_stream stream=cuda_stream{})
 Create owning copy of existing buffer with given stream The memory type of this new buffer will be the same as the original. More...
 
buffer< T > & operator= (buffer< T > const &other)
 
 buffer (buffer< T > &&other, device_type mem_type, int device, cuda_stream stream)
 Move from existing buffer unless a copy is necessary based on memory location. More...
 
 buffer (buffer< T > &&other, device_type mem_type, int device)
 
 buffer (buffer< T > &&other, device_type mem_type)
 
 buffer (buffer< T > &&other) noexcept
 
buffer< T > & operator= (buffer< T > &&other) noexcept
 
template<typename iter_t , typename = decltype(*std::declval<iter_t&>(), void(), ++std::declval<iter_t&>(), void())>
 buffer (iter_t const &begin, iter_t const &end)
 
template<typename iter_t , typename = decltype(*std::declval<iter_t&>(), void(), ++std::declval<iter_t&>(), void())>
 buffer (iter_t const &begin, iter_t const &end, device_type mem_type)
 
template<typename iter_t , typename = decltype(*std::declval<iter_t&>(), void(), ++std::declval<iter_t&>(), void())>
 buffer (iter_t const &begin, iter_t const &end, device_type mem_type, int device, cuda_stream stream=cuda_stream{})
 
auto size () const noexcept
 
HOST DEVICE auto * data () const noexcept
 
auto memory_type () const noexcept
 
auto device () const noexcept
 
auto device_index () const noexcept
 
 ~buffer ()=default
 

Friends

void swap (buffer< T > &first, buffer< T > &second)
 Create owning copy of existing buffer The memory type of this new buffer will be the same as the original. More...
 

Detailed Description

template<typename T>
struct raft_proto::buffer< T >

A container which may or may not own its own data on host or device.

Member Typedef Documentation

◆ data_store

◆ index_type

template<typename T >
using raft_proto::buffer< T >::index_type = std::size_t

◆ value_type

template<typename T >
using raft_proto::buffer< T >::value_type = T

Constructor & Destructor Documentation

◆ buffer() [1/12]

template<typename T >
raft_proto::buffer< T >::buffer ( )
inline

◆ buffer() [2/12]

template<typename T >
raft_proto::buffer< T >::buffer ( index_type  size,
device_type  mem_type = device_type::cpu,
int  device = 0,
cuda_stream  stream = 0 
)
inline

Construct non-initialized owning buffer

◆ buffer() [3/12]

template<typename T >
raft_proto::buffer< T >::buffer ( T *  input_data,
index_type  size,
device_type  mem_type = device_type::cpu,
int  device = 0 
)
inline

Construct non-owning buffer

◆ buffer() [4/12]

template<typename T >
raft_proto::buffer< T >::buffer ( buffer< T > const &  other,
device_type  mem_type,
int  device = 0,
cuda_stream  stream = cuda_stream{} 
)
inline

Construct one buffer from another in the given memory location (either on host or on device) A buffer constructed in this way is owning and will copy the data from the original location.

◆ buffer() [5/12]

template<typename T >
raft_proto::buffer< T >::buffer ( buffer< T > const &  other,
cuda_stream  stream = cuda_stream{} 
)
inline

Create owning copy of existing buffer with given stream The memory type of this new buffer will be the same as the original.

◆ buffer() [6/12]

template<typename T >
raft_proto::buffer< T >::buffer ( buffer< T > &&  other,
device_type  mem_type,
int  device,
cuda_stream  stream 
)
inline

Move from existing buffer unless a copy is necessary based on memory location.

◆ buffer() [7/12]

template<typename T >
raft_proto::buffer< T >::buffer ( buffer< T > &&  other,
device_type  mem_type,
int  device 
)
inline

◆ buffer() [8/12]

template<typename T >
raft_proto::buffer< T >::buffer ( buffer< T > &&  other,
device_type  mem_type 
)
inline

◆ buffer() [9/12]

template<typename T >
raft_proto::buffer< T >::buffer ( buffer< T > &&  other)
inlinenoexcept

◆ buffer() [10/12]

template<typename T >
template<typename iter_t , typename = decltype(*std::declval<iter_t&>(), void(), ++std::declval<iter_t&>(), void())>
raft_proto::buffer< T >::buffer ( iter_t const &  begin,
iter_t const &  end 
)
inline

◆ buffer() [11/12]

template<typename T >
template<typename iter_t , typename = decltype(*std::declval<iter_t&>(), void(), ++std::declval<iter_t&>(), void())>
raft_proto::buffer< T >::buffer ( iter_t const &  begin,
iter_t const &  end,
device_type  mem_type 
)
inline

◆ buffer() [12/12]

template<typename T >
template<typename iter_t , typename = decltype(*std::declval<iter_t&>(), void(), ++std::declval<iter_t&>(), void())>
raft_proto::buffer< T >::buffer ( iter_t const &  begin,
iter_t const &  end,
device_type  mem_type,
int  device,
cuda_stream  stream = cuda_stream{} 
)
inline

◆ ~buffer()

template<typename T >
raft_proto::buffer< T >::~buffer ( )
default

Member Function Documentation

◆ data()

template<typename T >
HOST DEVICE auto* raft_proto::buffer< T >::data ( ) const
inlinenoexcept

◆ device()

template<typename T >
auto raft_proto::buffer< T >::device ( ) const
inlinenoexcept

◆ device_index()

template<typename T >
auto raft_proto::buffer< T >::device_index ( ) const
inlinenoexcept

◆ memory_type()

template<typename T >
auto raft_proto::buffer< T >::memory_type ( ) const
inlinenoexcept

◆ operator=() [1/2]

template<typename T >
buffer<T>& raft_proto::buffer< T >::operator= ( buffer< T > &&  other)
inlinenoexcept

◆ operator=() [2/2]

template<typename T >
buffer<T>& raft_proto::buffer< T >::operator= ( buffer< T > const &  other)
inline

◆ size()

template<typename T >
auto raft_proto::buffer< T >::size ( ) const
inlinenoexcept

Friends And Related Function Documentation

◆ swap

template<typename T >
void swap ( buffer< T > &  first,
buffer< T > &  second 
)
friend

Create owning copy of existing buffer The memory type of this new buffer will be the same as the original.


The documentation for this struct was generated from the following file: