Public Types | Public Member Functions | Static Public Member Functions | List of all members
cudf::mutable_column_device_view Class Reference

A mutable, non-owning view of device data as a column of elements that is trivially copyable and usable in CUDA device code. More...

Inheritance diagram for cudf::mutable_column_device_view:
cudf::mutable_column_device_view_core cudf::detail::column_device_view_base

Public Types

using base = mutable_column_device_view_core
 Base class.
 
using count_it = thrust::counting_iterator< size_type >
 Counting iterator.
 
template<typename T >
using iterator = thrust::transform_iterator< detail::mutable_value_accessor< T >, count_it >
 Iterator for navigating this column.
 

Public Member Functions

 mutable_column_device_view (mutable_column_device_view const &)=default
 Copy constructor.
 
 mutable_column_device_view (mutable_column_device_view &&)=default
 Move constructor.
 
mutable_column_device_viewoperator= (mutable_column_device_view const &)=default
 Copy assignment operator. More...
 
mutable_column_device_viewoperator= (mutable_column_device_view &&)=default
 Move assignment operator. More...
 
 mutable_column_device_view (mutable_column_view column, void *h_ptr, void *d_ptr)
 Creates an instance of this class using the specified host memory pointer (h_ptr) to store child objects and the device memory pointer (d_ptr) as a base for any child object pointers. More...
 
template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
T & element (size_type element_index) const noexcept
 Returns reference to element at the specified index. More...
 
template<typename T , CUDF_ENABLE_IF(mutable_column_device_view::has_element_accessor< T >()) >
iterator< T > begin ()
 Return first element (accounting for offset) after underlying data is casted to the specified type. More...
 
template<typename T , CUDF_ENABLE_IF(mutable_column_device_view::has_element_accessor< T >()) >
iterator< T > end ()
 Return one past the last element after underlying data is casted to the specified type. More...
 
mutable_column_device_view child (size_type child_index) const noexcept
 Returns the specified child. More...
 
void destroy ()
 Destroy the mutable_column_device_view object. More...
 
- Public Member Functions inherited from cudf::mutable_column_device_view_core
 mutable_column_device_view_core (mutable_column_device_view_core const &)=default
 Copy constructor.
 
 mutable_column_device_view_core (mutable_column_device_view_core &&)=default
 Move constructor.
 
mutable_column_device_view_coreoperator= (mutable_column_device_view_core const &)=default
 Copy assignment operator. More...
 
mutable_column_device_view_coreoperator= (mutable_column_device_view_core &&)=default
 Move assignment operator. More...
 
template<typename T = void, CUDF_ENABLE_IF(cuda::std::is_same_v< T, void > or is_rep_layout_compatible< T >()) >
CUDF_HOST_DEVICE T * head () const noexcept
 Returns pointer to the base device memory allocation casted to the specified type. More...
 
template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
CUDF_HOST_DEVICE T * data () const noexcept
 Returns the underlying data casted to the specified type, plus the offset. More...
 
template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
T & element (size_type element_index) const noexcept
 Returns reference to element at the specified index. More...
 
template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
void assign (size_type element_index, T value) const noexcept
 Assigns value to the element at element_index More...
 
template<typename T , CUDF_ENABLE_IF(is_fixed_point< T >()) >
void assign (size_type element_index, T value) const noexcept
 Assigns value to the element at element_index. More...
 
CUDF_HOST_DEVICE bitmask_typenull_mask () const noexcept
 Returns raw pointer to the underlying bitmask allocation. More...
 
mutable_column_device_view_core child (size_type child_index) const noexcept
 Returns the specified child. More...
 
void set_mask_word (size_type word_index, bitmask_type new_word) const noexcept
 Updates the specified bitmask word in the null_mask() with a new word. More...
 
- Public Member Functions inherited from cudf::detail::column_device_view_base
 column_device_view_base (column_device_view_base const &)=default
 Copy constructor.
 
 column_device_view_base (column_device_view_base &&)=default
 Move constructor.
 
column_device_view_baseoperator= (column_device_view_base const &)=default
 Copy assignment operator. More...
 
column_device_view_baseoperator= (column_device_view_base &&)=default
 Move assignment operator. More...
 
