xpu
xpu::h_view< T > Class Template Reference

Create a view from a buffer. Create a view from a buffer to access the underlying data on the host. The view is a lightweight wrapper around the buffer and does not own the data. If the underlying buffer can't be accessed on the host, an runtime_error is thrown. Note that no synchronization with the device is performed, so the data may be out of date. More...

Public Types

using value_type = T
 

Public Member Functions

 h_view ()
 Create an empty view. More...
 
 h_view (buffer< T > &)
 Create a view from a buffer. More...
 
T * data ()
 
const T * data () const
 
size_t size () const
 
size_t size_bytes () const
 
bool empty () const
 
T * begin ()
 
const T * begin () const
 
T * end ()
 
const T * end () const
 
T & front ()
 
const T & front () const
 
T & back ()
 
const T & back () const
 
T & operator[] (size_t i)
 
const T & operator[] (size_t i) const
 
T & at (size_t i)
 
const T & at (size_t i) const
 
T & unsafe_at (size_t i)
 
const T & unsafe_at (size_t i) const
 
 h_view (T *data, size_t size)
 

Detailed Description

template<typename T>
class xpu::h_view< T >

Create a view from a buffer. Create a view from a buffer to access the underlying data on the host. The view is a lightweight wrapper around the buffer and does not own the data. If the underlying buffer can't be accessed on the host, an runtime_error is thrown. Note that no synchronization with the device is performed, so the data may be out of date.

Member Typedef Documentation

◆ value_type

template<typename T >
using xpu::h_view< T >::value_type = T

Constructor & Destructor Documentation

◆ h_view() [1/3]

template<typename T >
xpu::h_view< T >::h_view ( )
inline

Create an empty view.

◆ h_view() [2/3]

template<typename T >
xpu::h_view< T >::h_view ( buffer< T > &  )
explicit

Create a view from a buffer.

◆ h_view() [3/3]

template<typename T >
xpu::h_view< T >::h_view ( T *  data,
size_t  size 
)
inline

Member Function Documentation

◆ at() [1/2]

template<typename T >
T& xpu::h_view< T >::at ( size_t  i)
Returns
Reference to the element at index i.
Note
This call is always bounds checked. Use unsafe_at() instead if no bounds checking is needed. Equivalent to []-operator.

◆ at() [2/2]

template<typename T >
const T& xpu::h_view< T >::at ( size_t  i) const

◆ back() [1/2]

template<typename T >
T& xpu::h_view< T >::back ( )
inline

◆ back() [2/2]

template<typename T >
const T& xpu::h_view< T >::back ( ) const
inline

◆ begin() [1/2]

template<typename T >
T* xpu::h_view< T >::begin ( )
inline

◆ begin() [2/2]

template<typename T >
const T* xpu::h_view< T >::begin ( ) const
inline

◆ data() [1/2]

template<typename T >
T* xpu::h_view< T >::data ( )
inline
Returns
Pointer to the underlying data.

◆ data() [2/2]

template<typename T >
const T* xpu::h_view< T >::data ( ) const
inline

◆ empty()

template<typename T >
bool xpu::h_view< T >::empty ( ) const
inline

Check if the view is empty.

◆ end() [1/2]

template<typename T >
T* xpu::h_view< T >::end ( )
inline

◆ end() [2/2]

template<typename T >
const T* xpu::h_view< T >::end ( ) const
inline

◆ front() [1/2]

template<typename T >
T& xpu::h_view< T >::front ( )
inline

◆ front() [2/2]

template<typename T >
const T& xpu::h_view< T >::front ( ) const
inline

◆ operator[]() [1/2]

template<typename T >
T& xpu::h_view< T >::operator[] ( size_t  i)
Returns
Reference to the element at index i.
Note
This call is always bounds checked. Use instead unsafe_at() if no bounds check are needed. Equivalent to calling at(i).

◆ operator[]() [2/2]

template<typename T >
const T& xpu::h_view< T >::operator[] ( size_t  i) const

◆ size()

template<typename T >
size_t xpu::h_view< T >::size ( ) const
inline
Returns
Size of the view in number of elements.

◆ size_bytes()

template<typename T >
size_t xpu::h_view< T >::size_bytes ( ) const
inline
Returns
Size of the view in bytes.

◆ unsafe_at() [1/2]

template<typename T >
T& xpu::h_view< T >::unsafe_at ( size_t  i)
inline
Returns
Reference to the element at index i.
Note
No bounds checking is performed. Usually you will want to use at() instead.

◆ unsafe_at() [2/2]

template<typename T >
const T& xpu::h_view< T >::unsafe_at ( size_t  i) const
inline

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