null_mask.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #pragma once
6 
7 #include <cudf/types.hpp>
9 #include <cudf/utilities/export.hpp>
11 #include <cudf/utilities/span.hpp>
12 
13 #include <rmm/device_buffer.hpp>
14 
15 #include <cuda/stream>
16 
17 #include <span>
18 #include <vector>
19 
25 namespace CUDF_EXPORT cudf {
26 
43 
56 std::size_t bitmask_allocation_size_bytes(size_type number_of_bits,
57  std::size_t padding_boundary = 64);
58 
73 
86  size_type size,
87  mask_state state,
88  cuda::stream_ref stream = cudf::get_default_stream(),
90 
105  size_type begin_bit,
106  size_type end_bit,
107  bool valid,
108  cuda::stream_ref stream = cudf::get_default_stream());
109 
129  cuda::stream_ref stream = cudf::get_default_stream());
130 
150  cuda::stream_ref stream = cudf::get_default_stream());
151 
170  bitmask_type const* mask,
171  size_type begin_bit,
172  size_type end_bit,
173  cuda::stream_ref stream = cudf::get_default_stream(),
175 
189  column_view const& view,
190  cuda::stream_ref stream = cudf::get_default_stream(),
192 
205 std::pair<rmm::device_buffer, size_type> bitmask_and(
206  table_view const& view,
207  cuda::stream_ref stream = cudf::get_default_stream(),
209 
222 std::pair<rmm::device_buffer, size_type> bitmask_and(
224  host_span<size_type const> begin_bits,
225  size_type mask_size,
226  cuda::stream_ref stream = cudf::get_default_stream(),
228 
253 std::pair<std::vector<std::unique_ptr<rmm::device_buffer>>, std::vector<size_type>>
255  host_span<size_type const> segment_offsets,
256  cuda::stream_ref stream = cudf::get_default_stream(),
258 
283 std::pair<std::vector<std::unique_ptr<rmm::device_buffer>>, std::vector<size_type>>
285  host_span<size_type const> segment_offsets,
286  size_type mask_size_bits,
287  cuda::stream_ref stream = cudf::get_default_stream(),
289 
302 std::pair<rmm::device_buffer, size_type> bitmask_or(
303  table_view const& view,
304  cuda::stream_ref stream = cudf::get_default_stream(),
306 
324  size_type start,
325  size_type stop,
326  cuda::stream_ref stream = cudf::get_default_stream());
327 
346  size_type start,
347  size_type stop,
348  cuda::stream_ref stream = cudf::get_default_stream());
349 
367 std::vector<size_type> segmented_valid_count(bitmask_type const* bitmask,
368  std::span<size_type const> indices,
369  cuda::stream_ref stream = cudf::get_default_stream());
370 
387 std::vector<size_type> segmented_null_count(bitmask_type const* bitmask,
388  std::span<size_type const> indices,
389  cuda::stream_ref stream = cudf::get_default_stream());
390 
403  size_type start,
404  size_type stop,
405  cuda::stream_ref stream = cudf::get_default_stream());
406  // end of group
408 } // namespace CUDF_EXPORT cudf
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
A set of cudf::column_view's of the same size.
Definition: table_view.hpp:206
APIs for querying the default CUDA stream and per-thread default stream status.
size_type null_count(bitmask_type const *bitmask, size_type start, size_type stop, cuda::stream_ref stream=cudf::get_default_stream())
Given a validity bitmask, counts the number of null elements (unset bits) in the range [start,...
rmm::device_buffer create_null_mask(size_type size, mask_state state, cuda::stream_ref stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Creates a device_buffer for use as a null value indicator bitmask of a column
std::pair< rmm::device_buffer, size_type > bitmask_and(host_span< bitmask_type const *const > masks, host_span< size_type const > begin_bits, size_type mask_size, cuda::stream_ref stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Performs bitwise AND of the bitmasks provided.
size_type index_of_first_set_bit(bitmask_type const *bitmask, size_type start, size_type stop, cuda::stream_ref stream=cudf::get_default_stream())
Given a validity bitmask, returns the index of the first set bit in the range [start,...
std::size_t bitmask_allocation_size_bytes(size_type number_of_bits, std::size_t padding_boundary=64)
Computes the required bytes necessary to represent the specified number of bits with a given padding ...
size_type state_null_count(mask_state state, size_type size)
Returns the null count for a null mask of the specified state representing size elements.
std::vector< size_type > batch_null_count(host_span< bitmask_type const *const > bitmasks, size_type start, size_type stop, cuda::stream_ref stream=cudf::get_default_stream())
Given a list of validity bitmasks, counts the number of null elements (unset bits) in the range [star...
std::pair< rmm::device_buffer, size_type > bitmask_or(table_view const &view, cuda::stream_ref stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Performs bitwise OR of the bitmasks of columns of a table. Returns a pair of resulting mask and count...
void set_null_masks_safe(cudf::host_span< bitmask_type * > bitmasks, cudf::host_span< size_type const > begin_bits, cudf::host_span< size_type const > end_bits, cudf::host_span< bool const > valids, cuda::stream_ref stream=cudf::get_default_stream())
Sets a vector of non-overlapping pre-allocated bitmask buffers to given states in the corresponding r...
void set_null_mask(bitmask_type *bitmask, size_type begin_bit, size_type end_bit, bool valid, cuda::stream_ref stream=cudf::get_default_stream())
Sets a pre-allocated bitmask buffer to a given state in the range [begin_bit, end_bit)
std::vector< size_type > segmented_valid_count(bitmask_type const *bitmask, std::span< size_type const > indices, cuda::stream_ref stream=cudf::get_default_stream())
Given a validity bitmask, counts the number of valid elements (set bits) in every range [indices[2*i]...
void set_null_masks_unsafe(cudf::host_span< bitmask_type * > bitmasks, cudf::host_span< size_type const > begin_bits, cudf::host_span< size_type const > end_bits, cudf::host_span< bool const > valids, cuda::stream_ref stream=cudf::get_default_stream())
Sets a vector of non-overlapping pre-allocated bitmask buffers to given states in the corresponding n...
std::vector< size_type > segmented_null_count(bitmask_type const *bitmask, std::span< size_type const > indices, cuda::stream_ref stream=cudf::get_default_stream())
Given a validity bitmask, counts the number of null elements (unset bits) in every range [indices[2*i...
size_type num_bitmask_words(size_type number_of_bits)
Returns the number of bitmask_type words required to represent the specified number of bits.
std::pair< std::vector< std::unique_ptr< rmm::device_buffer > >, std::vector< size_type > > segmented_bitmask_and(host_span< bitmask_type const *const > masks, host_span< size_type const > segment_offsets, size_type mask_size_bits, cuda::stream_ref stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Performs segmented bitwise AND operations on the null masks on defined segments.
rmm::device_buffer copy_bitmask(column_view const &view, cuda::stream_ref stream=cudf::get_default_stream(), rmm::device_async_resource_ref mr=cudf::get_current_device_resource_ref())
Copies view's bitmask from the bits [view.offset(), view.offset() + view.size()) into a device_buffer
cuda::stream_ref const get_default_stream()
Get the current default stream.
rmm::device_async_resource_ref get_current_device_resource_ref()
Get the current device memory resource reference.
cuda::mr::resource_ref< cuda::mr::device_accessible > device_async_resource_ref
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:76
uint32_t bitmask_type
Bitmask type stored as 32-bit unsigned integer.
Definition: types.hpp:77
mask_state
Controls the allocation/initialization of a null mask.
Definition: types.hpp:162
APIs for getting and setting the current device memory resource.
cuDF interfaces
Definition: host_udf.hpp:27
APIs for spans.
Host span, a non-owning view over a contiguous sequence of host-accessible elements.
Definition: span.hpp:65
Type declarations for libcudf.