template<typename T = void, CUDF_ENABLE_IF(cuda::std::is_same_v< T, void > or is_rep_layout_compatible< T >()) >
CUDF_HOST_DEVICE T const * head () const noexcept
 Returns pointer to the base device memory allocation casted to the specified type. More...
 
template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
CUDF_HOST_DEVICE T const * data () const noexcept
 Returns the underlying data casted to the specified type, plus the offset. More...
 
CUDF_HOST_DEVICE size_type size () const noexcept
 Returns the number of elements in the column. More...
 
CUDF_HOST_DEVICE data_type type () const noexcept
 Returns the element type. More...
 
CUDF_HOST_DEVICE bool nullable () const noexcept
 Indicates whether the column can contain null elements, i.e., if it has an allocated bitmask. More...
 
CUDF_HOST_DEVICE bitmask_type const * null_mask () const noexcept
 Returns raw pointer to the underlying bitmask allocation. More...
 
CUDF_HOST_DEVICE size_type offset () const noexcept
 Returns the index of the first element relative to the base memory allocation, i.e., what is returned from head<T>(). More...
 
bool is_valid (size_type element_index) const noexcept
 Returns whether the specified element holds a valid value (i.e., not null). More...
 
bool is_valid_nocheck (size_type element_index) const noexcept
 Returns whether the specified element holds a valid value (i.e., not null) More...
 
bool is_null (size_type element_index) const noexcept
 Returns whether the specified element is null. More...
 
bool is_null_nocheck (size_type element_index) const noexcept
 Returns whether the specified element is null. More...
 
bitmask_type get_mask_word (size_type word_index) const noexcept
 Returns the specified bitmask word from the null_mask(). More...
 

Static Public Member Functions

static std::unique_ptr< mutable_column_device_view, std::function< void(mutable_column_device_view *)> > create (mutable_column_view source_view, rmm::cuda_stream_view stream=cudf::get_default_stream())
 Factory to construct a column view that is usable in device memory. More...
 
template<typename T >
static constexpr CUDF_HOST_DEVICE bool has_element_accessor ()
 For a given T, indicates if mutable_column_device_view::element<T>() has a valid overload. More...
 
static std::size_t extent (mutable_column_view source_view)
 Return the size in bytes of the amount of memory needed to hold a device view of the specified column and its children. More...
 

Additional Inherited Members

- Static Public Attributes inherited from cudf::detail::column_device_view_base
static constexpr size_type offsets_column_index {0}
 Child index of the offsets column.
 
- Protected Member Functions inherited from cudf::mutable_column_device_view_core
CUDF_HOST_DEVICE mutable_column_device_view_core (data_type type, size_type size, void const *data, bitmask_type const *null_mask, size_type offset, mutable_column_device_view_core *children, size_type num_children)
 Creates an instance of this class using pre-existing device memory pointers to data, nullmask, and offset. More...
 
- Protected Member Functions inherited from cudf::detail::column_device_view_base
CUDF_HOST_DEVICE column_device_view_base (data_type type, size_type size, void const *data, bitmask_type const *null_mask, size_type offset)
 Constructs a column with the specified type, size, data, nullmask and offset. More...
 
- Protected Attributes inherited from cudf::mutable_column_device_view_core
mutable_column_device_view_cored_children {}
 
size_type _num_children {}
 The number of child columns.
 
- Protected Attributes inherited from cudf::detail::column_device_view_base
data_type _type {type_id::EMPTY}
 Element type.
 
cudf::size_type _size {}
 Number of elements.
 
void const * _data {}
 Pointer to device memory containing elements.
 
bitmask_type const * _null_mask {}
 
size_type _offset {}
 

Detailed Description

A mutable, non-owning view of device data as a column of elements that is trivially copyable and usable in CUDA device code.

Definition at line 608 of file column_device_view.cuh.

Constructor & Destructor Documentation

◆ mutable_column_device_view()

cudf::mutable_column_device_view::mutable_column_device_view ( mutable_column_view  column,
void *  h_ptr,
void *  d_ptr 
)

Creates an instance of this class using the specified host memory pointer (h_ptr) to store child objects and the device memory pointer (d_ptr) as a base for any child object pointers.

Parameters
columnColumn view from which to create this instance.
h_ptrHost memory pointer on which to place any child data.
d_ptrDevice memory pointer on which to base any child pointers.

Member Function Documentation

◆ begin()

template<typename T , CUDF_ENABLE_IF(mutable_column_device_view::has_element_accessor< T >()) >
iterator<T> cudf::mutable_column_device_view::begin ( )
inline

Return first element (accounting for offset) after underlying data is casted to the specified type.

This function does not participate in overload resolution if mutable_column_device_view::has_element_accessor<T>() is false.

Template Parameters
TThe desired type
Returns
Pointer to the first element after casting

Definition at line 717 of file column_device_view.cuh.

◆ child()

mutable_column_device_view cudf::mutable_column_device_view::child ( size_type  child_index) const
inlinenoexcept

Returns the specified child.

Parameters
child_indexThe index of the desired child
Returns
The requested child column_view

Definition at line 744 of file column_device_view.cuh.

◆ create()

static std::unique_ptr<mutable_column_device_view, std::function<void(mutable_column_device_view*)> > cudf::mutable_column_device_view::create ( mutable_column_view  source_view,
rmm::cuda_stream_view  stream = cudf::get_default_stream() 
)
static

Factory to construct a column view that is usable in device memory.

Allocates and copies views of source_view's children to device memory to make them accessible in device code.

If source_view.num_children() == 0, then no device memory is allocated.

Returns a std::unique_ptr<mutable_column_device_view> with a custom deleter to free the device memory allocated for the children.

A mutable_column_device_view should be passed by value into GPU kernels.

Parameters
source_viewThe column_view to make usable in device code
streamCUDA stream used for device memory operations for children columns.
Returns
A unique_ptr to a mutable_column_device_view that makes the data from source_view available in device memory.

◆ destroy()

void cudf::mutable_column_device_view::destroy ( )

Destroy the mutable_column_device_view object.

Note
Does not free the column data, simply frees the device memory allocated to hold the child views.

◆ element()

template<typename T , CUDF_ENABLE_IF(is_rep_layout_compatible< T >()) >
T& cudf::mutable_column_device_view::element ( size_type  element_index) const
inlinenoexcept

Returns reference to element at the specified index.

If the element at the specified index is NULL, i.e., is_null(element_index) == true, then any attempt to use the result will lead to undefined behavior.

This function accounts for the offset.

This function does not participate in overload resolution if is_rep_layout_compatible<T> is false. Specializations of this function may exist for types T where is_rep_layout_compatible<T> is false.

Template Parameters
TThe element type
Parameters
element_indexPosition of the desired element
Returns
Reference to the element at the specified index

Definition at line 681 of file column_device_view.cuh.

◆ end()

template<typename T , CUDF_ENABLE_IF(mutable_column_device_view::has_element_accessor< T >()) >
iterator<T> cudf::mutable_column_device_view::end ( )
inline

Return one past the last element after underlying data is casted to the specified type.

This function does not participate in overload resolution if mutable_column_device_view::has_element_accessor<T>() is false.

Template Parameters
TThe desired type
Returns
Pointer to one past the last element after casting

Definition at line 733 of file column_device_view.cuh.

◆ extent()

static std::size_t cudf::mutable_column_device_view::extent ( mutable_column_view  source_view)
static

Return the size in bytes of the amount of memory needed to hold a device view of the specified column and its children.

Parameters
source_viewThe column_view to use for this calculation.
Returns
The size in bytes of the amount of memory needed to hold a device view of the specified column and its children

◆ has_element_accessor()

template<typename T >
static constexpr CUDF_HOST_DEVICE bool cudf::mutable_column_device_view::has_element_accessor ( )
inlinestaticconstexpr

For a given T, indicates if mutable_column_device_view::element<T>() has a valid overload.

Returns
true if mutable_column_device_view::element<T>() has a valid overload, false

Definition at line 693 of file column_device_view.cuh.

◆ operator=() [1/2]

mutable_column_device_view& cudf::mutable_column_device_view::operator= ( mutable_column_device_view &&  )
default

Move assignment operator.

Returns
Reference to this object (after transferring ownership)

◆ operator=() [2/2]

mutable_column_device_view& cudf::mutable_column_device_view::operator= ( mutable_column_device_view const &  )
default

Copy assignment operator.

Returns
Reference to this object

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