repo_id
stringlengths 21
96
| file_path
stringlengths 31
155
| content
stringlengths 1
92.9M
| __index_level_0__
int64 0
0
|
---|---|---|---|
rapidsai_public_repos/cudf/cpp/cmake/thirdparty
|
rapidsai_public_repos/cudf/cpp/cmake/thirdparty/patches/cub_segmented_sort_with_bool_key.diff
|
diff --git a/dependencies/cub/cub/agent/agent_sub_warp_merge_sort.cuh b/dependencies/cub/cub/agent/agent_sub_warp_merge_sort.cuh
index ad65f2a3..ad45a21e 100644
--- a/dependencies/cub/cub/agent/agent_sub_warp_merge_sort.cuh
+++ b/dependencies/cub/cub/agent/agent_sub_warp_merge_sort.cuh
@@ -221,7 +221,8 @@ public:
using UnsignedBitsT = typename Traits<KeyT>::UnsignedBits;
UnsignedBitsT default_key_bits = IS_DESCENDING ? Traits<KeyT>::LOWEST_KEY
: Traits<KeyT>::MAX_KEY;
- KeyT oob_default = reinterpret_cast<KeyT &>(default_key_bits);
+ KeyT oob_default = std::is_same_v<KeyT, bool> ? !IS_DESCENDING
+ : reinterpret_cast<KeyT &>(default_key_bits);
WarpLoadKeysT(storage.load_keys)
.Load(keys_input, keys, segment_size, oob_default);
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/bitmask/null_mask.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/detail/null_mask.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/cuda.cuh>
#include <cudf/detail/utilities/integer_utils.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/null_mask.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/bit.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf/utilities/span.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_buffer.hpp>
#include <rmm/device_scalar.hpp>
#include <rmm/mr/device/device_memory_resource.hpp>
#include <thrust/binary_search.h>
#include <thrust/copy.h>
#include <thrust/device_ptr.h>
#include <thrust/extrema.h>
#include <cub/cub.cuh>
#include <algorithm>
#include <numeric>
#include <type_traits>
namespace cudf {
size_type state_null_count(mask_state state, size_type size)
{
switch (state) {
case mask_state::UNALLOCATED: return 0;
case mask_state::ALL_NULL: return size;
case mask_state::ALL_VALID: return 0;
default: CUDF_FAIL("Invalid null mask state.", std::invalid_argument);
}
}
// Computes required allocation size of a bitmask
std::size_t bitmask_allocation_size_bytes(size_type number_of_bits, std::size_t padding_boundary)
{
CUDF_EXPECTS(padding_boundary > 0, "Invalid padding boundary");
auto necessary_bytes = cudf::util::div_rounding_up_safe<size_type>(number_of_bits, CHAR_BIT);
auto padded_bytes = padding_boundary * cudf::util::div_rounding_up_safe<size_type>(
necessary_bytes, padding_boundary);
return padded_bytes;
}
// Computes number of *actual* bitmask_type elements needed
size_type num_bitmask_words(size_type number_of_bits)
{
return cudf::util::div_rounding_up_safe<size_type>(number_of_bits,
detail::size_in_bits<bitmask_type>());
}
namespace detail {
// Create a device_buffer for a null mask
rmm::device_buffer create_null_mask(size_type size,
mask_state state,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type mask_size{0};
if (state != mask_state::UNALLOCATED) { mask_size = bitmask_allocation_size_bytes(size); }
rmm::device_buffer mask(mask_size, stream, mr);
if (state != mask_state::UNINITIALIZED) {
uint8_t fill_value = (state == mask_state::ALL_VALID) ? 0xff : 0x00;
CUDF_CUDA_TRY(cudaMemsetAsync(
static_cast<bitmask_type*>(mask.data()), fill_value, mask_size, stream.value()));
}
return mask;
}
namespace {
__global__ void set_null_mask_kernel(bitmask_type* __restrict__ destination,
size_type begin_bit,
size_type end_bit,
bool valid,
size_type number_of_mask_words)
{
auto x = destination + word_index(begin_bit);
thread_index_type const last_word = word_index(end_bit) - word_index(begin_bit);
bitmask_type fill_value = valid ? 0xffff'ffff : 0;
auto const stride = cudf::detail::grid_1d::grid_stride();
for (thread_index_type destination_word_index = grid_1d::global_thread_id();
destination_word_index < number_of_mask_words;
destination_word_index += stride) {
if (destination_word_index == 0 || destination_word_index == last_word) {
bitmask_type mask = ~bitmask_type{0};
if (destination_word_index == 0) {
mask = ~(set_least_significant_bits(intra_word_index(begin_bit)));
}
if (destination_word_index == last_word) {
mask = mask & set_least_significant_bits(intra_word_index(end_bit));
}
x[destination_word_index] =
valid ? x[destination_word_index] | mask : x[destination_word_index] & ~mask;
} else {
x[destination_word_index] = fill_value;
}
}
}
} // namespace
// Set pre-allocated null mask of given bit range [begin_bit, end_bit) to valid, if valid==true,
// or null, otherwise;
void set_null_mask(bitmask_type* bitmask,
size_type begin_bit,
size_type end_bit,
bool valid,
rmm::cuda_stream_view stream)
{
CUDF_FUNC_RANGE();
CUDF_EXPECTS(begin_bit >= 0, "Invalid range.");
CUDF_EXPECTS(begin_bit <= end_bit, "Invalid bit range.");
if (begin_bit == end_bit) return;
if (bitmask != nullptr) {
auto number_of_mask_words =
num_bitmask_words(end_bit) - begin_bit / detail::size_in_bits<bitmask_type>();
cudf::detail::grid_1d config(number_of_mask_words, 256);
set_null_mask_kernel<<<config.num_blocks, config.num_threads_per_block, 0, stream.value()>>>(
static_cast<bitmask_type*>(bitmask), begin_bit, end_bit, valid, number_of_mask_words);
CUDF_CHECK_CUDA(stream.value());
}
}
} // namespace detail
// Create a device_buffer for a null mask
rmm::device_buffer create_null_mask(size_type size,
mask_state state,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return detail::create_null_mask(size, state, stream, mr);
}
// Set pre-allocated null mask of given bit range [begin_bit, end_bit) to valid, if valid==true,
// or null, otherwise;
void set_null_mask(bitmask_type* bitmask,
size_type begin_bit,
size_type end_bit,
bool valid,
rmm::cuda_stream_view stream)
{
return detail::set_null_mask(bitmask, begin_bit, end_bit, valid, stream);
}
namespace detail {
namespace {
/**
* @brief Copies the bits starting at the specified offset from a source
* bitmask into the destination bitmask.
*
* Bit `i` in `destination` will be equal to bit `i + offset` from `source`.
*
* @param destination The mask to copy into
* @param source The mask to copy from
* @param source_begin_bit The offset into `source` from which to begin the copy
* @param source_end_bit The offset into `source` till which copying is done
* @param number_of_mask_words The number of `cudf::bitmask_type` words to copy
*/
// TODO: Also make binops test that uses offset in column_view
__global__ void copy_offset_bitmask(bitmask_type* __restrict__ destination,
bitmask_type const* __restrict__ source,
size_type source_begin_bit,
size_type source_end_bit,
size_type number_of_mask_words)
{
auto const stride = cudf::detail::grid_1d::grid_stride();
for (thread_index_type destination_word_index = grid_1d::global_thread_id();
destination_word_index < number_of_mask_words;
destination_word_index += stride) {
destination[destination_word_index] = detail::get_mask_offset_word(
source, destination_word_index, source_begin_bit, source_end_bit);
}
}
} // namespace
// Create a bitmask from a specific range
rmm::device_buffer copy_bitmask(bitmask_type const* mask,
size_type begin_bit,
size_type end_bit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
CUDF_EXPECTS(begin_bit >= 0, "Invalid range.");
CUDF_EXPECTS(begin_bit <= end_bit, "Invalid bit range.");
rmm::device_buffer dest_mask{};
auto num_bytes = bitmask_allocation_size_bytes(end_bit - begin_bit);
if ((mask == nullptr) || (num_bytes == 0)) { return dest_mask; }
if (begin_bit == 0) {
dest_mask = rmm::device_buffer{static_cast<void const*>(mask), num_bytes, stream, mr};
} else {
auto number_of_mask_words = num_bitmask_words(end_bit - begin_bit);
dest_mask = rmm::device_buffer{num_bytes, stream, mr};
cudf::detail::grid_1d config(number_of_mask_words, 256);
copy_offset_bitmask<<<config.num_blocks, config.num_threads_per_block, 0, stream.value()>>>(
static_cast<bitmask_type*>(dest_mask.data()), mask, begin_bit, end_bit, number_of_mask_words);
CUDF_CHECK_CUDA(stream.value());
}
return dest_mask;
}
// Create a bitmask from a column view
rmm::device_buffer copy_bitmask(column_view const& view,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
rmm::device_buffer null_mask{0, stream, mr};
if (view.nullable()) {
null_mask =
copy_bitmask(view.null_mask(), view.offset(), view.offset() + view.size(), stream, mr);
}
return null_mask;
}
namespace {
/**
* @brief Counts the number of non-zero bits in a bitmask in the range
* `[first_bit_index, last_bit_index]`.
*
* Expects `0 <= first_bit_index <= last_bit_index`.
*
* @param[in] bitmask The bitmask whose non-zero bits will be counted.
* @param[in] first_bit_index The index (inclusive) of the first bit to count
* @param[in] last_bit_index The index (inclusive) of the last bit to count
* @param[out] global_count The number of non-zero bits in the specified range
*/
template <size_type block_size>
__global__ void count_set_bits_kernel(bitmask_type const* bitmask,
size_type first_bit_index,
size_type last_bit_index,
size_type* global_count)
{
constexpr auto const word_size{detail::size_in_bits<bitmask_type>()};
auto const first_word_index{word_index(first_bit_index)};
auto const last_word_index{word_index(last_bit_index)};
thread_index_type const tid = grid_1d::global_thread_id();
thread_index_type const stride = grid_1d::grid_stride();
thread_index_type thread_word_index = tid + first_word_index;
size_type thread_count{0};
// First, just count the bits in all words
while (thread_word_index <= last_word_index) {
thread_count += __popc(bitmask[thread_word_index]);
thread_word_index += stride;
}
// Subtract any slack bits counted from the first and last word
// Two threads handle this -- one for first word, one for last
if (tid < 2) {
bool const first{tid == 0};
bool const last{not first};
size_type bit_index = (first) ? first_bit_index : last_bit_index;
size_type word_index = (first) ? first_word_index : last_word_index;
size_type num_slack_bits = bit_index % word_size;
if (last) { num_slack_bits = word_size - num_slack_bits - 1; }
if (num_slack_bits > 0) {
bitmask_type word = bitmask[word_index];
auto slack_mask = (first) ? set_least_significant_bits(num_slack_bits)
: set_most_significant_bits(num_slack_bits);
thread_count -= __popc(word & slack_mask);
}
}
using BlockReduce = cub::BlockReduce<size_type, block_size>;
__shared__ typename BlockReduce::TempStorage temp_storage;
size_type block_count{BlockReduce(temp_storage).Sum(thread_count)};
if (threadIdx.x == 0) { atomicAdd(global_count, block_count); }
}
} // namespace
// Count non-zero bits in the specified range
cudf::size_type count_set_bits(bitmask_type const* bitmask,
size_type start,
size_type stop,
rmm::cuda_stream_view stream)
{
CUDF_EXPECTS(bitmask != nullptr, "Invalid bitmask.");
CUDF_EXPECTS(start >= 0, "Invalid range.");
CUDF_EXPECTS(start <= stop, "Invalid bit range.");
auto const num_bits_to_count = stop - start;
if (num_bits_to_count == 0) { return 0; }
auto const num_words = num_bitmask_words(num_bits_to_count);
constexpr size_type block_size{256};
cudf::detail::grid_1d grid(num_words, block_size);
rmm::device_scalar<size_type> non_zero_count(0, stream);
count_set_bits_kernel<block_size>
<<<grid.num_blocks, grid.num_threads_per_block, 0, stream.value()>>>(
bitmask, start, stop - 1, non_zero_count.data());
return non_zero_count.value(stream);
}
// Count zero bits in the specified range
cudf::size_type count_unset_bits(bitmask_type const* bitmask,
size_type start,
size_type stop,
rmm::cuda_stream_view stream)
{
auto const num_set_bits = detail::count_set_bits(bitmask, start, stop, stream);
auto const total_num_bits = (stop - start);
return total_num_bits - num_set_bits;
}
// Count valid elements in the specified range of a validity bitmask
cudf::size_type valid_count(bitmask_type const* bitmask,
size_type start,
size_type stop,
rmm::cuda_stream_view stream)
{
if (bitmask == nullptr) {
CUDF_EXPECTS(start >= 0, "Invalid range.");
CUDF_EXPECTS(start <= stop, "Invalid bit range.");
auto const total_num_bits = (stop - start);
return total_num_bits;
}
return detail::count_set_bits(bitmask, start, stop, stream);
}
// Count null elements in the specified range of a validity bitmask
cudf::size_type null_count(bitmask_type const* bitmask,
size_type start,
size_type stop,
rmm::cuda_stream_view stream)
{
if (bitmask == nullptr) {
CUDF_EXPECTS(start >= 0, "Invalid range.");
CUDF_EXPECTS(start <= stop, "Invalid bit range.");
return 0;
}
return detail::count_unset_bits(bitmask, start, stop, stream);
}
// Count non-zero bits in the specified ranges of a bitmask
std::vector<size_type> segmented_count_set_bits(bitmask_type const* bitmask,
host_span<size_type const> indices,
rmm::cuda_stream_view stream)
{
return detail::segmented_count_set_bits(bitmask, indices.begin(), indices.end(), stream);
}
// Count zero bits in the specified ranges of a bitmask
std::vector<size_type> segmented_count_unset_bits(bitmask_type const* bitmask,
host_span<size_type const> indices,
rmm::cuda_stream_view stream)
{
return detail::segmented_count_unset_bits(bitmask, indices.begin(), indices.end(), stream);
}
// Count valid elements in the specified ranges of a validity bitmask
std::vector<size_type> segmented_valid_count(bitmask_type const* bitmask,
host_span<size_type const> indices,
rmm::cuda_stream_view stream)
{
return detail::segmented_valid_count(bitmask, indices.begin(), indices.end(), stream);
}
// Count null elements in the specified ranges of a validity bitmask
std::vector<size_type> segmented_null_count(bitmask_type const* bitmask,
host_span<size_type const> indices,
rmm::cuda_stream_view stream)
{
return detail::segmented_null_count(bitmask, indices.begin(), indices.end(), stream);
}
// Inplace Bitwise AND of the masks
cudf::size_type inplace_bitmask_and(device_span<bitmask_type> dest_mask,
host_span<bitmask_type const* const> masks,
host_span<size_type const> begin_bits,
size_type mask_size,
rmm::cuda_stream_view stream)
{
return inplace_bitmask_binop(
[] __device__(bitmask_type left, bitmask_type right) { return left & right; },
dest_mask,
masks,
begin_bits,
mask_size,
stream);
}
// Bitwise AND of the masks
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,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return bitmask_binop(
[] __device__(bitmask_type left, bitmask_type right) { return left & right; },
masks,
begin_bits,
mask_size,
stream,
mr);
}
// Returns the bitwise AND of the null masks of all columns in the table view
std::pair<rmm::device_buffer, size_type> bitmask_and(table_view const& view,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
rmm::device_buffer null_mask{0, stream, mr};
if (view.num_rows() == 0 or view.num_columns() == 0) {
return std::pair(std::move(null_mask), 0);
}
std::vector<bitmask_type const*> masks;
std::vector<size_type> offsets;
for (auto&& col : view) {
if (col.nullable()) {
masks.push_back(col.null_mask());
offsets.push_back(col.offset());
}
}
if (masks.size() > 0) {
return cudf::detail::bitmask_binop(
[] __device__(bitmask_type left, bitmask_type right) { return left & right; },
masks,
offsets,
view.num_rows(),
stream,
mr);
}
return std::pair(std::move(null_mask), 0);
}
// Returns the bitwise OR of the null masks of all columns in the table view
std::pair<rmm::device_buffer, size_type> bitmask_or(table_view const& view,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
rmm::device_buffer null_mask{0, stream, mr};
if (view.num_rows() == 0 or view.num_columns() == 0) {
return std::pair(std::move(null_mask), 0);
}
std::vector<bitmask_type const*> masks;
std::vector<size_type> offsets;
for (auto&& col : view) {
if (col.nullable()) {
masks.push_back(col.null_mask());
offsets.push_back(col.offset());
}
}
if (static_cast<size_type>(masks.size()) == view.num_columns()) {
return cudf::detail::bitmask_binop(
[] __device__(bitmask_type left, bitmask_type right) { return left | right; },
masks,
offsets,
view.num_rows(),
stream,
mr);
}
return std::pair(std::move(null_mask), 0);
}
void set_all_valid_null_masks(column_view const& input,
column& output,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.nullable()) {
auto mask = detail::create_null_mask(output.size(), mask_state::ALL_VALID, stream, mr);
output.set_null_mask(std::move(mask), 0);
for (size_type i = 0; i < input.num_children(); ++i) {
set_all_valid_null_masks(input.child(i), output.child(i), stream, mr);
}
}
}
} // namespace detail
// Create a bitmask from a specific range
rmm::device_buffer copy_bitmask(bitmask_type const* mask,
size_type begin_bit,
size_type end_bit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::copy_bitmask(mask, begin_bit, end_bit, stream, mr);
}
// Create a bitmask from a column view
rmm::device_buffer copy_bitmask(column_view const& view,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::copy_bitmask(view, stream, mr);
}
std::pair<rmm::device_buffer, size_type> bitmask_and(table_view const& view,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::bitmask_and(view, stream, mr);
}
std::pair<rmm::device_buffer, size_type> bitmask_or(table_view const& view,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::bitmask_or(view, stream, mr);
}
// Count non-zero bits in the specified range
cudf::size_type null_count(bitmask_type const* bitmask,
size_type start,
size_type stop,
rmm::cuda_stream_view stream)
{
CUDF_FUNC_RANGE();
return detail::null_count(bitmask, start, stop, stream);
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/bitmask/is_element_valid.cpp
|
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_view.hpp>
#include <cudf/utilities/bit.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
namespace cudf {
namespace detail {
bool is_element_valid_sync(column_view const& col_view,
size_type element_index,
rmm::cuda_stream_view stream)
{
CUDF_EXPECTS(element_index >= 0 and element_index < col_view.size(), "invalid index.");
if (!col_view.nullable()) { return true; }
bitmask_type word;
// null_mask() returns device ptr to bitmask without offset
size_type index = element_index + col_view.offset();
CUDF_CUDA_TRY(cudaMemcpyAsync(&word,
col_view.null_mask() + word_index(index),
sizeof(bitmask_type),
cudaMemcpyDefault,
stream.value()));
stream.synchronize();
return static_cast<bool>(word & (bitmask_type{1} << intra_word_index(index)));
}
} // namespace detail
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/labeling/label_bins.cu
|
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/column/column_view.hpp>
#include <cudf/detail/label_bins.hpp>
#include <cudf/detail/valid_if.cuh>
#include <cudf/labeling/label_bins.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf/utilities/span.hpp>
#include <cudf/utilities/traits.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/device_memory_resource.hpp>
#include <thrust/advance.h>
#include <thrust/binary_search.h>
#include <thrust/distance.h>
#include <thrust/execution_policy.h>
#include <thrust/functional.h>
#include <thrust/pair.h>
#include <thrust/transform.h>
#include <limits>
namespace cudf {
namespace detail {
namespace {
// Sentinel used to indicate that an input value should be placed in the null
// bin.
// NOTE: In theory if a user decided to specify 2^31 bins this would fail. We
// could make this an error in Python, but that is such a crazy edge case...
constexpr size_type NULL_VALUE{std::numeric_limits<size_type>::max()};
/*
* Functor for finding bins using thrust::transform.
*
* This functor is stateful, in the sense that it stores (for read-only use)
* pointers to the edge ranges on construction to enable natural use with
* thrust::transform semantics. To handle null values, this functor assumes
* that the input iterators have already been shifted to exclude the range
* containing nulls. The `edge_index_shift` parameter is used to return the
* index of a value's bin accounting for this shift.
*/
template <typename T,
typename RandomAccessIterator,
typename LeftComparator,
typename RightComparator>
struct bin_finder {
bin_finder(RandomAccessIterator left_begin,
RandomAccessIterator left_end,
RandomAccessIterator right_begin)
: m_left_begin(left_begin), m_left_end(left_end), m_right_begin(right_begin)
{
}
__device__ size_type operator()(thrust::pair<T, bool> input_value) const
{
// Immediately return sentinel for null inputs.
if (!input_value.second) return NULL_VALUE;
T value = input_value.first;
auto bound = thrust::lower_bound(thrust::seq, m_left_begin, m_left_end, value, m_left_comp);
// Exit early and return sentinel for values that lie below the interval.
if (bound == m_left_begin) { return NULL_VALUE; }
auto index = thrust::distance(m_left_begin, thrust::prev(bound));
return (m_right_comp(value, m_right_begin[index])) ? index : NULL_VALUE;
}
RandomAccessIterator const
m_left_begin{}; // The beginning of the range containing the left bin edges.
RandomAccessIterator const m_left_end{}; // The end of the range containing the left bin edges.
RandomAccessIterator const
m_right_begin{}; // The beginning of the range containing the right bin edges.
LeftComparator const m_left_comp{}; // Comparator used for left edges.
RightComparator const m_right_comp{}; // Comparator used for right edges.
};
// Functor to identify rows that should be filtered out based on the sentinel set by
// bin_finder::operator().
struct filter_null_sentinel {
__device__ bool operator()(size_type i) { return i != NULL_VALUE; }
};
// Bin the input by the edges in left_edges and right_edges.
template <typename T, typename LeftComparator, typename RightComparator>
std::unique_ptr<column> label_bins(column_view const& input,
column_view const& left_edges,
column_view const& right_edges,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto output = make_numeric_column(
data_type(type_to_id<size_type>()), input.size(), mask_state::UNALLOCATED, stream, mr);
auto output_mutable_view = output->mutable_view();
auto output_begin = output_mutable_view.begin<size_type>();
auto output_end = output_mutable_view.end<size_type>();
// These device column views are necessary for creating iterators that work
// for columns of compound types. The column_view iterators fail for compound
// types because they return raw pointers to the start of the data. The output
// does not require these iterators because it's always a primitive type.
auto input_device_view = column_device_view::create(input, stream);
auto left_edges_device_view = column_device_view::create(left_edges, stream);
auto right_edges_device_view = column_device_view::create(right_edges, stream);
auto left_begin = left_edges_device_view->begin<T>();
auto left_end = left_edges_device_view->end<T>();
auto right_begin = right_edges_device_view->begin<T>();
using RandomAccessIterator = decltype(left_edges_device_view->begin<T>());
if (input.has_nulls()) {
thrust::transform(rmm::exec_policy(stream),
input_device_view->pair_begin<T, true>(),
input_device_view->pair_end<T, true>(),
output_begin,
bin_finder<T, RandomAccessIterator, LeftComparator, RightComparator>(
left_begin, left_end, right_begin));
} else {
thrust::transform(rmm::exec_policy(stream),
input_device_view->pair_begin<T, false>(),
input_device_view->pair_end<T, false>(),
output_begin,
bin_finder<T, RandomAccessIterator, LeftComparator, RightComparator>(
left_begin, left_end, right_begin));
}
auto mask_and_count = valid_if(output_begin, output_end, filter_null_sentinel(), stream, mr);
output->set_null_mask(std::move(mask_and_count.first), mask_and_count.second);
return output;
}
template <typename T>
constexpr auto is_supported_bin_type()
{
return cudf::is_relationally_comparable<T, T>() && cudf::is_equality_comparable<T, T>();
}
struct bin_type_dispatcher {
template <typename T, typename... Args>
std::enable_if_t<not detail::is_supported_bin_type<T>(), std::unique_ptr<column>> operator()(
Args&&...)
{
CUDF_FAIL("Type not support for cudf::bin");
}
template <typename T>
std::enable_if_t<detail::is_supported_bin_type<T>(), std::unique_ptr<column>> operator()(
column_view const& input,
column_view const& left_edges,
inclusive left_inclusive,
column_view const& right_edges,
inclusive right_inclusive,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if ((left_inclusive == inclusive::YES) && (right_inclusive == inclusive::YES))
return label_bins<T, thrust::less_equal<T>, thrust::less_equal<T>>(
input, left_edges, right_edges, stream, mr);
if ((left_inclusive == inclusive::YES) && (right_inclusive == inclusive::NO))
return label_bins<T, thrust::less_equal<T>, thrust::less<T>>(
input, left_edges, right_edges, stream, mr);
if ((left_inclusive == inclusive::NO) && (right_inclusive == inclusive::YES))
return label_bins<T, thrust::less<T>, thrust::less_equal<T>>(
input, left_edges, right_edges, stream, mr);
if ((left_inclusive == inclusive::NO) && (right_inclusive == inclusive::NO))
return label_bins<T, thrust::less<T>, thrust::less<T>>(
input, left_edges, right_edges, stream, mr);
CUDF_FAIL("Undefined inclusive setting.");
}
};
} // anonymous namespace
/// Bin the input by the edges in left_edges and right_edges.
std::unique_ptr<column> label_bins(column_view const& input,
column_view const& left_edges,
inclusive left_inclusive,
column_view const& right_edges,
inclusive right_inclusive,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE()
CUDF_EXPECTS((input.type() == left_edges.type()) && (input.type() == right_edges.type()),
"The input and edge columns must have the same types.");
CUDF_EXPECTS(left_edges.size() == right_edges.size(),
"The left and right edge columns must be of the same length.");
CUDF_EXPECTS(!left_edges.has_nulls() && !right_edges.has_nulls(),
"The left and right edge columns cannot contain nulls.");
// Handle empty inputs.
if (input.is_empty()) { return make_empty_column(type_to_id<size_type>()); }
return type_dispatcher<dispatch_storage_type>(input.type(),
detail::bin_type_dispatcher{},
input,
left_edges,
left_inclusive,
right_edges,
right_inclusive,
stream,
mr);
}
} // namespace detail
/// Bin the input by the edges in left_edges and right_edges.
std::unique_ptr<column> label_bins(column_view const& input,
column_view const& left_edges,
inclusive left_inclusive,
column_view const& right_edges,
inclusive right_inclusive,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::label_bins(input,
left_edges,
left_inclusive,
right_edges,
right_inclusive,
cudf::get_default_stream(),
mr);
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/table/table_view.cpp
|
/*
* Copyright (c) 2018-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_view.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/error.hpp>
#include <thrust/iterator/counting_iterator.h>
#include <algorithm>
#include <cassert>
#include <vector>
namespace cudf {
namespace detail {
template <typename ColumnView>
table_view_base<ColumnView>::table_view_base(std::vector<ColumnView> const& cols) : _columns{cols}
{
if (num_columns() > 0) {
std::for_each(_columns.begin(), _columns.end(), [this](ColumnView col) {
CUDF_EXPECTS(col.size() == _columns.front().size(), "Column size mismatch.");
});
_num_rows = _columns.front().size();
} else {
_num_rows = 0;
}
}
template <typename ViewType>
auto concatenate_column_views(std::vector<ViewType> const& views)
{
using ColumnView = typename ViewType::ColumnView;
std::vector<ColumnView> concat_cols;
for (auto& view : views) {
concat_cols.insert(concat_cols.end(), view.begin(), view.end());
}
return concat_cols;
}
template <typename ColumnView>
ColumnView const& table_view_base<ColumnView>::column(size_type column_index) const
{
return _columns.at(column_index);
}
// Explicit instantiation for a table of `column_view`s
template class table_view_base<column_view>;
// Explicit instantiation for a table of `mutable_column_view`s
template class table_view_base<mutable_column_view>;
} // namespace detail
// Returns a table_view with set of specified columns
table_view table_view::select(std::vector<size_type> const& column_indices) const
{
return select(column_indices.begin(), column_indices.end());
}
// Convert mutable view to immutable view
mutable_table_view::operator table_view()
{
std::vector<column_view> cols{begin(), end()};
return table_view{cols};
}
table_view::table_view(std::vector<table_view> const& views)
: table_view{concatenate_column_views(views)}
{
}
mutable_table_view::mutable_table_view(std::vector<mutable_table_view> const& views)
: mutable_table_view{concatenate_column_views(views)}
{
}
table_view scatter_columns(table_view const& source,
std::vector<size_type> const& map,
table_view const& target)
{
std::vector<cudf::column_view> updated_columns(target.begin(), target.end());
// scatter(updated_table.begin(),updated_table.end(),indices.begin(),updated_columns.begin());
for (size_type idx = 0; idx < source.num_columns(); ++idx)
updated_columns[map[idx]] = source.column(idx);
return table_view{updated_columns};
}
std::vector<column_view> get_nullable_columns(table_view const& table)
{
std::vector<column_view> result;
for (auto const& col : table) {
if (col.nullable()) { result.push_back(col); }
for (auto it = col.child_begin(); it != col.child_end(); ++it) {
auto const& child = *it;
if (child.size() == col.size()) {
auto const child_result = get_nullable_columns(table_view{{child}});
result.insert(result.end(), child_result.begin(), child_result.end());
}
}
}
return result;
}
namespace detail {
template <typename TableView>
bool is_relationally_comparable(TableView const& lhs, TableView const& rhs)
{
return std::all_of(thrust::counting_iterator<size_type>(0),
thrust::counting_iterator<size_type>(lhs.num_columns()),
[lhs, rhs](auto const i) {
return lhs.column(i).type() == rhs.column(i).type() and
cudf::is_relationally_comparable(lhs.column(i).type());
});
}
// Explicit template instantiation for a table of immutable views
template bool is_relationally_comparable<table_view>(table_view const& lhs, table_view const& rhs);
// Explicit template instantiation for a table of mutable views
template bool is_relationally_comparable<mutable_table_view>(mutable_table_view const& lhs,
mutable_table_view const& rhs);
bool has_nested_columns(table_view const& table)
{
return std::any_of(
table.begin(), table.end(), [](column_view const& col) { return is_nested(col.type()); });
}
} // namespace detail
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/table/table_device_view.cu
|
/*
* Copyright (c) 2019-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/table/table_device_view.cuh>
#include <cudf/table/table_view.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
namespace cudf {
namespace detail {
template <typename ColumnDeviceView, typename HostTableView>
void table_device_view_base<ColumnDeviceView, HostTableView>::destroy()
{
delete _descendant_storage;
delete this;
}
template <typename ColumnDeviceView, typename HostTableView>
table_device_view_base<ColumnDeviceView, HostTableView>::table_device_view_base(
HostTableView source_view, rmm::cuda_stream_view stream)
: _num_rows{source_view.num_rows()}, _num_columns{source_view.num_columns()}
{
// The table's columns must be converted to ColumnDeviceView
// objects and copied into device memory for the table_device_view's
// _columns member.
if (source_view.num_columns() > 0) {
std::unique_ptr<rmm::device_buffer> descendant_storage_owner;
std::tie(descendant_storage_owner, _columns) =
contiguous_copy_column_device_views<ColumnDeviceView, HostTableView>(source_view, stream);
_descendant_storage = descendant_storage_owner.release();
}
}
// Explicit instantiation for a device table of immutable views
template class table_device_view_base<column_device_view, table_view>;
// Explicit instantiation for a device table of mutable views
template class table_device_view_base<mutable_column_device_view, mutable_table_view>;
} // namespace detail
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/table/row_operators.cu
|
/*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <lists/utilities.hpp>
#include <cudf/column/column.hpp>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/concatenate.hpp>
#include <cudf/detail/copy.hpp>
#include <cudf/detail/sorting.hpp>
#include <cudf/detail/structs/utilities.hpp>
#include <cudf/detail/utilities/linked_column.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/lists/lists_column_view.hpp>
#include <cudf/table/experimental/row_operators.cuh>
#include <cudf/table/table_view.hpp>
#include <cudf/utilities/type_checks.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <thrust/iterator/transform_iterator.h>
namespace cudf {
namespace experimental {
namespace {
/**
* @brief Removes the offsets of struct column's children
*
* @param c The column whose children are to be un-sliced
* @return Children of `c` with offsets removed
*/
std::vector<column_view> unslice_children(column_view const& c)
{
if (c.type().id() == type_id::STRUCT) {
auto child_it = thrust::make_transform_iterator(c.child_begin(), [](auto const& child) {
return column_view(
child.type(),
child.offset() + child.size(), // This is hacky, we don't know the actual unsliced size but
// it is at least offset + size
child.head(),
child.null_mask(),
child.null_count(),
0,
unslice_children(child));
});
return {child_it, child_it + c.num_children()};
}
return {c.child_begin(), c.child_end()};
};
/**
* @brief Removes the child column offsets of struct columns in a table.
*
* Given a table, this replaces any struct columns with similar struct columns that have their
* offsets removed from their children. Structs that are children of list columns are not affected.
*
*/
table_view remove_struct_child_offsets(table_view table)
{
std::vector<column_view> cols;
cols.reserve(table.num_columns());
std::transform(table.begin(), table.end(), std::back_inserter(cols), [&](column_view const& c) {
return column_view(c.type(),
c.size(),
c.head<uint8_t>(),
c.null_mask(),
c.null_count(),
c.offset(),
unslice_children(c));
});
return table_view(cols);
}
/**
* @brief The enum to specify whether the `decompose_structs` function will process lists columns
* (at any nested level) or will output them unchanged.
*/
enum class decompose_lists_column : bool { YES, NO };
/**
* @brief Decompose all struct columns in a table
*
* If a structs column is a tree with N leaves, then this function decomposes the tree into
* N "linear trees" (branch factor == 1) and prunes common parents. Also returns a vector of
* per-column `depth`s.
*
* A `depth` value is the number of nested levels as parent of the column in the original,
* non-decomposed table, which are pruned during decomposition.
*
* Special handling is needed in the cases of structs column having lists as its first child. In
* such situations, the function decomposes the tree of N leaves into N+1 linear trees in which the
* second tree was generated by extracting out leaf of the first tree. This is to make sure there is
* no structs column having child lists column in the output. Note that structs with lists children
* in subsequent positions do not require any special treatment because the struct parent will be
* pruned for all subsequent children.
*
* For example, if the original table has a column `Struct<Struct<int, float>, decimal>`,
*
* S1
* / \
* S2 d
* / \
* i f
*
* then after decomposition, we get three columns:
* `Struct<Struct<int>>`, `float`, and `decimal`.
*
* 0 2 1 <- depths
* S1
* |
* S2 d
* |
* i f
*
* The depth of the first column is 0 because it contains all its parent levels, while the depth
* of the second column is 2 because two of its parent struct levels were pruned.
*
* Similarly, a struct column of type `Struct<int, Struct<float, decimal>>` is decomposed as follows
*
* S1
* / \
* i S2
* / \
* f d
*
* 0 1 2 <- depths
* S1 S2 d
* | |
* i f
*
* In the case of structs column with a lists column as its first child such as
* `Struct<List<int>, float>`, after decomposition we get three columns `Struct<>`,
* `List<int>`, and `float`.
*
* When list columns are present, depending on the input flag `decompose_lists`, the decomposition
* can be performed similarly to pure structs but list parent columns are NOT pruned. The list
* parents are still needed to define the range of elements in the leaf that belong to the same row.
*
* For example, if the original table has a column `List<Struct<int, float>>`,
*
* L
* |
* S
* / \
* i f
*
* after decomposition, we get two columns
*
* L L
* | |
* S f
* |
* i
*
* Note that the `decompose_lists` flag should be specified as follow:
* - `decompose_lists_column::YES` when preprocessing a table for equality comparison.
* - `decompose_lists_column::NO` when preprocessing a table for lexicographic comparison,
* since we need to keep all lists columns intact to input into the next preprocessing step.
*
* @param table The table whose struct columns to decompose.
* @param decompose_lists Whether to decompose lists columns
* @param column_order The per-column order if using output with lexicographic comparison
* @param null_precedence The per-column null precedence
* @return A tuple containing a table with all struct columns decomposed, new corresponding column
* orders and null precedences and depths of the linearized branches
*/
auto decompose_structs(table_view table,
decompose_lists_column decompose_lists,
host_span<order const> column_order = {},
host_span<null_order const> null_precedence = {})
{
auto linked_columns = detail::table_to_linked_columns(table);
std::vector<column_view> verticalized_columns;
std::vector<order> new_column_order;
std::vector<null_order> new_null_precedence;
std::vector<int> verticalized_col_depths;
for (size_t col_idx = 0; col_idx < linked_columns.size(); ++col_idx) {
detail::linked_column_view const* col = linked_columns[col_idx].get();
if (is_nested(col->type())) {
// convert and insert
std::vector<std::vector<detail::linked_column_view const*>> flattened;
std::function<void(
detail::linked_column_view const*, std::vector<detail::linked_column_view const*>*, int)>
recursive_child = [&](detail::linked_column_view const* c,
std::vector<detail::linked_column_view const*>* branch,
int depth) {
branch->push_back(c);
if (decompose_lists == decompose_lists_column::YES && c->type().id() == type_id::LIST) {
recursive_child(
c->children[lists_column_view::child_column_index].get(), branch, depth + 1);
} else if (c->type().id() == type_id::STRUCT) {
for (size_t child_idx = 0; child_idx < c->children.size(); ++child_idx) {
// When child_idx == 0, we also cut off the current branch if its first child is a
// lists column.
// In such cases, the last column of the current branch will be `Struct<List,...>` and
// it will be modified to empty struct type `Struct<>` later on.
if (child_idx > 0 || c->children[0]->type().id() == type_id::LIST) {
verticalized_col_depths.push_back(depth + 1);
branch = &flattened.emplace_back();
}
recursive_child(c->children[child_idx].get(), branch, depth + 1);
}
}
};
auto& branch = flattened.emplace_back();
verticalized_col_depths.push_back(0);
recursive_child(col, &branch, 0);
for (auto const& branch : flattened) {
column_view temp_col = *branch.back();
// Change `Struct<List,...>` into empty struct type `Struct<>`.
if (temp_col.type().id() == type_id::STRUCT &&
(temp_col.num_children() > 0 && temp_col.child(0).type().id() == type_id::LIST)) {
temp_col = column_view(temp_col.type(),
temp_col.size(),
temp_col.head(),
temp_col.null_mask(),
temp_col.null_count(),
temp_col.offset(),
{});
}
for (auto it = branch.crbegin() + 1; it < branch.crend(); ++it) {
auto const& prev_col = *(*it);
auto children =
(prev_col.type().id() == type_id::LIST)
? std::vector<column_view>{*prev_col
.children[lists_column_view::offsets_column_index],
temp_col}
: std::vector<column_view>{temp_col};
temp_col = column_view(prev_col.type(),
prev_col.size(),
nullptr,
prev_col.null_mask(),
prev_col.null_count(),
prev_col.offset(),
std::move(children));
}
// Traverse upward and include any list columns in the ancestors
for (detail::linked_column_view* parent = branch.front()->parent; parent;
parent = parent->parent) {
if (parent->type().id() == type_id::LIST) {
// Include this parent
temp_col = column_view(
parent->type(),
parent->size(),
nullptr, // list has no data of its own
nullptr, // If we're going through this then nullmask is already in another branch
0,
parent->offset(),
{*parent->children[lists_column_view::offsets_column_index], temp_col});
} else if (parent->type().id() == type_id::STRUCT) {
// Replace offset with parent's offset
temp_col = column_view(temp_col.type(),
parent->size(),
temp_col.head(),
temp_col.null_mask(),
temp_col.null_count(),
parent->offset(),
{temp_col.child_begin(), temp_col.child_end()});
}
}
verticalized_columns.push_back(temp_col);
}
if (not column_order.empty()) {
new_column_order.insert(new_column_order.end(), flattened.size(), column_order[col_idx]);
}
if (not null_precedence.empty()) {
new_null_precedence.insert(
new_null_precedence.end(), flattened.size(), null_precedence[col_idx]);
}
} else {
verticalized_columns.push_back(*col);
verticalized_col_depths.push_back(0);
if (not column_order.empty()) { new_column_order.push_back(column_order[col_idx]); }
if (not null_precedence.empty()) { new_null_precedence.push_back(null_precedence[col_idx]); }
}
}
return std::make_tuple(table_view(verticalized_columns),
std::move(new_column_order),
std::move(new_null_precedence),
std::move(verticalized_col_depths));
}
/*
* This helper function generates dremel data for any list-type columns in a
* table. This data is necessary for lexicographic comparisons.
*/
auto list_lex_preprocess(table_view const& table, rmm::cuda_stream_view stream)
{
std::vector<detail::dremel_data> dremel_data;
std::vector<detail::dremel_device_view> dremel_device_views;
for (auto const& col : table) {
if (col.type().id() == type_id::LIST) {
dremel_data.push_back(detail::get_comparator_data(col, {}, false, stream));
dremel_device_views.push_back(dremel_data.back());
}
}
auto d_dremel_device_views = detail::make_device_uvector_sync(
dremel_device_views, stream, rmm::mr::get_current_device_resource());
return std::make_tuple(std::move(dremel_data), std::move(d_dremel_device_views));
}
using column_checker_fn_t = std::function<void(column_view const&)>;
/**
* @brief Check a table for compatibility with lexicographic comparison
*
* Checks whether a given table contains columns of non-relationally comparable types.
*/
void check_lex_compatibility(table_view const& input)
{
// Basically check if there's any LIST of STRUCT or STRUCT of LIST hiding anywhere in the table
column_checker_fn_t check_column = [&](column_view const& c) {
if (c.type().id() == type_id::LIST) {
auto const& list_col = lists_column_view(c);
CUDF_EXPECTS(list_col.child().type().id() != type_id::STRUCT,
"Cannot lexicographically compare a table with a LIST of STRUCT column");
check_column(list_col.child());
} else if (c.type().id() == type_id::STRUCT) {
for (auto child = c.child_begin(); child < c.child_end(); ++child) {
CUDF_EXPECTS(child->type().id() != type_id::LIST,
"Cannot lexicographically compare a table with a STRUCT of LIST column");
check_column(*child);
}
}
if (not is_nested(c.type())) {
CUDF_EXPECTS(is_relationally_comparable(c.type()),
"Cannot lexicographic compare a table with a column of type " +
cudf::type_to_name(c.type()));
}
};
for (column_view const& c : input) {
check_column(c);
}
}
/**
* @brief Check a table for compatibility with equality comparison
*
* Checks whether a given table contains columns of non-equality comparable types.
*/
void check_eq_compatibility(table_view const& input)
{
column_checker_fn_t check_column = [&](column_view const& c) {
if (not is_nested(c.type())) {
CUDF_EXPECTS(is_equality_comparable(c.type()),
"Cannot compare equality for a table with a column of type " +
cudf::type_to_name(c.type()));
}
for (auto child = c.child_begin(); child < c.child_end(); ++child) {
check_column(*child);
}
};
for (column_view const& c : input) {
check_column(c);
}
}
void check_shape_compatibility(table_view const& lhs, table_view const& rhs)
{
CUDF_EXPECTS(lhs.num_columns() == rhs.num_columns(),
"Cannot compare tables with different number of columns");
for (size_type i = 0; i < lhs.num_columns(); ++i) {
CUDF_EXPECTS(column_types_equivalent(lhs.column(i), rhs.column(i)),
"Cannot compare tables with different column types");
}
}
} // namespace
namespace row {
namespace lexicographic {
namespace {
/**
* @brief Replace child of the input lists column by a new child column.
*
* If the input is not sliced, just replace the input child by the new_child.
* Otherwise, we have to generate new offsets and replace both the offsets and the child of the
* input by the new ones. This is because the new child was generated by ranking and always
* has zero offset, so it cannot replace the input child if it is sliced.
*
* The new generated offsets column needs to be returned and kept alive.
*
* @param[in] input The input column_view of type LIST
* @param[in] new_child A new child column to replace the existing child of the input
* @param[out] out_cols An array to store the new generated offsets (if applicable)
* @param[in] stream CUDA stream used for device memory operations and kernel launches
* @param[in] mr Device memory resource used to allocate the returned column
* @return An output column_view with child replaced
*/
auto replace_child(column_view const& input,
column_view const& new_child,
std::vector<std::unique_ptr<column>>& out_cols,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto const make_output = [&input](auto const& offsets_cv, auto const& child_cv) {
return column_view{data_type{type_id::LIST},
input.size(),
nullptr,
input.null_mask(),
input.null_count(),
0,
{offsets_cv, child_cv}};
};
if (input.offset() == 0) {
return make_output(input.child(lists_column_view::offsets_column_index), new_child);
}
out_cols.emplace_back(
cudf::lists::detail::get_normalized_offsets(lists_column_view{input}, stream, mr));
return make_output(out_cols.back()->view(), new_child);
}
/**
* @brief Compute ranks of the input column.
*
* `Dense` rank type must be used for compute ranking of the input for later lexicographic
* comparison.
*
* To understand why, consider: `input = [ [{0, "a"}, {3, "c"}], [{0, "a"}, {2, "b"}] ]`.
* If first rank is used, `transformed_input = [ [0, 3], [1, 2] ]`. Comparing them will lead
* to the result row(0) < row(1) which is incorrect.
* With dense rank, `transformed_input = [ [0, 2], [0, 1] ]`, producing the correct output for
* lexicographic comparison.
*
* In addition, since the input column being ranked is always a nested child column instead of
* a top-level column, the column order for ranking should be fixed to the same value
* `order::ASCENDING` in all situations.
* For example, with the same input above, using column order as `order::ASCENDING` we will have
* `transformed_input = [ [0, 2], [0, 1] ]`. The output of sorting `transformed_input` will be
* exactly the same as sorting `input` regardless of the sorting order (ASC or DESC).
*
* @param input The input column to compute ranks
* @param column_null_order The flag indicating how nulls compare to non-null values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate the returned column
* @return The output rank columns
*/
auto compute_ranks(column_view const& input,
null_order column_null_order,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return cudf::detail::rank(input,
rank_method::DENSE,
order::ASCENDING,
null_policy::EXCLUDE,
column_null_order,
false /*percentage*/,
stream,
mr);
}
/**
* @brief Transform any nested lists-of-structs column into lists-of-integers column.
*
* For a lists-of-structs column at any nested level, its child structs column will be replaced by a
* `size_type` column computed as its ranks.
*
* If the input column is not lists-of-structs, or does not contain lists-of-structs at any nested
* level, the input will be passed through without any changes.
*
* @param input The input column to transform
* @param column_null_order The flag indicating how nulls compare to non-null values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate the returned column(s)
* @return A pair consisting of new column_view representing the transformed input, along with
* an array containing its rank column(s) (of `size_type` type) and possibly new list
* offsets generated during the transformation process
*/
std::pair<column_view, std::vector<std::unique_ptr<column>>> transform_lists_of_structs(
column_view const& input,
null_order column_null_order,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
std::vector<std::unique_ptr<column>> out_cols;
if (input.type().id() == type_id::LIST) {
auto const child = cudf::lists_column_view{input}.get_sliced_child(stream);
// Found a lists-of-structs column.
if (child.type().id() == type_id::STRUCT) {
out_cols.emplace_back(compute_ranks(child, column_null_order, stream, mr));
return {replace_child(input, out_cols.back()->view(), out_cols, stream, mr),
std::move(out_cols)};
}
// Found a lists-of-lists column.
else if (child.type().id() == type_id::LIST) {
// Recursively call transformation on the child column.
auto [new_child, out_cols_child] =
transform_lists_of_structs(child, column_null_order, stream, mr);
// Only transform the current column if its child has been transformed.
if (out_cols_child.size() > 0) {
out_cols.insert(out_cols.end(),
std::make_move_iterator(out_cols_child.begin()),
std::make_move_iterator(out_cols_child.end()));
return {replace_child(input, new_child, out_cols, stream, mr), std::move(out_cols)};
}
// else: child was not transformed so input is also not transformed.
}
// else: child is not STRUCT or LIST: no transformation.
}
// else: lhs.type().id() != type_id::LIST.
// In such situations, lhs.type().id() can still be type_id::STRUCT. However, any
// structs-of-lists should be decomposed into empty struct type `Struct<>` before being
// processed by this function so we do nothing here.
// Passthrough: nothing changed.
return {input, std::move(out_cols)};
}
/**
* @brief Transform any nested lists-of-structs column into lists-of-integers column.
*
* For a lists-of-structs column at any nested level, its child structs column will be replaced by a
* `size_type` column computed as its ranks. In addition, equivalent child columns of both input
* columns (i.e., child columns at the same order, same nested level) will be combined and
* ranked together.
*
* If the input columns are not lists-of-structs, or do not contain lists-of-structs at any nested
* level, there will not be any changes.
*
* @param lhs The input lhs column to transform
* @param rhs The input rhs column to transform
* @param column_null_order The flag indicating how nulls compare to non-null values
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate the returned column(s)
* @return A tuple consisting of new column_view(s) representing the transformed input, along with
* their rank column(s) (of `size_type` type) and possibly new list offsets generated
* during the transformation process
*/
std::tuple<column_view,
column_view,
std::vector<std::unique_ptr<column>>,
std::vector<std::unique_ptr<column>>>
transform_lists_of_structs(column_view const& lhs,
column_view const& rhs,
null_order column_null_order,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
std::vector<std::unique_ptr<column>> out_cols_lhs;
std::vector<std::unique_ptr<column>> out_cols_rhs;
auto const make_output = [&](auto const& new_child_lhs, auto const& new_child_rhs) {
return std::tuple{replace_child(lhs, new_child_lhs, out_cols_lhs, stream, mr),
replace_child(rhs, new_child_rhs, out_cols_rhs, stream, mr),
std::move(out_cols_lhs),
std::move(out_cols_rhs)};
};
if (lhs.type().id() == type_id::LIST) {
auto const child_lhs = cudf::lists_column_view{lhs}.get_sliced_child(stream);
auto const child_rhs = cudf::lists_column_view{rhs}.get_sliced_child(stream);
// Found a lists-of-structs column.
if (child_lhs.type().id() == type_id::STRUCT) {
auto const concatenated_children =
cudf::detail::concatenate(std::vector<column_view>{child_lhs, child_rhs},
stream,
rmm::mr::get_current_device_resource());
auto const ranks = compute_ranks(concatenated_children->view(),
column_null_order,
stream,
rmm::mr::get_current_device_resource());
auto const ranks_slices = cudf::detail::slice(
ranks->view(),
{0, child_lhs.size(), child_lhs.size(), child_lhs.size() + child_rhs.size()},
stream);
out_cols_lhs.emplace_back(std::make_unique<column>(ranks_slices.front(), stream, mr));
out_cols_rhs.emplace_back(std::make_unique<column>(ranks_slices.back(), stream, mr));
return make_output(out_cols_lhs.back()->view(), out_cols_rhs.back()->view());
}
// Found a lists-of-lists column.
else if (child_lhs.type().id() == type_id::LIST) {
// Recursively call transformation on the child column.
auto [new_child_lhs, new_child_rhs, out_cols_child_lhs, out_cols_child_rhs] =
transform_lists_of_structs(child_lhs, child_rhs, column_null_order, stream, mr);
// Only transform the current pair of columns if their children have been transformed.
if (out_cols_child_lhs.size() > 0 || out_cols_child_rhs.size() > 0) {
out_cols_lhs.insert(out_cols_lhs.end(),
std::make_move_iterator(out_cols_child_lhs.begin()),
std::make_move_iterator(out_cols_child_lhs.end()));
out_cols_rhs.insert(out_cols_rhs.end(),
std::make_move_iterator(out_cols_child_rhs.begin()),
std::make_move_iterator(out_cols_child_rhs.end()));
return make_output(new_child_lhs, new_child_rhs);
}
}
// else: child is not STRUCT or LIST: just go to the end of this function, no transformation.
}
// else: lhs.type().id() != type_id::LIST.
// In such situations, lhs.type().id() can still be type_id::STRUCT. However, any
// structs-of-lists should be decomposed into empty struct type `Struct<>` before being
// processed by this function so we do nothing here.
// Passthrough: nothing changed.
return {lhs, rhs, std::move(out_cols_lhs), std::move(out_cols_rhs)};
}
} // namespace
std::shared_ptr<preprocessed_table> preprocessed_table::create(
table_view const& preprocessed_input,
std::vector<int>&& verticalized_col_depths,
std::vector<std::unique_ptr<column>>&& transformed_columns,
host_span<order const> column_order,
host_span<null_order const> null_precedence,
bool has_ranked_children,
rmm::cuda_stream_view stream)
{
check_lex_compatibility(preprocessed_input);
auto d_table = table_device_view::create(preprocessed_input, stream);
auto d_column_order =
detail::make_device_uvector_async(column_order, stream, rmm::mr::get_current_device_resource());
auto d_null_precedence = detail::make_device_uvector_async(
null_precedence, stream, rmm::mr::get_current_device_resource());
auto d_depths = detail::make_device_uvector_async(
verticalized_col_depths, stream, rmm::mr::get_current_device_resource());
if (detail::has_nested_columns(preprocessed_input)) {
auto [dremel_data, d_dremel_device_view] = list_lex_preprocess(preprocessed_input, stream);
return std::shared_ptr<preprocessed_table>(
new preprocessed_table(std::move(d_table),
std::move(d_column_order),
std::move(d_null_precedence),
std::move(d_depths),
std::move(dremel_data),
std::move(d_dremel_device_view),
std::move(transformed_columns),
has_ranked_children));
} else {
return std::shared_ptr<preprocessed_table>(
new preprocessed_table(std::move(d_table),
std::move(d_column_order),
std::move(d_null_precedence),
std::move(d_depths),
std::move(transformed_columns),
has_ranked_children));
}
}
std::shared_ptr<preprocessed_table> preprocessed_table::create(
table_view const& input,
host_span<order const> column_order,
host_span<null_order const> null_precedence,
rmm::cuda_stream_view stream)
{
auto [decomposed_input, new_column_order, new_null_precedence, verticalized_col_depths] =
decompose_structs(input, decompose_lists_column::NO, column_order, null_precedence);
// Transform any (nested) lists-of-structs column into lists-of-integers column.
std::vector<std::unique_ptr<column>> transformed_columns;
auto const transformed_input =
[&, &decomposed_input = decomposed_input, &new_null_precedence = new_null_precedence] {
std::vector<column_view> transformed_cvs;
for (size_type col_idx = 0; col_idx < decomposed_input.num_columns(); ++col_idx) {
auto const& lhs_col = decomposed_input.column(col_idx);
auto [transformed, curr_out_cols] = transform_lists_of_structs(
lhs_col,
null_precedence.empty() ? null_order::BEFORE : new_null_precedence[col_idx],
stream,
rmm::mr::get_current_device_resource());
transformed_cvs.emplace_back(std::move(transformed));
transformed_columns.insert(transformed_columns.end(),
std::make_move_iterator(curr_out_cols.begin()),
std::make_move_iterator(curr_out_cols.end()));
}
return table_view{transformed_cvs};
}();
auto const has_ranked_children = !transformed_columns.empty();
return create(transformed_input,
std::move(verticalized_col_depths),
std::move(transformed_columns),
new_column_order,
new_null_precedence,
has_ranked_children,
stream);
}
std::pair<std::shared_ptr<preprocessed_table>, std::shared_ptr<preprocessed_table>>
preprocessed_table::create(table_view const& lhs,
table_view const& rhs,
host_span<order const> column_order,
host_span<null_order const> null_precedence,
rmm::cuda_stream_view stream)
{
check_shape_compatibility(lhs, rhs);
auto [decomposed_lhs,
new_column_order_lhs,
new_null_precedence_lhs,
verticalized_col_depths_lhs] =
decompose_structs(lhs, decompose_lists_column::NO, column_order, null_precedence);
// Unused variables are new column order and null order for rhs, which are the same as for lhs
// so we don't need them.
[[maybe_unused]] auto [decomposed_rhs, unused0, unused1, verticalized_col_depths_rhs] =
decompose_structs(rhs, decompose_lists_column::NO, column_order, null_precedence);
// Transform any (nested) lists-of-structs column into lists-of-integers column.
std::vector<std::unique_ptr<column>> transformed_columns_lhs;
std::vector<std::unique_ptr<column>> transformed_columns_rhs;
auto const [transformed_lhs,
transformed_rhs] = [&,
&decomposed_lhs = decomposed_lhs,
&decomposed_rhs = decomposed_rhs,
&new_null_precedence_lhs = new_null_precedence_lhs] {
std::vector<column_view> transformed_lhs_cvs;
std::vector<column_view> transformed_rhs_cvs;
for (size_type col_idx = 0; col_idx < decomposed_lhs.num_columns(); ++col_idx) {
auto const& lhs_col = decomposed_lhs.column(col_idx);
auto const& rhs_col = decomposed_rhs.column(col_idx);
auto [transformed_lhs, transformed_rhs, curr_out_cols_lhs, curr_out_cols_rhs] =
transform_lists_of_structs(
lhs_col,
rhs_col,
null_precedence.empty() ? null_order::BEFORE : null_precedence[col_idx],
stream,
rmm::mr::get_current_device_resource());
transformed_lhs_cvs.emplace_back(std::move(transformed_lhs));
transformed_rhs_cvs.emplace_back(std::move(transformed_rhs));
transformed_columns_lhs.insert(transformed_columns_lhs.end(),
std::make_move_iterator(curr_out_cols_lhs.begin()),
std::make_move_iterator(curr_out_cols_lhs.end()));
transformed_columns_rhs.insert(transformed_columns_rhs.end(),
std::make_move_iterator(curr_out_cols_rhs.begin()),
std::make_move_iterator(curr_out_cols_rhs.end()));
}
return std::pair{table_view{transformed_lhs_cvs}, table_view{transformed_rhs_cvs}};
}();
// This should be the same for both lhs and rhs but not all the time, such as when one table
// has 0 rows while the other has >0 rows. So we check separately for each of them.
auto const has_ranked_children_lhs = !transformed_columns_lhs.empty();
auto const has_ranked_children_rhs = !transformed_columns_rhs.empty();
return {create(transformed_lhs,
std::move(verticalized_col_depths_lhs),
std::move(transformed_columns_lhs),
new_column_order_lhs,
new_null_precedence_lhs,
has_ranked_children_lhs,
stream),
create(transformed_rhs,
std::move(verticalized_col_depths_rhs),
std::move(transformed_columns_rhs),
new_column_order_lhs,
new_null_precedence_lhs,
has_ranked_children_rhs,
stream)};
}
preprocessed_table::preprocessed_table(
table_device_view_owner&& table,
rmm::device_uvector<order>&& column_order,
rmm::device_uvector<null_order>&& null_precedence,
rmm::device_uvector<size_type>&& depths,
std::vector<detail::dremel_data>&& dremel_data,
rmm::device_uvector<detail::dremel_device_view>&& dremel_device_views,
std::vector<std::unique_ptr<column>>&& transformed_columns,
bool has_ranked_children)
: _t(std::move(table)),
_column_order(std::move(column_order)),
_null_precedence(std::move(null_precedence)),
_depths(std::move(depths)),
_dremel_data(std::move(dremel_data)),
_dremel_device_views(std::move(dremel_device_views)),
_transformed_columns(std::move(transformed_columns)),
_has_ranked_children(has_ranked_children)
{
}
preprocessed_table::preprocessed_table(table_device_view_owner&& table,
rmm::device_uvector<order>&& column_order,
rmm::device_uvector<null_order>&& null_precedence,
rmm::device_uvector<size_type>&& depths,
std::vector<std::unique_ptr<column>>&& transformed_columns,
bool has_ranked_children)
: _t(std::move(table)),
_column_order(std::move(column_order)),
_null_precedence(std::move(null_precedence)),
_depths(std::move(depths)),
_dremel_data{},
_dremel_device_views{},
_transformed_columns(std::move(transformed_columns)),
_has_ranked_children(has_ranked_children)
{
}
two_table_comparator::two_table_comparator(table_view const& left,
table_view const& right,
host_span<order const> column_order,
host_span<null_order const> null_precedence,
rmm::cuda_stream_view stream)
{
std::tie(d_left_table, d_right_table) =
preprocessed_table::create(left, right, column_order, null_precedence, stream);
}
} // namespace lexicographic
namespace equality {
std::shared_ptr<preprocessed_table> preprocessed_table::create(table_view const& t,
rmm::cuda_stream_view stream)
{
check_eq_compatibility(t);
auto [null_pushed_table, nullable_data] =
structs::detail::push_down_nulls(t, stream, rmm::mr::get_current_device_resource());
auto struct_offset_removed_table = remove_struct_child_offsets(null_pushed_table);
auto verticalized_t =
std::get<0>(decompose_structs(struct_offset_removed_table, decompose_lists_column::YES));
auto d_t = table_device_view_owner(table_device_view::create(verticalized_t, stream));
return std::shared_ptr<preprocessed_table>(new preprocessed_table(
std::move(d_t), std::move(nullable_data.new_null_masks), std::move(nullable_data.new_columns)));
}
two_table_comparator::two_table_comparator(table_view const& left,
table_view const& right,
rmm::cuda_stream_view stream)
: d_left_table{preprocessed_table::create(left, stream)},
d_right_table{preprocessed_table::create(right, stream)}
{
check_shape_compatibility(left, right);
}
} // namespace equality
} // namespace row
} // namespace experimental
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/table/table.cpp
|
/*
* Copyright (c) 2019-2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/table/table.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
namespace cudf {
// Copy the columns from another table
table::table(table const& other) : _num_rows{other.num_rows()}
{
CUDF_FUNC_RANGE();
_columns.reserve(other._columns.size());
for (auto const& c : other._columns) {
_columns.emplace_back(std::make_unique<column>(*c));
}
}
// Move the contents of a vector `unique_ptr<column>`
table::table(std::vector<std::unique_ptr<column>>&& columns) : _columns{std::move(columns)}
{
if (num_columns() > 0) {
for (auto const& c : _columns) {
CUDF_EXPECTS(c, "Unexpected null column");
CUDF_EXPECTS(c->size() == _columns.front()->size(),
"Column size mismatch: " + std::to_string(c->size()) +
" != " + std::to_string(_columns.front()->size()));
}
_num_rows = _columns.front()->size();
} else {
_num_rows = 0;
}
}
// Copy the contents of a `table_view`
table::table(table_view view, rmm::cuda_stream_view stream, rmm::mr::device_memory_resource* mr)
: _num_rows{view.num_rows()}
{
CUDF_FUNC_RANGE();
_columns.reserve(view.num_columns());
for (auto const& c : view) {
_columns.emplace_back(std::make_unique<column>(c, stream, mr));
}
}
// Create immutable view
table_view table::view() const
{
std::vector<column_view> views;
views.reserve(_columns.size());
for (auto const& c : _columns) {
views.push_back(c->view());
}
return table_view{views};
}
// Create mutable view
mutable_table_view table::mutable_view()
{
std::vector<mutable_column_view> views;
views.reserve(_columns.size());
for (auto const& c : _columns) {
views.push_back(c->mutable_view());
}
return mutable_table_view{views};
}
// Release ownership of columns
std::vector<std::unique_ptr<column>> table::release()
{
_num_rows = 0;
return std::move(_columns);
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/replace/nans.cu
|
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_view.hpp>
#include <cudf/detail/copy_if_else.cuh>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/replace.hpp>
#include <cudf/replace.hpp>
#include <cudf/scalar/scalar.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform.h>
#include <thrust/transform_scan.h>
namespace cudf {
namespace detail {
namespace {
struct replace_nans_functor {
template <typename T, typename Replacement>
std::enable_if_t<std::is_floating_point_v<T>, std::unique_ptr<column>> operator()(
column_view const& input,
Replacement const& replacement,
bool replacement_nullable,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(input.type() == replacement.type(),
"Input and replacement must be of the same type");
if (input.is_empty()) { return cudf::make_empty_column(input.type()); }
auto input_device_view = column_device_view::create(input, stream);
size_type size = input.size();
auto predicate = [dinput = *input_device_view] __device__(auto i) {
return dinput.is_null(i) or !std::isnan(dinput.element<T>(i));
};
auto input_iterator =
make_optional_iterator<T>(*input_device_view, nullate::DYNAMIC{input.has_nulls()});
auto replacement_iterator =
make_optional_iterator<T>(replacement, nullate::DYNAMIC{replacement_nullable});
return copy_if_else(input.has_nulls() or replacement_nullable,
input_iterator,
input_iterator + size,
replacement_iterator,
predicate,
input.type(),
stream,
mr);
}
template <typename T, typename... Args>
std::enable_if_t<!std::is_floating_point_v<T>, std::unique_ptr<column>> operator()(Args&&...)
{
CUDF_FAIL("NAN is not supported in a Non-floating point type column");
}
};
} // namespace
std::unique_ptr<column> replace_nans(column_view const& input,
column_view const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(input.size() == replacement.size(),
"Input and replacement must be of the same size");
return type_dispatcher(input.type(),
replace_nans_functor{},
input,
*column_device_view::create(replacement, stream),
replacement.nullable(),
stream,
mr);
}
std::unique_ptr<column> replace_nans(column_view const& input,
scalar const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return type_dispatcher(
input.type(), replace_nans_functor{}, input, replacement, true, stream, mr);
}
} // namespace detail
std::unique_ptr<column> replace_nans(column_view const& input,
column_view const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace_nans(input, replacement, stream, mr);
}
std::unique_ptr<column> replace_nans(column_view const& input,
scalar const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace_nans(input, replacement, stream, mr);
}
} // namespace cudf
namespace { // anonymous
template <typename T>
struct normalize_nans_and_zeros_lambda {
cudf::column_device_view in;
T __device__ operator()(cudf::size_type i)
{
auto e = in.element<T>(i);
if (isnan(e)) { return std::numeric_limits<T>::quiet_NaN(); }
if (T{0.0} == e) { return T{0.0}; }
return e;
}
};
/**
* @brief Functor called by the `type_dispatcher` in order to invoke and instantiate
* `normalize_nans_and_zeros` with the appropriate data types.
*/
struct normalize_nans_and_zeros_kernel_forwarder {
// floats and doubles. what we really care about.
template <typename T, std::enable_if_t<std::is_floating_point_v<T>>* = nullptr>
void operator()(cudf::column_device_view in,
cudf::mutable_column_device_view out,
rmm::cuda_stream_view stream)
{
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator(0),
thrust::make_counting_iterator(in.size()),
out.head<T>(),
normalize_nans_and_zeros_lambda<T>{in});
}
// if we get in here for anything but a float or double, that's a problem.
template <typename T, typename... Args>
std::enable_if_t<not std::is_floating_point_v<T>, void> operator()(Args&&...)
{
CUDF_FAIL("Unexpected non floating-point type.");
}
};
} // end anonymous namespace
namespace cudf {
namespace detail {
void normalize_nans_and_zeros(mutable_column_view in_out, rmm::cuda_stream_view stream)
{
if (in_out.is_empty()) { return; }
CUDF_EXPECTS(
in_out.type() == data_type(type_id::FLOAT32) || in_out.type() == data_type(type_id::FLOAT64),
"Expects float or double input");
// wrapping the in_out data in a column_view so we can call the same lower level code.
// that we use for the non in-place version.
column_view input = in_out;
// to device. unique_ptr which gets automatically cleaned up when we leave
auto device_in = column_device_view::create(input, stream);
// from device. unique_ptr which gets automatically cleaned up when we leave.
auto device_out = mutable_column_device_view::create(in_out, stream);
// invoke the actual kernel.
cudf::type_dispatcher(
input.type(), normalize_nans_and_zeros_kernel_forwarder{}, *device_in, *device_out, stream);
}
std::unique_ptr<column> normalize_nans_and_zeros(column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// output. copies the input
auto out = std::make_unique<column>(input, stream, mr);
// from device. unique_ptr which gets automatically cleaned up when we leave.
auto out_view = out->mutable_view();
detail::normalize_nans_and_zeros(out_view, stream);
out->set_null_count(input.null_count());
return out;
}
} // namespace detail
/**
* @brief Makes all Nans and zeroes positive.
*
* Converts floating point values from @p in_out using the following rules:
* Convert -NaN -> NaN
* Convert -0.0 -> 0.0
*
* @param stream CUDA stream used for device memory operations and kernel launches.
* @param mr Device memory resource used to allocate the returned column's device memory.
*/
std::unique_ptr<column> normalize_nans_and_zeros(column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::normalize_nans_and_zeros(input, stream, mr);
}
/**
* @brief Makes all Nans and zeroes positive.
*
* Converts floating point values from @p in_out using the following rules:
* Convert -NaN -> NaN
* Convert -0.0 -> 0.0
*
* @throws cudf::logic_error if column does not have floating point data type.
* @param[in, out] in_out mutable_column_view representing input data. data is processed in-place
*/
void normalize_nans_and_zeros(mutable_column_view& in_out, rmm::cuda_stream_view stream)
{
CUDF_FUNC_RANGE();
detail::normalize_nans_and_zeros(in_out, cudf::get_default_stream());
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/replace/replace.cu
|
/*
* Copyright 2018 BlazingDB, Inc.
* Copyright 2018 Cristhian Alberto Gonzales Castillo <[email protected]>
* Copyright 2018 Alexander Ocsa <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/column/column_view.hpp>
#include <cudf/detail/concatenate.hpp>
#include <cudf/detail/copy.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/replace.hpp>
#include <cudf/detail/utilities/cuda.cuh>
#include <cudf/dictionary/detail/update_keys.hpp>
#include <cudf/dictionary/dictionary_column_view.hpp>
#include <cudf/dictionary/dictionary_factories.hpp>
#include <cudf/replace.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_scalar.hpp>
#include <thrust/distance.h>
#include <thrust/execution_policy.h>
#include <thrust/find.h>
#include <thrust/pair.h>
#include <thrust/tuple.h>
namespace { // anonymous
static constexpr int BLOCK_SIZE = 256;
// return the new_value for output column at index `idx`
template <class T, bool replacement_has_nulls>
__device__ auto get_new_value(cudf::size_type idx,
T const* __restrict__ input_data,
T const* __restrict__ values_to_replace_begin,
T const* __restrict__ values_to_replace_end,
T const* __restrict__ d_replacement_values,
cudf::bitmask_type const* __restrict__ replacement_valid)
{
auto found_ptr =
thrust::find(thrust::seq, values_to_replace_begin, values_to_replace_end, input_data[idx]);
T new_value{};
bool output_is_valid{true};
if (found_ptr != values_to_replace_end) {
auto d = thrust::distance(values_to_replace_begin, found_ptr);
new_value = d_replacement_values[d];
if (replacement_has_nulls) { output_is_valid = cudf::bit_is_set(replacement_valid, d); }
} else {
new_value = input_data[idx];
}
return thrust::make_pair(new_value, output_is_valid);
}
__device__ int get_new_string_value(cudf::size_type idx,
cudf::column_device_view& input,
cudf::column_device_view& values_to_replace,
cudf::column_device_view&)
{
cudf::string_view input_string = input.element<cudf::string_view>(idx);
int match = -1;
for (int i = 0; i < values_to_replace.size(); i++) {
cudf::string_view value_string = values_to_replace.element<cudf::string_view>(i);
if (input_string == value_string) {
match = i;
break;
}
}
return match;
}
/**
* @brief Kernel which does the first pass of strings replace.
*
* It computes the output null_mask, null_count, and the offsets.
*
* @param input The input column to replace strings in.
* @param values_to_replace The string values to replace.
* @param replacement The replacement values.
* @param offsets The column which will contain the offsets of the new string column
* @param indices Temporary column used to store the replacement indices
* @param output_valid The output null_mask
* @param output_valid_count The output valid count
*/
template <bool input_has_nulls, bool replacement_has_nulls>
__global__ void replace_strings_first_pass(cudf::column_device_view input,
cudf::column_device_view values_to_replace,
cudf::column_device_view replacement,
cudf::mutable_column_device_view offsets,
cudf::mutable_column_device_view indices,
cudf::bitmask_type* output_valid,
cudf::size_type* __restrict__ output_valid_count)
{
cudf::size_type nrows = input.size();
auto tid = cudf::detail::grid_1d::global_thread_id();
auto const stride = cudf::detail::grid_1d::grid_stride();
uint32_t active_mask = 0xffff'ffffu;
active_mask = __ballot_sync(active_mask, tid < nrows);
auto const lane_id{threadIdx.x % cudf::detail::warp_size};
uint32_t valid_sum{0};
while (tid < nrows) {
auto const idx = static_cast<cudf::size_type>(tid);
bool input_is_valid = true;
if (input_has_nulls) input_is_valid = input.is_valid_nocheck(idx);
bool output_is_valid = input_is_valid;
if (input_is_valid) {
int result = get_new_string_value(idx, input, values_to_replace, replacement);
cudf::string_view output = (result == -1) ? input.element<cudf::string_view>(idx)
: replacement.element<cudf::string_view>(result);
offsets.data<cudf::size_type>()[idx] = output.size_bytes();
indices.data<cudf::size_type>()[idx] = result;
if (replacement_has_nulls && result != -1) {
output_is_valid = replacement.is_valid_nocheck(result);
}
} else {
offsets.data<cudf::size_type>()[idx] = 0;
indices.data<cudf::size_type>()[idx] = -1;
}
uint32_t bitmask = __ballot_sync(active_mask, output_is_valid);
if (0 == lane_id) {
output_valid[cudf::word_index(idx)] = bitmask;
valid_sum += __popc(bitmask);
}
tid += stride;
active_mask = __ballot_sync(active_mask, tid < nrows);
}
// Compute total valid count for this block and add it to global count
uint32_t block_valid_count = cudf::detail::single_lane_block_sum_reduce<BLOCK_SIZE, 0>(valid_sum);
// one thread computes and adds to output_valid_count
if (threadIdx.x == 0) { atomicAdd(output_valid_count, block_valid_count); }
}
/**
* @brief Kernel which does the second pass of strings replace.
*
* It copies the string data needed from input and replacement into the new strings column chars
* column.
*
* @param input The input column
* @param replacement The replacement values
* @param offsets The offsets column of the new strings column
* @param strings The chars column of the new strings column
* @param indices Temporary column used to store the replacement indices.
*/
template <bool input_has_nulls, bool replacement_has_nulls>
__global__ void replace_strings_second_pass(cudf::column_device_view input,
cudf::column_device_view replacement,
cudf::mutable_column_device_view offsets,
cudf::mutable_column_device_view strings,
cudf::mutable_column_device_view indices)
{
cudf::size_type nrows = input.size();
auto tid = cudf::detail::grid_1d::global_thread_id();
auto const stride = cudf::detail::grid_1d::grid_stride();
while (tid < nrows) {
auto const idx = static_cast<cudf::size_type>(tid);
auto const replace_idx = indices.element<cudf::size_type>(idx);
bool output_is_valid = true;
bool input_is_valid = true;
if (input_has_nulls) {
input_is_valid = input.is_valid_nocheck(idx);
output_is_valid = input_is_valid;
}
if (replacement_has_nulls && replace_idx != -1) {
output_is_valid = replacement.is_valid_nocheck(replace_idx);
}
if (output_is_valid) {
cudf::string_view output = (replace_idx == -1)
? input.element<cudf::string_view>(idx)
: replacement.element<cudf::string_view>(replace_idx);
std::memcpy(strings.data<char>() + offsets.data<cudf::size_type>()[idx],
output.data(),
output.size_bytes());
}
tid += stride;
}
}
/**
* @brief Kernel that replaces elements from `output_data` given the following
* rule: replace all `values_to_replace[i]` in [values_to_replace_begin`,
* `values_to_replace_end`) present in `output_data` with `d_replacement_values[i]`.
*
* @tparam input_has_nulls `true` if output column has valid mask, `false` otherwise
* @tparam replacement_has_nulls `true` if replacement_values column has valid mask, `false`
* otherwise The input_has_nulls and replacement_has_nulls template parameters allows us to
* specialize this kernel for the different scenario for performance without writing different
* kernel.
*
* @param[in] input_data Device array with the data to be modified
* @param[in] input_valid Valid mask associated with input_data
* @param[out] output_data Device array to store the data from input_data
* @param[out] output_valid Valid mask associated with output_data
* @param[out] output_valid_count #valid in output column
* @param[in] nrows # rows in `output_data`
* @param[in] values_to_replace_begin Device pointer to the beginning of the sequence
* of old values to be replaced
* @param[in] values_to_replace_end Device pointer to the end of the sequence
* of old values to be replaced
* @param[in] d_replacement_values Device array with the new values
* @param[in] replacement_valid Valid mask associated with d_replacement_values
*/
template <class T, bool input_has_nulls, bool replacement_has_nulls>
__global__ void replace_kernel(cudf::column_device_view input,
cudf::mutable_column_device_view output,
cudf::size_type* __restrict__ output_valid_count,
cudf::size_type nrows,
cudf::column_device_view values_to_replace,
cudf::column_device_view replacement)
{
T* __restrict__ output_data = output.data<T>();
auto tid = cudf::detail::grid_1d::global_thread_id();
auto const stride = cudf::detail::grid_1d::grid_stride();
uint32_t active_mask = 0xffff'ffffu;
active_mask = __ballot_sync(active_mask, tid < nrows);
auto const lane_id{threadIdx.x % cudf::detail::warp_size};
uint32_t valid_sum{0};
while (tid < nrows) {
auto const idx = static_cast<cudf::size_type>(tid);
bool output_is_valid{true};
bool input_is_valid{true};
if (input_has_nulls) {
input_is_valid = input.is_valid_nocheck(idx);
output_is_valid = input_is_valid;
}
if (input_is_valid)
thrust::tie(output_data[idx], output_is_valid) = get_new_value<T, replacement_has_nulls>(
idx,
input.data<T>(),
values_to_replace.data<T>(),
values_to_replace.data<T>() + values_to_replace.size(),
replacement.data<T>(),
replacement.null_mask());
/* output valid counts calculations*/
if (input_has_nulls or replacement_has_nulls) {
uint32_t bitmask = __ballot_sync(active_mask, output_is_valid);
if (0 == lane_id) {
output.set_mask_word(cudf::word_index(idx), bitmask);
valid_sum += __popc(bitmask);
}
}
tid += stride;
active_mask = __ballot_sync(active_mask, tid < nrows);
}
if (input_has_nulls or replacement_has_nulls) {
// Compute total valid count for this block and add it to global count
uint32_t block_valid_count =
cudf::detail::single_lane_block_sum_reduce<BLOCK_SIZE, 0>(valid_sum);
// one thread computes and adds to output_valid_count
if (threadIdx.x == 0) { atomicAdd(output_valid_count, block_valid_count); }
}
}
/**
* @brief Functor called by the `type_dispatcher` in order to invoke and instantiate
* `replace_kernel` with the appropriate data types.
*/
struct replace_kernel_forwarder {
template <typename col_type, std::enable_if_t<cudf::is_fixed_width<col_type>()>* = nullptr>
std::unique_ptr<cudf::column> operator()(cudf::column_view const& input_col,
cudf::column_view const& values_to_replace,
cudf::column_view const& replacement_values,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
rmm::device_scalar<cudf::size_type> valid_counter(0, stream);
cudf::size_type* valid_count = valid_counter.data();
auto replace = [&] {
if (input_col.has_nulls())
return replacement_values.has_nulls() ? replace_kernel<col_type, true, true>
: replace_kernel<col_type, true, false>;
else
return replacement_values.has_nulls() ? replace_kernel<col_type, false, true>
: replace_kernel<col_type, false, false>;
}();
auto output = [&] {
auto const mask_allocation_policy = input_col.has_nulls() || replacement_values.has_nulls()
? cudf::mask_allocation_policy::ALWAYS
: cudf::mask_allocation_policy::NEVER;
return cudf::detail::allocate_like(
input_col, input_col.size(), mask_allocation_policy, stream, mr);
}();
auto output_view = output->mutable_view();
auto grid = cudf::detail::grid_1d{output_view.size(), BLOCK_SIZE, 1};
auto device_in = cudf::column_device_view::create(input_col, stream);
auto device_out = cudf::mutable_column_device_view::create(output_view, stream);
auto device_values_to_replace = cudf::column_device_view::create(values_to_replace, stream);
auto device_replacement_values = cudf::column_device_view::create(replacement_values, stream);
replace<<<grid.num_blocks, BLOCK_SIZE, 0, stream.value()>>>(*device_in,
*device_out,
valid_count,
output_view.size(),
*device_values_to_replace,
*device_replacement_values);
if (output_view.nullable()) {
output->set_null_count(output->size() - valid_counter.value(stream));
}
return output;
}
template <typename col_type, std::enable_if_t<not cudf::is_fixed_width<col_type>()>* = nullptr>
std::unique_ptr<cudf::column> operator()(cudf::column_view const&,
cudf::column_view const&,
cudf::column_view const&,
rmm::cuda_stream_view,
rmm::mr::device_memory_resource*)
{
CUDF_FAIL("No specialization exists for this type");
}
};
template <>
std::unique_ptr<cudf::column> replace_kernel_forwarder::operator()<cudf::string_view>(
cudf::column_view const& input_col,
cudf::column_view const& values_to_replace,
cudf::column_view const& replacement_values,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
rmm::device_scalar<cudf::size_type> valid_counter(0, stream);
cudf::size_type* valid_count = valid_counter.data();
auto replace_first = replace_strings_first_pass<true, false>;
auto replace_second = replace_strings_second_pass<true, false>;
if (input_col.has_nulls()) {
if (replacement_values.has_nulls()) {
replace_first = replace_strings_first_pass<true, true>;
replace_second = replace_strings_second_pass<true, true>;
}
} else {
if (replacement_values.has_nulls()) {
replace_first = replace_strings_first_pass<false, true>;
replace_second = replace_strings_second_pass<false, true>;
} else {
replace_first = replace_strings_first_pass<false, false>;
replace_second = replace_strings_second_pass<false, false>;
}
}
// Create new offsets column to use in kernel
std::unique_ptr<cudf::column> sizes =
cudf::make_numeric_column(cudf::data_type{cudf::type_to_id<cudf::size_type>()},
input_col.size(),
cudf::mask_state::UNALLOCATED,
stream);
std::unique_ptr<cudf::column> indices =
cudf::make_numeric_column(cudf::data_type{cudf::type_to_id<cudf::size_type>()},
input_col.size(),
cudf::mask_state::UNALLOCATED,
stream);
auto sizes_view = sizes->mutable_view();
auto indices_view = indices->mutable_view();
auto device_in = cudf::column_device_view::create(input_col, stream);
auto device_values_to_replace = cudf::column_device_view::create(values_to_replace, stream);
auto device_replacement = cudf::column_device_view::create(replacement_values, stream);
auto device_sizes = cudf::mutable_column_device_view::create(sizes_view, stream);
auto device_indices = cudf::mutable_column_device_view::create(indices_view, stream);
rmm::device_buffer valid_bits =
cudf::detail::create_null_mask(input_col.size(), cudf::mask_state::UNINITIALIZED, stream, mr);
// Call first pass kernel to get sizes in offsets
cudf::detail::grid_1d grid{input_col.size(), BLOCK_SIZE, 1};
replace_first<<<grid.num_blocks, BLOCK_SIZE, 0, stream.value()>>>(
*device_in,
*device_values_to_replace,
*device_replacement,
*device_sizes,
*device_indices,
reinterpret_cast<cudf::bitmask_type*>(valid_bits.data()),
valid_count);
auto [offsets, bytes] = cudf::detail::make_offsets_child_column(
sizes_view.begin<cudf::size_type>(), sizes_view.end<cudf::size_type>(), stream, mr);
auto offsets_view = offsets->mutable_view();
auto device_offsets = cudf::mutable_column_device_view::create(offsets_view, stream);
// Allocate chars array and output null mask
cudf::size_type null_count = input_col.size() - valid_counter.value(stream);
std::unique_ptr<cudf::column> output_chars =
cudf::strings::detail::create_chars_child_column(bytes, stream, mr);
auto output_chars_view = output_chars->mutable_view();
auto device_chars = cudf::mutable_column_device_view::create(output_chars_view, stream);
replace_second<<<grid.num_blocks, BLOCK_SIZE, 0, stream.value()>>>(
*device_in, *device_replacement, *device_offsets, *device_chars, *device_indices);
return cudf::make_strings_column(input_col.size(),
std::move(offsets),
std::move(output_chars),
null_count,
std::move(valid_bits));
}
template <>
std::unique_ptr<cudf::column> replace_kernel_forwarder::operator()<cudf::dictionary32>(
cudf::column_view const& input_col,
cudf::column_view const& values_to_replace,
cudf::column_view const& replacement_values,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto input = cudf::dictionary_column_view(input_col);
auto values = cudf::dictionary_column_view(values_to_replace);
auto replacements = cudf::dictionary_column_view(replacement_values);
auto matched_input = [&] {
auto new_keys = cudf::detail::concatenate(
std::vector<cudf::column_view>({values.keys(), replacements.keys()}),
stream,
rmm::mr::get_current_device_resource());
return cudf::dictionary::detail::add_keys(input, new_keys->view(), stream, mr);
}();
auto matched_view = cudf::dictionary_column_view(matched_input->view());
auto matched_values = cudf::dictionary::detail::set_keys(
values, matched_view.keys(), stream, rmm::mr::get_current_device_resource());
auto matched_replacements = cudf::dictionary::detail::set_keys(
replacements, matched_view.keys(), stream, rmm::mr::get_current_device_resource());
auto indices_type = matched_view.indices().type();
auto new_indices = cudf::type_dispatcher<cudf::dispatch_storage_type>(
indices_type,
replace_kernel_forwarder{},
matched_view.get_indices_annotated(),
cudf::dictionary_column_view(matched_values->view()).indices(),
cudf::dictionary_column_view(matched_replacements->view()).get_indices_annotated(),
stream,
mr);
auto null_count = new_indices->null_count();
auto contents = new_indices->release();
auto indices_column = std::make_unique<cudf::column>(
indices_type, input.size(), std::move(*(contents.data.release())), rmm::device_buffer{}, 0);
std::unique_ptr<cudf::column> keys_column(std::move(matched_input->release().children.back()));
return cudf::make_dictionary_column(std::move(keys_column),
std::move(indices_column),
std::move(*(contents.null_mask.release())),
null_count);
}
} // end anonymous namespace
namespace cudf {
namespace detail {
std::unique_ptr<cudf::column> find_and_replace_all(cudf::column_view const& input_col,
cudf::column_view const& values_to_replace,
cudf::column_view const& replacement_values,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(values_to_replace.size() == replacement_values.size(),
"values_to_replace and replacement_values size mismatch.");
CUDF_EXPECTS(
input_col.type() == values_to_replace.type() && input_col.type() == replacement_values.type(),
"Columns type mismatch");
CUDF_EXPECTS(not values_to_replace.has_nulls(), "values_to_replace must not have nulls");
if (input_col.is_empty() or values_to_replace.is_empty() or replacement_values.is_empty()) {
return std::make_unique<cudf::column>(input_col, stream, mr);
}
return cudf::type_dispatcher<dispatch_storage_type>(input_col.type(),
replace_kernel_forwarder{},
input_col,
values_to_replace,
replacement_values,
stream,
mr);
}
} // namespace detail
/**
* @brief Replace elements from `input_col` according to the mapping `values_to_replace` to
* `replacement_values`, that is, replace all `values_to_replace[i]` present in `input_col`
* with `replacement_values[i]`.
*
* @param[in] input_col column_view of the data to be modified
* @param[in] values_to_replace column_view of the old values to be replaced
* @param[in] replacement_values column_view of the new values
*
* @returns output cudf::column with the modified data
*/
std::unique_ptr<cudf::column> find_and_replace_all(cudf::column_view const& input_col,
cudf::column_view const& values_to_replace,
cudf::column_view const& replacement_values,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return detail::find_and_replace_all(input_col, values_to_replace, replacement_values, stream, mr);
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/replace/nulls.cu
|
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/column/column_view.hpp>
#include <cudf/copying.hpp>
#include <cudf/detail/copy.hpp>
#include <cudf/detail/gather.hpp>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/replace.hpp>
#include <cudf/detail/replace/nulls.cuh>
#include <cudf/detail/utilities/cuda.cuh>
#include <cudf/dictionary/detail/replace.hpp>
#include <cudf/dictionary/dictionary_column_view.hpp>
#include <cudf/null_mask.hpp>
#include <cudf/replace.hpp>
#include <cudf/scalar/scalar.hpp>
#include <cudf/strings/detail/replace.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf/utilities/traits.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <thrust/functional.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/discard_iterator.h>
#include <thrust/iterator/reverse_iterator.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/scan.h>
#include <thrust/transform.h>
#include <thrust/tuple.h>
namespace { // anonymous
static constexpr int BLOCK_SIZE = 256;
template <int phase, bool replacement_has_nulls>
__global__ void replace_nulls_strings(cudf::column_device_view input,
cudf::column_device_view replacement,
cudf::bitmask_type* output_valid,
cudf::size_type* offsets,
char* chars,
cudf::size_type* valid_counter)
{
cudf::size_type nrows = input.size();
auto i = cudf::detail::grid_1d::global_thread_id();
auto const stride = cudf::detail::grid_1d::grid_stride();
uint32_t active_mask = 0xffff'ffff;
active_mask = __ballot_sync(active_mask, i < nrows);
auto const lane_id{threadIdx.x % cudf::detail::warp_size};
uint32_t valid_sum{0};
while (i < nrows) {
bool input_is_valid = input.is_valid_nocheck(i);
bool output_is_valid = true;
if (replacement_has_nulls && !input_is_valid) {
output_is_valid = replacement.is_valid_nocheck(i);
}
cudf::string_view out;
if (input_is_valid) {
out = input.element<cudf::string_view>(i);
} else if (output_is_valid) {
out = replacement.element<cudf::string_view>(i);
}
bool nonzero_output = (input_is_valid || output_is_valid);
if (phase == 0) {
offsets[i] = nonzero_output ? out.size_bytes() : 0;
uint32_t bitmask = __ballot_sync(active_mask, output_is_valid);
if (0 == lane_id) {
output_valid[cudf::word_index(i)] = bitmask;
valid_sum += __popc(bitmask);
}
} else if (phase == 1) {
if (nonzero_output) std::memcpy(chars + offsets[i], out.data(), out.size_bytes());
}
i += stride;
active_mask = __ballot_sync(active_mask, i < nrows);
}
// Compute total valid count for this block and add it to global count
uint32_t block_valid_count = cudf::detail::single_lane_block_sum_reduce<BLOCK_SIZE, 0>(valid_sum);
// one thread computes and adds to output_valid_count
if (threadIdx.x == 0) { atomicAdd(valid_counter, block_valid_count); }
}
template <typename Type, bool replacement_has_nulls>
__global__ void replace_nulls(cudf::column_device_view input,
cudf::column_device_view replacement,
cudf::mutable_column_device_view output,
cudf::size_type* output_valid_count)
{
cudf::size_type nrows = input.size();
auto i = cudf::detail::grid_1d::global_thread_id();
auto const stride = cudf::detail::grid_1d::grid_stride();
uint32_t active_mask = 0xffff'ffff;
active_mask = __ballot_sync(active_mask, i < nrows);
auto const lane_id{threadIdx.x % cudf::detail::warp_size};
uint32_t valid_sum{0};
while (i < nrows) {
bool input_is_valid = input.is_valid_nocheck(i);
bool output_is_valid = true;
if (input_is_valid) {
output.data<Type>()[i] = input.element<Type>(i);
} else {
if (replacement_has_nulls) { output_is_valid = replacement.is_valid_nocheck(i); }
output.data<Type>()[i] = replacement.element<Type>(i);
}
/* output valid counts calculations*/
if (replacement_has_nulls) {
uint32_t bitmask = __ballot_sync(active_mask, output_is_valid);
if (0 == lane_id) {
output.set_mask_word(cudf::word_index(i), bitmask);
valid_sum += __popc(bitmask);
}
}
i += stride;
active_mask = __ballot_sync(active_mask, i < nrows);
}
if (replacement_has_nulls) {
// Compute total valid count for this block and add it to global count
uint32_t block_valid_count =
cudf::detail::single_lane_block_sum_reduce<BLOCK_SIZE, 0>(valid_sum);
// one thread computes and adds to output_valid_count
if (threadIdx.x == 0) { atomicAdd(output_valid_count, block_valid_count); }
}
}
/**
* @brief Functor called by the `type_dispatcher` in order to invoke and instantiate
* `replace_nulls` with the appropriate data types.
*/
struct replace_nulls_column_kernel_forwarder {
template <typename col_type, CUDF_ENABLE_IF(cudf::is_rep_layout_compatible<col_type>())>
std::unique_ptr<cudf::column> operator()(cudf::column_view const& input,
cudf::column_view const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
cudf::size_type nrows = input.size();
cudf::detail::grid_1d grid{nrows, BLOCK_SIZE};
auto output =
cudf::detail::allocate_like(input,
input.size(),
replacement.has_nulls() ? cudf::mask_allocation_policy::ALWAYS
: cudf::mask_allocation_policy::NEVER,
stream,
mr);
auto output_view = output->mutable_view();
auto replace = replace_nulls<col_type, false>;
if (output_view.nullable()) replace = replace_nulls<col_type, true>;
auto device_in = cudf::column_device_view::create(input, stream);
auto device_out = cudf::mutable_column_device_view::create(output_view, stream);
auto device_replacement = cudf::column_device_view::create(replacement, stream);
rmm::device_scalar<cudf::size_type> valid_counter(0, stream);
cudf::size_type* valid_count = valid_counter.data();
replace<<<grid.num_blocks, BLOCK_SIZE, 0, stream.value()>>>(
*device_in, *device_replacement, *device_out, valid_count);
if (output_view.nullable()) {
output->set_null_count(output->size() - valid_counter.value(stream));
}
return output;
}
template <typename col_type, CUDF_ENABLE_IF(not cudf::is_rep_layout_compatible<col_type>())>
std::unique_ptr<cudf::column> operator()(cudf::column_view const&,
cudf::column_view const&,
rmm::cuda_stream_view,
rmm::mr::device_memory_resource*)
{
CUDF_FAIL("No specialization exists for the given type.");
}
};
template <>
std::unique_ptr<cudf::column> replace_nulls_column_kernel_forwarder::operator()<cudf::string_view>(
cudf::column_view const& input,
cudf::column_view const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
rmm::device_scalar<cudf::size_type> valid_counter(0, stream);
cudf::size_type* valid_count = valid_counter.data();
auto replace_first = replace_nulls_strings<0, false>;
auto replace_second = replace_nulls_strings<1, false>;
if (replacement.has_nulls()) {
replace_first = replace_nulls_strings<0, true>;
replace_second = replace_nulls_strings<1, true>;
}
// Create new offsets column to use in kernel
std::unique_ptr<cudf::column> sizes = cudf::make_numeric_column(
cudf::data_type(cudf::type_id::INT32), input.size(), cudf::mask_state::UNALLOCATED, stream);
auto sizes_view = sizes->mutable_view();
auto device_in = cudf::column_device_view::create(input, stream);
auto device_replacement = cudf::column_device_view::create(replacement, stream);
rmm::device_buffer valid_bits =
cudf::detail::create_null_mask(input.size(), cudf::mask_state::UNINITIALIZED, stream, mr);
// Call first pass kernel to get sizes in offsets
cudf::detail::grid_1d grid{input.size(), BLOCK_SIZE, 1};
replace_first<<<grid.num_blocks, BLOCK_SIZE, 0, stream.value()>>>(
*device_in,
*device_replacement,
reinterpret_cast<cudf::bitmask_type*>(valid_bits.data()),
sizes_view.begin<cudf::size_type>(),
nullptr,
valid_count);
auto [offsets, bytes] = cudf::detail::make_offsets_child_column(
sizes_view.begin<int32_t>(), sizes_view.end<int32_t>(), stream, mr);
auto offsets_view = offsets->mutable_view();
// Allocate chars array and output null mask
std::unique_ptr<cudf::column> output_chars =
cudf::strings::detail::create_chars_child_column(bytes, stream, mr);
auto output_chars_view = output_chars->mutable_view();
replace_second<<<grid.num_blocks, BLOCK_SIZE, 0, stream.value()>>>(
*device_in,
*device_replacement,
reinterpret_cast<cudf::bitmask_type*>(valid_bits.data()),
offsets_view.begin<cudf::size_type>(),
output_chars_view.data<char>(),
valid_count);
return cudf::make_strings_column(input.size(),
std::move(offsets),
std::move(output_chars),
input.size() - valid_counter.value(stream),
std::move(valid_bits));
}
template <>
std::unique_ptr<cudf::column> replace_nulls_column_kernel_forwarder::operator()<cudf::dictionary32>(
cudf::column_view const& input,
cudf::column_view const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
cudf::dictionary_column_view dict_input(input);
cudf::dictionary_column_view dict_repl(replacement);
return cudf::dictionary::detail::replace_nulls(dict_input, dict_repl, stream, mr);
}
template <typename T>
struct replace_nulls_functor {
T const* value_it;
replace_nulls_functor(T const* _value_it) : value_it(_value_it) {}
__device__ T operator()(T input, bool is_valid) { return is_valid ? input : *value_it; }
};
/**
* @brief Functor called by the `type_dispatcher` in order to invoke and instantiate
* `replace_nulls` with the appropriate data types.
*/
struct replace_nulls_scalar_kernel_forwarder {
template <typename col_type, std::enable_if_t<cudf::is_fixed_width<col_type>()>* = nullptr>
std::unique_ptr<cudf::column> operator()(cudf::column_view const& input,
cudf::scalar const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(input.type() == replacement.type(), "Data type mismatch");
std::unique_ptr<cudf::column> output = cudf::detail::allocate_like(
input, input.size(), cudf::mask_allocation_policy::NEVER, stream, mr);
auto output_view = output->mutable_view();
using ScalarType = cudf::scalar_type_t<col_type>;
auto& s1 = static_cast<ScalarType const&>(replacement);
auto device_in = cudf::column_device_view::create(input, stream);
auto func = replace_nulls_functor<col_type>{s1.data()};
thrust::transform(rmm::exec_policy(stream),
input.data<col_type>(),
input.data<col_type>() + input.size(),
cudf::detail::make_validity_iterator(*device_in),
output_view.data<col_type>(),
func);
return output;
}
template <typename col_type, std::enable_if_t<not cudf::is_fixed_width<col_type>()>* = nullptr>
std::unique_ptr<cudf::column> operator()(cudf::column_view const&,
cudf::scalar const&,
rmm::cuda_stream_view,
rmm::mr::device_memory_resource*)
{
CUDF_FAIL("No specialization exists for the given type.");
}
};
template <>
std::unique_ptr<cudf::column> replace_nulls_scalar_kernel_forwarder::operator()<cudf::string_view>(
cudf::column_view const& input,
cudf::scalar const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(input.type() == replacement.type(), "Data type mismatch");
cudf::strings_column_view input_s(input);
cudf::string_scalar const& repl = static_cast<cudf::string_scalar const&>(replacement);
return cudf::strings::detail::replace_nulls(input_s, repl, stream, mr);
}
template <>
std::unique_ptr<cudf::column> replace_nulls_scalar_kernel_forwarder::operator()<cudf::dictionary32>(
cudf::column_view const& input,
cudf::scalar const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
cudf::dictionary_column_view dict_input(input);
return cudf::dictionary::detail::replace_nulls(dict_input, replacement, stream, mr);
}
/**
* @brief Function used by replace_nulls policy
*/
std::unique_ptr<cudf::column> replace_nulls_policy_impl(cudf::column_view const& input,
cudf::replace_policy const& replace_policy,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto device_in = cudf::column_device_view::create(input, stream);
auto index = thrust::make_counting_iterator<cudf::size_type>(0);
auto valid_it = cudf::detail::make_validity_iterator(*device_in);
auto in_begin = thrust::make_zip_iterator(thrust::make_tuple(index, valid_it));
rmm::device_uvector<cudf::size_type> gather_map(input.size(), stream);
auto gm_begin = thrust::make_zip_iterator(
thrust::make_tuple(gather_map.begin(), thrust::make_discard_iterator()));
auto func = cudf::detail::replace_policy_functor();
if (replace_policy == cudf::replace_policy::PRECEDING) {
thrust::inclusive_scan(
rmm::exec_policy(stream), in_begin, in_begin + input.size(), gm_begin, func);
} else {
auto in_rbegin = thrust::make_reverse_iterator(in_begin + input.size());
auto gm_rbegin = thrust::make_reverse_iterator(gm_begin + gather_map.size());
thrust::inclusive_scan(
rmm::exec_policy(stream), in_rbegin, in_rbegin + input.size(), gm_rbegin, func);
}
auto output = cudf::detail::gather(cudf::table_view({input}),
gather_map,
cudf::out_of_bounds_policy::DONT_CHECK,
cudf::detail::negative_index_policy::NOT_ALLOWED,
stream,
mr);
return std::move(output->release()[0]);
}
} // end anonymous namespace
namespace cudf {
namespace detail {
std::unique_ptr<cudf::column> replace_nulls(cudf::column_view const& input,
cudf::column_view const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(input.type() == replacement.type(), "Data type mismatch");
CUDF_EXPECTS(replacement.size() == input.size(), "Column size mismatch");
if (input.is_empty()) { return cudf::empty_like(input); }
if (!input.has_nulls()) { return std::make_unique<cudf::column>(input, stream, mr); }
return cudf::type_dispatcher<dispatch_storage_type>(
input.type(), replace_nulls_column_kernel_forwarder{}, input, replacement, stream, mr);
}
std::unique_ptr<cudf::column> replace_nulls(cudf::column_view const& input,
cudf::scalar const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) { return cudf::empty_like(input); }
if (!input.has_nulls() || !replacement.is_valid(stream)) {
return std::make_unique<cudf::column>(input, stream, mr);
}
return cudf::type_dispatcher<dispatch_storage_type>(
input.type(), replace_nulls_scalar_kernel_forwarder{}, input, replacement, stream, mr);
}
std::unique_ptr<cudf::column> replace_nulls(cudf::column_view const& input,
cudf::replace_policy const& replace_policy,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) { return cudf::empty_like(input); }
if (!input.has_nulls()) { return std::make_unique<cudf::column>(input, stream, mr); }
return replace_nulls_policy_impl(input, replace_policy, stream, mr);
}
} // namespace detail
std::unique_ptr<cudf::column> replace_nulls(cudf::column_view const& input,
cudf::column_view const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace_nulls(input, replacement, stream, mr);
}
std::unique_ptr<cudf::column> replace_nulls(cudf::column_view const& input,
cudf::scalar const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace_nulls(input, replacement, stream, mr);
}
std::unique_ptr<cudf::column> replace_nulls(column_view const& input,
replace_policy const& replace_policy,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace_nulls(input, replace_policy, stream, mr);
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/replace/clamp.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/copy.hpp>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/dictionary/detail/search.hpp>
#include <cudf/dictionary/detail/update_keys.hpp>
#include <cudf/dictionary/dictionary_column_view.hpp>
#include <cudf/dictionary/dictionary_factories.hpp>
#include <cudf/replace.hpp>
#include <cudf/scalar/scalar.hpp>
#include <cudf/scalar/scalar_device_view.cuh>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/iterator/zip_iterator.h>
#include <thrust/transform.h>
#include <thrust/tuple.h>
namespace cudf {
namespace detail {
namespace {
template <typename Transformer>
std::pair<std::unique_ptr<column>, std::unique_ptr<column>> form_offsets_and_char_column(
cudf::column_device_view input,
size_type,
Transformer offsets_transformer,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
std::unique_ptr<column> offsets_column{};
auto strings_count = input.size();
size_type bytes = 0;
if (input.nullable()) {
auto input_begin =
cudf::detail::make_null_replacement_iterator<string_view>(input, string_view{});
auto offsets_transformer_itr =
thrust::make_transform_iterator(input_begin, offsets_transformer);
std::tie(offsets_column, bytes) = cudf::detail::make_offsets_child_column(
offsets_transformer_itr, offsets_transformer_itr + strings_count, stream, mr);
} else {
auto offsets_transformer_itr =
thrust::make_transform_iterator(input.begin<string_view>(), offsets_transformer);
std::tie(offsets_column, bytes) = cudf::detail::make_offsets_child_column(
offsets_transformer_itr, offsets_transformer_itr + strings_count, stream, mr);
}
// build chars column
auto chars_column = cudf::strings::detail::create_chars_child_column(bytes, stream, mr);
return std::pair(std::move(offsets_column), std::move(chars_column));
}
template <typename OptionalScalarIterator, typename ReplaceScalarIterator>
std::unique_ptr<cudf::column> clamp_string_column(strings_column_view const& input,
OptionalScalarIterator lo_itr,
ReplaceScalarIterator lo_replace_itr,
OptionalScalarIterator hi_itr,
ReplaceScalarIterator hi_replace_itr,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto input_device_column = column_device_view::create(input.parent(), stream);
auto d_input = *input_device_column;
size_type null_count = input.null_count();
// build offset column
auto offsets_transformer = [lo_itr, hi_itr, lo_replace_itr, hi_replace_itr] __device__(
string_view element, bool is_valid = true) {
const auto d_lo = (*lo_itr).value_or(element);
const auto d_hi = (*hi_itr).value_or(element);
const auto d_lo_replace = *(*lo_replace_itr);
const auto d_hi_replace = *(*hi_replace_itr);
size_type bytes = 0;
if (is_valid) {
if (element < d_lo) {
bytes = d_lo_replace.size_bytes();
} else if (d_hi < element) {
bytes = d_hi_replace.size_bytes();
} else {
bytes = element.size_bytes();
}
}
return bytes;
};
auto [offsets_column, chars_column] =
form_offsets_and_char_column(d_input, null_count, offsets_transformer, stream, mr);
auto d_offsets = offsets_column->view().template data<size_type>();
auto d_chars = chars_column->mutable_view().template data<char>();
// fill in chars
auto copy_transformer =
[d_input, lo_itr, hi_itr, lo_replace_itr, hi_replace_itr, d_offsets, d_chars] __device__(
size_type idx) {
if (d_input.is_null(idx)) { return; }
auto input_element = d_input.element<string_view>(idx);
const auto d_lo = (*lo_itr).value_or(input_element);
const auto d_hi = (*hi_itr).value_or(input_element);
const auto d_lo_replace = *(*lo_replace_itr);
const auto d_hi_replace = *(*hi_replace_itr);
if (input_element < d_lo) {
memcpy(d_chars + d_offsets[idx], d_lo_replace.data(), d_lo_replace.size_bytes());
} else if (d_hi < input_element) {
memcpy(d_chars + d_offsets[idx], d_hi_replace.data(), d_hi_replace.size_bytes());
} else {
memcpy(d_chars + d_offsets[idx], input_element.data(), input_element.size_bytes());
}
};
thrust::for_each_n(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
input.size(),
copy_transformer);
return make_strings_column(input.size(),
std::move(offsets_column),
std::move(chars_column),
input.null_count(),
std::move(cudf::detail::copy_bitmask(input.parent(), stream, mr)));
}
template <typename T, typename OptionalScalarIterator, typename ReplaceScalarIterator>
std::enable_if_t<cudf::is_fixed_width<T>(), std::unique_ptr<cudf::column>> clamper(
column_view const& input,
OptionalScalarIterator lo_itr,
ReplaceScalarIterator lo_replace_itr,
OptionalScalarIterator hi_itr,
ReplaceScalarIterator hi_replace_itr,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto output =
detail::allocate_like(input, input.size(), mask_allocation_policy::NEVER, stream, mr);
// mask will not change
if (input.nullable()) {
output->set_null_mask(cudf::detail::copy_bitmask(input, stream, mr), input.null_count());
}
auto output_device_view =
cudf::mutable_column_device_view::create(output->mutable_view(), stream);
auto input_device_view = cudf::column_device_view::create(input, stream);
auto scalar_zip_itr =
thrust::make_zip_iterator(thrust::make_tuple(lo_itr, lo_replace_itr, hi_itr, hi_replace_itr));
auto trans = [] __device__(auto element_optional, auto scalar_tuple) {
if (element_optional.has_value()) {
auto lo_optional = thrust::get<0>(scalar_tuple);
auto hi_optional = thrust::get<2>(scalar_tuple);
if (lo_optional.has_value() and (*element_optional < *lo_optional)) {
return *(thrust::get<1>(scalar_tuple));
} else if (hi_optional.has_value() and (*element_optional > *hi_optional)) {
return *(thrust::get<3>(scalar_tuple));
}
}
return *element_optional;
};
auto input_pair_iterator =
make_optional_iterator<T>(*input_device_view, nullate::DYNAMIC{input.has_nulls()});
thrust::transform(rmm::exec_policy(stream),
input_pair_iterator,
input_pair_iterator + input.size(),
scalar_zip_itr,
output_device_view->begin<T>(),
trans);
return output;
}
template <typename T, typename OptionalScalarIterator, typename ReplaceScalarIterator>
std::enable_if_t<std::is_same_v<T, string_view>, std::unique_ptr<cudf::column>> clamper(
column_view const& input,
OptionalScalarIterator lo_itr,
ReplaceScalarIterator lo_replace_itr,
OptionalScalarIterator hi_itr,
ReplaceScalarIterator hi_replace_itr,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return clamp_string_column(input, lo_itr, lo_replace_itr, hi_itr, hi_replace_itr, stream, mr);
}
} // namespace
template <typename T, typename OptionalScalarIterator, typename ReplaceScalarIterator>
std::unique_ptr<column> clamp(column_view const& input,
OptionalScalarIterator lo_itr,
ReplaceScalarIterator lo_replace_itr,
OptionalScalarIterator hi_itr,
ReplaceScalarIterator hi_replace_itr,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return clamper<T>(input, lo_itr, lo_replace_itr, hi_itr, hi_replace_itr, stream, mr);
}
struct dispatch_clamp {
template <typename T>
std::unique_ptr<column> operator()(column_view const& input,
scalar const& lo,
scalar const& lo_replace,
scalar const& hi,
scalar const& hi_replace,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(lo.type() == input.type(), "mismatching types of scalar and input");
auto lo_itr = make_optional_iterator<T>(lo, nullate::YES{});
auto hi_itr = make_optional_iterator<T>(hi, nullate::YES{});
auto lo_replace_itr = make_optional_iterator<T>(lo_replace, nullate::NO{});
auto hi_replace_itr = make_optional_iterator<T>(hi_replace, nullate::NO{});
return clamp<T>(input, lo_itr, lo_replace_itr, hi_itr, hi_replace_itr, stream, mr);
}
};
template <>
std::unique_ptr<column> dispatch_clamp::operator()<cudf::list_view>(
column_view const& input,
scalar const& lo,
scalar const& lo_replace,
scalar const& hi,
scalar const& hi_replace,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FAIL("clamp for list_view not supported");
}
template <>
std::unique_ptr<column> dispatch_clamp::operator()<struct_view>(column_view const& input,
scalar const& lo,
scalar const& lo_replace,
scalar const& hi,
scalar const& hi_replace,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FAIL("clamp for struct_view not supported");
}
template <>
std::unique_ptr<column> dispatch_clamp::operator()<cudf::dictionary32>(
column_view const& input,
scalar const& lo,
scalar const& lo_replace,
scalar const& hi,
scalar const& hi_replace,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// add lo_replace and hi_replace to keys
auto matched_column = [&] {
auto matched_view = dictionary_column_view(input);
std::unique_ptr<column> result = nullptr;
auto add_scalar_key = [&](scalar const& key, scalar const& key_replace) {
if (key.is_valid(stream)) {
result = dictionary::detail::add_keys(
matched_view, make_column_from_scalar(key_replace, 1, stream)->view(), stream, mr);
matched_view = dictionary_column_view(result->view());
}
};
add_scalar_key(lo, lo_replace);
add_scalar_key(hi, hi_replace);
return result;
}();
auto matched_view = dictionary_column_view(matched_column->view());
auto default_mr = rmm::mr::get_current_device_resource();
// get the indexes for lo_replace and for hi_replace
auto lo_replace_index =
dictionary::detail::get_index(matched_view, lo_replace, stream, default_mr);
auto hi_replace_index =
dictionary::detail::get_index(matched_view, hi_replace, stream, default_mr);
// get the closest indexes for lo and for hi
auto lo_index = dictionary::detail::get_insert_index(matched_view, lo, stream, default_mr);
auto hi_index = dictionary::detail::get_insert_index(matched_view, hi, stream, default_mr);
// call clamp with the scalar indexes and the matched indices
auto matched_indices = matched_view.get_indices_annotated();
auto new_indices = cudf::type_dispatcher<dispatch_storage_type>(matched_indices.type(),
dispatch_clamp{},
matched_indices,
*lo_index,
*lo_replace_index,
*hi_index,
*hi_replace_index,
stream,
mr);
auto const indices_type = new_indices->type();
auto const output_size = new_indices->size();
auto const null_count = new_indices->null_count();
auto contents = new_indices->release();
auto indices_column = std::make_unique<column>(indices_type,
static_cast<size_type>(output_size),
std::move(*(contents.data.release())),
rmm::device_buffer{},
0);
// take the keys from the matched column allocated using mr
std::unique_ptr<column> keys_column(std::move(matched_column->release().children.back()));
// create column with keys_column and indices_column
return make_dictionary_column(std::move(keys_column),
std::move(indices_column),
std::move(*(contents.null_mask.release())),
null_count);
}
/**
* @copydoc cudf::clamp(column_view const& input,
scalar const& lo,
scalar const& lo_replace,
scalar const& hi,
scalar const& hi_replace,
rmm::mr::device_memory_resource* mr);
*
* @param[in] stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<column> clamp(column_view const& input,
scalar const& lo,
scalar const& lo_replace,
scalar const& hi,
scalar const& hi_replace,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(lo.type() == hi.type(), "mismatching types of limit scalars");
CUDF_EXPECTS(lo_replace.type() == hi_replace.type(), "mismatching types of replace scalars");
CUDF_EXPECTS(lo.type() == lo_replace.type(), "mismatching types of limit and replace scalars");
if ((not lo.is_valid(stream) and not hi.is_valid(stream)) or (input.is_empty())) {
// There will be no change
return std::make_unique<column>(input, stream, mr);
}
if (lo.is_valid(stream)) {
CUDF_EXPECTS(lo_replace.is_valid(stream), "lo_replace can't be null if lo is not null");
}
if (hi.is_valid(stream)) {
CUDF_EXPECTS(hi_replace.is_valid(stream), "hi_replace can't be null if hi is not null");
}
return cudf::type_dispatcher<dispatch_storage_type>(
input.type(), dispatch_clamp{}, input, lo, lo_replace, hi, hi_replace, stream, mr);
}
} // namespace detail
// clamp input at lo and hi with lo_replace and hi_replace
std::unique_ptr<column> clamp(column_view const& input,
scalar const& lo,
scalar const& lo_replace,
scalar const& hi,
scalar const& hi_replace,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::clamp(input, lo, lo_replace, hi, hi_replace, stream, mr);
}
// clamp input at lo and hi
std::unique_ptr<column> clamp(column_view const& input,
scalar const& lo,
scalar const& hi,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::clamp(input, lo, lo, hi, hi, stream, mr);
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/padding.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/pad_impl.cuh>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/padding.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Base class for pad_fn and zfill_fn functors
*
* This handles the output size calculation while delegating the
* pad operation to Derived.
*
* @tparam Derived class uses the CRTP pattern to reuse code logic
* and must include a `pad(string_view,char*)` member function.
*/
template <typename Derived>
struct base_fn {
column_device_view const d_column;
size_type const width;
size_type const fill_char_size;
size_type* d_offsets{};
char* d_chars{};
base_fn(column_device_view const& d_column, size_type width, size_type fill_char_size)
: d_column(d_column), width(width), fill_char_size(fill_char_size)
{
}
__device__ void operator()(size_type idx) const
{
if (d_column.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto const d_str = d_column.element<string_view>(idx);
auto const& derived = static_cast<Derived const&>(*this);
if (d_chars) {
derived.pad(d_str, d_chars + d_offsets[idx]);
} else {
d_offsets[idx] = compute_padded_size(d_str, width, fill_char_size);
}
};
};
/**
* @brief Pads each string to specified width
*
* @tparam side Side of the string to pad
*/
template <side_type side>
struct pad_fn : base_fn<pad_fn<side>> {
using Base = base_fn<pad_fn<side>>;
cudf::char_utf8 const d_fill_char;
pad_fn(column_device_view const& d_column,
size_type width,
size_type fill_char_size,
char_utf8 fill_char)
: Base(d_column, width, fill_char_size), d_fill_char(fill_char)
{
}
__device__ void pad(string_view d_str, char* output) const
{
pad_impl<side>(d_str, Base::width, d_fill_char, output);
}
};
} // namespace
std::unique_ptr<column> pad(strings_column_view const& input,
size_type width,
side_type side,
std::string_view fill_char,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) return make_empty_column(type_id::STRING);
CUDF_EXPECTS(!fill_char.empty(), "fill_char parameter must not be empty");
auto d_fill_char = char_utf8{0};
auto const fill_char_size = to_char_utf8(fill_char.data(), d_fill_char);
auto d_strings = column_device_view::create(input.parent(), stream);
auto children = [&] {
if (side == side_type::LEFT) {
auto fn = pad_fn<side_type::LEFT>{*d_strings, width, fill_char_size, d_fill_char};
return make_strings_children(fn, input.size(), stream, mr);
} else if (side == side_type::RIGHT) {
auto fn = pad_fn<side_type::RIGHT>{*d_strings, width, fill_char_size, d_fill_char};
return make_strings_children(fn, input.size(), stream, mr);
}
auto fn = pad_fn<side_type::BOTH>{*d_strings, width, fill_char_size, d_fill_char};
return make_strings_children(fn, input.size(), stream, mr);
}();
return make_strings_column(input.size(),
std::move(children.first),
std::move(children.second),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
namespace {
/**
* @brief Zero-fill each string to specified width
*/
struct zfill_fn : base_fn<zfill_fn> {
zfill_fn(column_device_view const& d_column, size_type width) : base_fn(d_column, width, 1) {}
__device__ void pad(string_view d_str, char* output) const { zfill_impl(d_str, width, output); }
};
} // namespace
std::unique_ptr<column> zfill(strings_column_view const& input,
size_type width,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) return make_empty_column(type_id::STRING);
auto d_strings = column_device_view::create(input.parent(), stream);
auto children = make_strings_children(zfill_fn{*d_strings, width}, input.size(), stream, mr);
return make_strings_column(input.size(),
std::move(children.first),
std::move(children.second),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
} // namespace detail
// Public APIs
std::unique_ptr<column> pad(strings_column_view const& input,
size_type width,
side_type side,
std::string_view fill_char,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::pad(input, width, side, fill_char, stream, mr);
}
std::unique_ptr<column> zfill(strings_column_view const& input,
size_type width,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::zfill(input, width, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/slice.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/indexalator.cuh>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/scalar/scalar_device_view.cuh>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/slice.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Function logic for compute_substrings_from_fn API
*
* This computes the output size and resolves the substring
*/
template <typename IndexIterator>
struct substring_from_fn {
column_device_view const d_column;
IndexIterator const starts;
IndexIterator const stops;
__device__ string_view operator()(size_type idx) const
{
if (d_column.is_null(idx)) { return string_view{nullptr, 0}; }
auto const d_str = d_column.template element<string_view>(idx);
auto const length = d_str.length();
auto const start = std::max(starts[idx], 0);
if (start >= length) { return string_view{}; }
auto const stop = stops[idx];
auto const end = (((stop < 0) || (stop > length)) ? length : stop);
return start < end ? d_str.substr(start, end - start) : string_view{};
}
substring_from_fn(column_device_view const& d_column, IndexIterator starts, IndexIterator stops)
: d_column(d_column), starts(starts), stops(stops)
{
}
};
/**
* @brief Function logic for the substring API.
*
* This will perform a substring operation on each string
* using the provided start, stop, and step parameters.
*/
struct substring_fn {
column_device_view const d_column;
numeric_scalar_device_view<size_type> const d_start;
numeric_scalar_device_view<size_type> const d_stop;
numeric_scalar_device_view<size_type> const d_step;
int32_t* d_offsets{};
char* d_chars{};
__device__ void operator()(size_type idx)
{
if (d_column.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto const d_str = d_column.template element<string_view>(idx);
auto const length = d_str.length();
if (length == 0) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
size_type const step = d_step.is_valid() ? d_step.value() : 1;
auto const begin = [&] { // always inclusive
// when invalid, default depends on step
if (!d_start.is_valid()) return (step > 0) ? d_str.begin() : (d_str.end() - 1);
// normal positive position logic
auto start = d_start.value();
if (start >= 0) {
if (start < length) return d_str.begin() + start;
return d_str.end() + (step < 0 ? -1 : 0);
}
// handle negative position here
auto adjust = length + start;
if (adjust >= 0) return d_str.begin() + adjust;
return d_str.begin() + (step < 0 ? -1 : 0);
}();
auto const end = [&] { // always exclusive
// when invalid, default depends on step
if (!d_stop.is_valid()) return step > 0 ? d_str.end() : (d_str.begin() - 1);
// normal positive position logic
auto stop = d_stop.value();
if (stop >= 0) return (stop < length) ? (d_str.begin() + stop) : d_str.end();
// handle negative position here
auto adjust = length + stop;
return d_str.begin() + (adjust >= 0 ? adjust : -1);
}();
size_type bytes = 0;
char* d_buffer = d_chars ? d_chars + d_offsets[idx] : nullptr;
auto itr = begin;
while (step > 0 ? itr < end : end < itr) {
if (d_buffer) {
d_buffer += from_char_utf8(*itr, d_buffer);
} else {
bytes += bytes_in_char_utf8(*itr);
}
itr += step;
}
if (!d_chars) d_offsets[idx] = bytes;
}
};
/**
* @brief Common utility function for the slice_strings APIs
*
* It wraps calling the functors appropriately to build the output strings column.
*
* The input iterators may have unique position values per string in `d_column`.
* This can also be called with constant value iterators to handle special
* slice functions if possible.
*
* @tparam IndexIterator Iterator type for character position values
*
* @param d_column Input strings column to substring
* @param starts Start positions index iterator
* @param stops Stop positions index iterator
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate the returned column's device memory
*/
template <typename IndexIterator>
std::unique_ptr<column> compute_substrings_from_fn(column_device_view const& d_column,
IndexIterator starts,
IndexIterator stops,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto results = rmm::device_uvector<string_view>(d_column.size(), stream);
thrust::transform(rmm::exec_policy(stream),
thrust::counting_iterator<size_type>(0),
thrust::counting_iterator<size_type>(d_column.size()),
results.begin(),
substring_from_fn{d_column, starts, stops});
return make_strings_column(results, string_view{nullptr, 0}, stream, mr);
}
} // namespace
//
std::unique_ptr<column> slice_strings(strings_column_view const& strings,
numeric_scalar<size_type> const& start,
numeric_scalar<size_type> const& stop,
numeric_scalar<size_type> const& step,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (strings.is_empty()) return make_empty_column(type_id::STRING);
auto const step_valid = step.is_valid(stream);
auto const step_value = step_valid ? step.value(stream) : 0;
if (step_valid) { CUDF_EXPECTS(step_value != 0, "Step parameter must not be 0"); }
auto const d_column = column_device_view::create(strings.parent(), stream);
// optimization for (step==1 and start < stop) -- expect this to be most common
if (step_value == 1 and start.is_valid(stream) and stop.is_valid(stream)) {
auto const start_value = start.value(stream);
auto const stop_value = stop.value(stream);
// note that any negative values here must use the alternate function below
if ((start_value >= 0) && (start_value < stop_value)) {
// this is about 2x faster on long strings for this common case
return compute_substrings_from_fn(*d_column,
thrust::constant_iterator<size_type>(start_value),
thrust::constant_iterator<size_type>(stop_value),
stream,
mr);
}
}
auto const d_start = get_scalar_device_view(const_cast<numeric_scalar<size_type>&>(start));
auto const d_stop = get_scalar_device_view(const_cast<numeric_scalar<size_type>&>(stop));
auto const d_step = get_scalar_device_view(const_cast<numeric_scalar<size_type>&>(step));
auto [offsets, chars] = make_strings_children(
substring_fn{*d_column, d_start, d_stop, d_step}, strings.size(), stream, mr);
return make_strings_column(strings.size(),
std::move(offsets),
std::move(chars),
strings.null_count(),
cudf::detail::copy_bitmask(strings.parent(), stream, mr));
}
std::unique_ptr<column> slice_strings(strings_column_view const& strings,
column_view const& starts_column,
column_view const& stops_column,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = strings.size();
if (strings_count == 0) return make_empty_column(type_id::STRING);
CUDF_EXPECTS(starts_column.size() == strings_count,
"Parameter starts must have the same number of rows as strings.");
CUDF_EXPECTS(stops_column.size() == strings_count,
"Parameter stops must have the same number of rows as strings.");
CUDF_EXPECTS(starts_column.type() == stops_column.type(),
"Parameters starts and stops must be of the same type.");
CUDF_EXPECTS(starts_column.null_count() == 0, "Parameter starts must not contain nulls.");
CUDF_EXPECTS(stops_column.null_count() == 0, "Parameter stops must not contain nulls.");
CUDF_EXPECTS(starts_column.type().id() != data_type{type_id::BOOL8}.id(),
"Positions values must not be bool type.");
CUDF_EXPECTS(is_fixed_width(starts_column.type()), "Positions values must be fixed width type.");
auto strings_column = column_device_view::create(strings.parent(), stream);
auto starts_iter = cudf::detail::indexalator_factory::make_input_iterator(starts_column);
auto stops_iter = cudf::detail::indexalator_factory::make_input_iterator(stops_column);
return compute_substrings_from_fn(*strings_column, starts_iter, stops_iter, stream, mr);
}
} // namespace detail
// external API
std::unique_ptr<column> slice_strings(strings_column_view const& strings,
numeric_scalar<size_type> const& start,
numeric_scalar<size_type> const& stop,
numeric_scalar<size_type> const& step,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::slice_strings(strings, start, stop, step, stream, mr);
}
std::unique_ptr<column> slice_strings(strings_column_view const& strings,
column_view const& starts_column,
column_view const& stops_column,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::slice_strings(strings, starts_column, stops_column, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/attributes.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/cuda.cuh>
#include <cudf/strings/attributes.hpp>
#include <cudf/strings/detail/utf8.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/binary_search.h>
#include <thrust/copy.h>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/functional.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform.h>
#include <thrust/transform_scan.h>
#include <cub/warp/warp_reduce.cuh>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Threshold to decide on using string or warp parallel functions.
*
* If the average byte length of a string in a column exceeds this value then
* the warp-parallel function is used.
* Otherwise, a regular string-parallel function is used.
*
* This value was found using the strings_lengths benchmark results.
*/
constexpr size_type AVG_CHAR_BYTES_THRESHOLD = 64;
/**
* @brief Returns a numeric column containing lengths of each string in
* based on the provided unary function
*
* Any null string will result in a null entry for that row in the output column.
*
* @tparam UnaryFunction Device function that returns an integer given a string_view
* @param strings Strings instance for this operation
* @param ufn Function returns an integer for each string
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate the returned column's device memory
* @return New column with lengths for each string
*/
template <typename UnaryFunction>
std::unique_ptr<column> counts_fn(strings_column_view const& strings,
UnaryFunction& ufn,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// create output column
auto results = make_numeric_column(data_type{type_to_id<size_type>()},
strings.size(),
cudf::detail::copy_bitmask(strings.parent(), stream, mr),
strings.null_count(),
stream,
mr);
auto d_lengths = results->mutable_view().data<int32_t>();
// input column device view
auto strings_column = cudf::column_device_view::create(strings.parent(), stream);
auto d_strings = *strings_column;
// fill in the lengths
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<cudf::size_type>(0),
thrust::make_counting_iterator<cudf::size_type>(strings.size()),
d_lengths,
[d_strings, ufn] __device__(size_type idx) {
return d_strings.is_null(idx)
? 0
: static_cast<int32_t>(ufn(d_strings.element<string_view>(idx)));
});
results->set_null_count(strings.null_count()); // reset null count
return results;
}
/**
* @brief Count characters using a warp per string
*
* @param d_strings Column with strings to count
* @param d_lengths Results of the counts per string
*/
__global__ void count_characters_parallel_fn(column_device_view const d_strings,
size_type* d_lengths)
{
auto const idx = cudf::detail::grid_1d::global_thread_id();
using warp_reduce = cub::WarpReduce<size_type>;
__shared__ typename warp_reduce::TempStorage temp_storage;
if (idx >= (d_strings.size() * cudf::detail::warp_size)) { return; }
auto const str_idx = static_cast<size_type>(idx / cudf::detail::warp_size);
auto const lane_idx = static_cast<size_type>(idx % cudf::detail::warp_size);
if (d_strings.is_null(str_idx)) {
d_lengths[str_idx] = 0;
return;
}
auto const d_str = d_strings.element<string_view>(str_idx);
auto const str_ptr = d_str.data();
size_type count = 0;
for (auto i = lane_idx; i < d_str.size_bytes(); i += cudf::detail::warp_size) {
count += static_cast<size_type>(is_begin_utf8_char(str_ptr[i]));
}
auto const char_count = warp_reduce(temp_storage).Sum(count);
if (lane_idx == 0) { d_lengths[str_idx] = char_count; }
}
std::unique_ptr<column> count_characters_parallel(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// create output column
auto results = make_numeric_column(data_type{type_to_id<size_type>()},
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto const d_lengths = results->mutable_view().data<size_type>();
auto const d_strings = cudf::column_device_view::create(input.parent(), stream);
// fill in the lengths
constexpr int block_size = 256;
cudf::detail::grid_1d grid{input.size() * cudf::detail::warp_size, block_size};
count_characters_parallel_fn<<<grid.num_blocks, grid.num_threads_per_block, 0, stream.value()>>>(
*d_strings, d_lengths);
// reset null count after call to mutable_view()
results->set_null_count(input.null_count());
return results;
}
} // namespace
std::unique_ptr<column> count_characters(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if ((input.size() == input.null_count()) ||
((input.chars_size() / (input.size() - input.null_count())) < AVG_CHAR_BYTES_THRESHOLD)) {
auto ufn = [] __device__(string_view const& d_str) { return d_str.length(); };
return counts_fn(input, ufn, stream, mr);
}
return count_characters_parallel(input, stream, mr);
}
std::unique_ptr<column> count_bytes(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto ufn = [] __device__(string_view const& d_str) { return d_str.size_bytes(); };
return counts_fn(input, ufn, stream, mr);
}
} // namespace detail
namespace {
/**
* @brief Sets the code-point values for each character in the output
* integer memory for each string in the strings column.
*
* For each string, there is a sub-array in d_results with length equal
* to the number of characters in that string. The function here will
* write code-point values to that section as pointed to by the
* corresponding d_offsets value calculated for that string.
*/
struct code_points_fn {
column_device_view d_strings;
size_type* d_offsets; // offset within d_results to fill with each string's code-point values
int32_t* d_results; // base integer array output
__device__ void operator()(size_type idx)
{
if (d_strings.is_null(idx)) return;
auto d_str = d_strings.element<string_view>(idx);
auto result = d_results + d_offsets[idx];
thrust::copy(thrust::seq, d_str.begin(), d_str.end(), result);
}
};
} // namespace
namespace detail {
//
std::unique_ptr<column> code_points(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto strings_column = column_device_view::create(input.parent(), stream);
auto d_column = *strings_column;
// create offsets vector to account for each string's character length
rmm::device_uvector<size_type> offsets(input.size() + 1, stream);
thrust::transform_inclusive_scan(
rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(input.size()),
offsets.begin() + 1,
[d_column] __device__(size_type idx) {
size_type length = 0;
if (!d_column.is_null(idx)) length = d_column.element<string_view>(idx).length();
return length;
},
thrust::plus<size_type>());
offsets.set_element_to_zero_async(0, stream);
// the total size is the number of characters in the entire column
size_type num_characters = offsets.back_element(stream);
// create output column with no nulls
auto results = make_numeric_column(
data_type{type_id::INT32}, num_characters, mask_state::UNALLOCATED, stream, mr);
auto results_view = results->mutable_view();
// fill column with character code-point values
auto d_results = results_view.data<int32_t>();
// now set the ranges from each strings' character values
thrust::for_each_n(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
input.size(),
code_points_fn{d_column, offsets.data(), d_results});
results->set_null_count(0);
return results;
}
} // namespace detail
// external APIS
std::unique_ptr<column> count_characters(strings_column_view const& input,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::count_characters(input, cudf::get_default_stream(), mr);
}
std::unique_ptr<column> count_bytes(strings_column_view const& input,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::count_bytes(input, cudf::get_default_stream(), mr);
}
std::unique_ptr<column> code_points(strings_column_view const& input,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::code_points(input, cudf::get_default_stream(), mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/count_matches.hpp
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cudf/column/column.hpp>
#include <rmm/cuda_stream_view.hpp>
namespace cudf {
class column_device_view;
namespace strings {
namespace detail {
class reprog_device;
/**
* @brief Returns a column of regex match counts for each string in the given column.
*
* A null entry will result in a zero count for that output row.
*
* @param d_strings Device view of the input strings column.
* @param d_prog Regex instance to evaluate on each string.
* @param output_size Number of rows for the output column.
* @param stream CUDA stream used for device memory operations and kernel launches.
* @param mr Device memory resource used to allocate the returned column's device memory.
* @return Integer column of match counts
*/
std::unique_ptr<column> count_matches(column_device_view const& d_strings,
reprog_device& d_prog,
size_type output_size,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/contains.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <strings/count_matches.hpp>
#include <strings/regex/regex_program_impl.h>
#include <strings/regex/utilities.cuh>
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/contains.hpp>
#include <cudf/strings/detail/utilities.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief This functor handles both contains_re and match_re to regex-match a pattern
* to each string in a column.
*/
struct contains_fn {
column_device_view const d_strings;
bool const beginning_only;
__device__ bool operator()(size_type const idx,
reprog_device const prog,
int32_t const thread_idx)
{
if (d_strings.is_null(idx)) return false;
auto const d_str = d_strings.element<string_view>(idx);
size_type end = beginning_only ? 1 // match only the beginning of the string;
: -1; // match anywhere in the string
return prog.find(thread_idx, d_str, d_str.begin(), end).has_value();
}
};
std::unique_ptr<column> contains_impl(strings_column_view const& input,
regex_program const& prog,
bool const beginning_only,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto results = make_numeric_column(data_type{type_id::BOOL8},
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
if (input.is_empty()) { return results; }
auto d_prog = regex_device_builder::create_prog_device(prog, stream);
auto d_results = results->mutable_view().data<bool>();
auto const d_strings = column_device_view::create(input.parent(), stream);
launch_transform_kernel(
contains_fn{*d_strings, beginning_only}, *d_prog, d_results, input.size(), stream);
results->set_null_count(input.null_count());
return results;
}
} // namespace
std::unique_ptr<column> contains_re(strings_column_view const& input,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return contains_impl(input, prog, false, stream, mr);
}
std::unique_ptr<column> matches_re(strings_column_view const& input,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return contains_impl(input, prog, true, stream, mr);
}
std::unique_ptr<column> count_re(strings_column_view const& input,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// create device object from regex_program
auto d_prog = regex_device_builder::create_prog_device(prog, stream);
auto const d_strings = column_device_view::create(input.parent(), stream);
auto result = count_matches(*d_strings, *d_prog, input.size(), stream, mr);
if (input.has_nulls()) {
result->set_null_mask(cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count());
}
return result;
}
} // namespace detail
// external APIs
std::unique_ptr<column> contains_re(strings_column_view const& input,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::contains_re(input, prog, stream, mr);
}
std::unique_ptr<column> matches_re(strings_column_view const& input,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::matches_re(input, prog, stream, mr);
}
std::unique_ptr<column> count_re(strings_column_view const& input,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::count_re(input, prog, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/strings_column_view.cpp
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/error.hpp>
namespace cudf {
//
strings_column_view::strings_column_view(column_view strings_column) : column_view(strings_column)
{
CUDF_EXPECTS(type().id() == type_id::STRING, "strings_column_view only supports strings");
}
column_view strings_column_view::parent() const { return static_cast<column_view>(*this); }
column_view strings_column_view::offsets() const
{
CUDF_EXPECTS(num_children() > 0, "strings column has no children");
return child(offsets_column_index);
}
strings_column_view::offset_iterator strings_column_view::offsets_begin() const
{
return offsets().begin<size_type>() + offset();
}
strings_column_view::offset_iterator strings_column_view::offsets_end() const
{
return offsets_begin() + size() + 1;
}
column_view strings_column_view::chars() const
{
CUDF_EXPECTS(num_children() > 0, "strings column has no children");
return child(chars_column_index);
}
size_type strings_column_view::chars_size() const noexcept
{
if (size() == 0) return 0;
return chars().size();
}
strings_column_view::chars_iterator strings_column_view::chars_begin() const
{
return chars().begin<char>();
}
strings_column_view::chars_iterator strings_column_view::chars_end() const
{
return chars_begin() + chars_size();
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/like.cu
|
/*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/contains.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
constexpr char multi_wildcard = '%';
constexpr char single_wildcard = '_';
template <typename PatternIterator>
struct like_fn {
column_device_view const d_strings;
PatternIterator const patterns_itr;
string_view const d_escape;
like_fn(column_device_view d_strings, PatternIterator patterns_itr, string_view d_escape)
: d_strings{d_strings}, patterns_itr{patterns_itr}, d_escape{d_escape}
{
}
__device__ bool operator()(size_type const idx)
{
if (d_strings.is_null(idx)) return false;
auto const d_str = d_strings.element<string_view>(idx);
auto const d_pattern = patterns_itr[idx];
// incrementing by bytes instead of character improves performance 10-20%
auto target_itr = d_str.data();
auto pattern_itr = d_pattern.begin();
auto const target_end = target_itr + d_str.size_bytes();
auto const pattern_end = d_pattern.end();
auto const esc_char = d_escape.empty() ? 0 : d_escape[0];
auto last_target_itr = target_end;
auto last_pattern_itr = pattern_end;
bool result = true;
while (true) {
// walk through the pattern and check against the current character
while (pattern_itr < pattern_end) {
auto const escaped = *pattern_itr == esc_char;
auto const pattern_char =
escaped && (pattern_itr + 1 < pattern_end) ? *(++pattern_itr) : *pattern_itr;
if (escaped || (pattern_char != multi_wildcard)) {
size_type char_width = 0;
// check match with the current character
result = (target_itr != target_end);
if (result) {
if (escaped || pattern_char != single_wildcard) {
char_utf8 target_char = 0;
// retrieve the target character to compare with the current pattern_char
char_width = to_char_utf8(target_itr, target_char);
result = (pattern_char == target_char);
}
}
if (!result) { break; }
++pattern_itr;
target_itr += char_width ? char_width : bytes_in_utf8_byte(*target_itr);
} else {
// process wildcard '%'
result = true;
++pattern_itr;
if (pattern_itr == pattern_end) { // pattern ends with '%' so we are done
target_itr = target_end;
break;
}
// save positions
last_pattern_itr = pattern_itr;
last_target_itr = target_itr;
} // next pattern character
}
if (result && (target_itr == target_end)) { break; } // success
result = false;
// check if exhausted either the pattern or the target string
if (last_pattern_itr == pattern_end || last_target_itr == target_end) { break; }
// restore saved positions
pattern_itr = last_pattern_itr;
last_target_itr += bytes_in_utf8_byte(*last_target_itr);
target_itr = last_target_itr;
}
return result;
}
};
template <typename PatternIterator>
std::unique_ptr<column> like(strings_column_view const& input,
PatternIterator const patterns_itr,
string_view const& d_escape,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto results = make_numeric_column(data_type{type_id::BOOL8},
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
if (input.is_empty()) { return results; }
auto const d_strings = column_device_view::create(input.parent(), stream);
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(input.size()),
results->mutable_view().data<bool>(),
like_fn{*d_strings, patterns_itr, d_escape});
results->set_null_count(input.null_count());
return results;
}
} // namespace
std::unique_ptr<column> like(strings_column_view const& input,
string_scalar const& pattern,
string_scalar const& escape_character,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(pattern.is_valid(stream), "Parameter pattern must be valid");
CUDF_EXPECTS(escape_character.is_valid(stream), "Parameter escape_character must be valid");
auto const d_pattern = pattern.value(stream);
auto const patterns_itr = thrust::make_constant_iterator(d_pattern);
return like(input, patterns_itr, escape_character.value(stream), stream, mr);
}
std::unique_ptr<column> like(strings_column_view const& input,
strings_column_view const& patterns,
string_scalar const& escape_character,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(patterns.size() == input.size(), "Number of patterns must match the input size");
CUDF_EXPECTS(patterns.has_nulls() == false, "Parameter patterns must not contain nulls");
CUDF_EXPECTS(escape_character.is_valid(stream), "Parameter escape_character must be valid");
auto const d_patterns = column_device_view::create(patterns.parent(), stream);
auto const patterns_itr = d_patterns->begin<string_view>();
return like(input, patterns_itr, escape_character.value(stream), stream, mr);
}
} // namespace detail
// external API
std::unique_ptr<column> like(strings_column_view const& input,
string_scalar const& pattern,
string_scalar const& escape_character,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::like(input, pattern, escape_character, stream, mr);
}
std::unique_ptr<column> like(strings_column_view const& input,
strings_column_view const& patterns,
string_scalar const& escape_character,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::like(input, patterns, escape_character, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/strip.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/strings_column_factories.cuh>
#include <cudf/strings/detail/strip.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/strings/strip.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Strip characters from the beginning and/or end of a string
*
* This functor strips the beginning and/or end of each string
* of any characters found in d_to_strip or whitespace if
* d_to_strip is empty.
*
*/
struct strip_transform_fn {
column_device_view const d_strings;
side_type const side; // right, left, or both
string_view const d_to_strip;
__device__ string_index_pair operator()(size_type idx)
{
if (d_strings.is_null(idx)) { return string_index_pair{nullptr, 0}; }
auto const d_str = d_strings.element<string_view>(idx);
auto const d_stripped = strip(d_str, d_to_strip, side);
return string_index_pair{d_stripped.data(), d_stripped.size_bytes()};
}
};
} // namespace
std::unique_ptr<column> strip(strings_column_view const& input,
side_type side,
string_scalar const& to_strip,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) return make_empty_column(type_id::STRING);
CUDF_EXPECTS(to_strip.is_valid(stream), "Parameter to_strip must be valid");
string_view const d_to_strip(to_strip.data(), to_strip.size());
auto const d_column = column_device_view::create(input.parent(), stream);
auto result = rmm::device_uvector<string_index_pair>(input.size(), stream);
thrust::transform(rmm::exec_policy(stream),
thrust::counting_iterator<size_type>(0),
thrust::counting_iterator<size_type>(input.size()),
result.begin(),
strip_transform_fn{*d_column, side, d_to_strip});
return make_strings_column(result.begin(), result.end(), stream, mr);
}
} // namespace detail
// external APIs
std::unique_ptr<column> strip(strings_column_view const& input,
side_type side,
string_scalar const& to_strip,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::strip(input, side, to_strip, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/repeat_strings.cu
|
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/indexalator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/repeat_strings.hpp>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/for_each.h>
#include <thrust/functional.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/scan.h>
#include <thrust/transform.h>
#include <thrust/transform_reduce.h>
namespace cudf {
namespace strings {
namespace detail {
std::unique_ptr<string_scalar> repeat_string(string_scalar const& input,
size_type repeat_times,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (!input.is_valid(stream)) { return std::make_unique<string_scalar>("", false, stream, mr); }
if (input.size() == 0 || repeat_times <= 0) {
return std::make_unique<string_scalar>("", true, stream, mr);
}
if (repeat_times == 1) { return std::make_unique<string_scalar>(input, stream, mr); }
CUDF_EXPECTS(input.size() <= std::numeric_limits<size_type>::max() / repeat_times,
"The output size exceeds the column size limit",
std::overflow_error);
auto const str_size = input.size();
auto const iter = thrust::make_counting_iterator(0);
auto buff = rmm::device_buffer(repeat_times * input.size(), stream, mr);
// Pull data from the input string into each byte of the output string.
thrust::transform(rmm::exec_policy(stream),
iter,
iter + repeat_times * str_size,
static_cast<char*>(buff.data()),
[in_ptr = input.data(), str_size] __device__(auto const idx) {
return in_ptr[idx % str_size];
});
return std::make_unique<string_scalar>(std::move(buff), true, stream, mr);
}
namespace {
/**
* @brief Generate a strings column in which each row is an empty string or a null.
*
* The output strings column has the same bitmask as the input column.
*/
auto generate_empty_output(strings_column_view const& input,
size_type strings_count,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto chars_column = create_chars_child_column(0, stream, mr);
auto offsets_column = make_numeric_column(
data_type{type_to_id<size_type>()}, strings_count + 1, mask_state::UNALLOCATED, stream, mr);
CUDF_CUDA_TRY(cudaMemsetAsync(offsets_column->mutable_view().template data<size_type>(),
0,
offsets_column->size() * sizeof(size_type),
stream.value()));
return make_strings_column(strings_count,
std::move(offsets_column),
std::move(chars_column),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
/**
* @brief Functor to compute output string sizes and repeat the input strings.
*
* This functor is called only when `repeat_times > 0`. In addition, the total number of threads
* running this functor is `repeat_times * strings_count` (instead of `string_count`) for maximizing
* parallelism and better load-balancing.
*/
struct compute_size_and_repeat_fn {
column_device_view const strings_dv;
size_type const repeat_times;
bool const has_nulls;
size_type* d_offsets{nullptr};
// If d_chars == nullptr: only compute sizes of the output strings.
// If d_chars != nullptr: only repeat strings.
char* d_chars{nullptr};
// `idx` will be in the range of [0, repeat_times * strings_count).
__device__ void operator()(size_type const idx) const noexcept
{
auto const str_idx = idx / repeat_times; // value cycles in [0, string_count)
auto const repeat_idx = idx % repeat_times; // value cycles in [0, repeat_times)
auto const is_valid = !has_nulls || strings_dv.is_valid_nocheck(str_idx);
if (!d_chars && repeat_idx == 0) {
d_offsets[str_idx] =
is_valid ? repeat_times * strings_dv.element<string_view>(str_idx).size_bytes() : 0;
}
// Each input string will be copied by `repeat_times` threads into the output string.
if (d_chars && is_valid) {
auto const d_str = strings_dv.element<string_view>(str_idx);
auto const str_size = d_str.size_bytes();
if (str_size > 0) {
auto const input_ptr = d_str.data();
auto const output_ptr = d_chars + d_offsets[str_idx] + repeat_idx * str_size;
std::memcpy(output_ptr, input_ptr, str_size);
}
}
}
};
} // namespace
std::unique_ptr<column> repeat_strings(strings_column_view const& input,
size_type repeat_times,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto const strings_count = input.size();
if (strings_count == 0) { return make_empty_column(type_id::STRING); }
if (repeat_times <= 0) {
// If the number of repetitions is not positive, each row of the output strings column will be
// either an empty string (if the input row is not null), or a null (if the input row is null).
return generate_empty_output(input, strings_count, stream, mr);
}
// If `repeat_times == 1`, just make a copy of the input.
if (repeat_times == 1) { return std::make_unique<column>(input.parent(), stream, mr); }
auto const strings_dv_ptr = column_device_view::create(input.parent(), stream);
auto const fn = compute_size_and_repeat_fn{*strings_dv_ptr, repeat_times, input.has_nulls()};
auto [offsets_column, chars_column] =
make_strings_children(fn, strings_count * repeat_times, strings_count, stream, mr);
return make_strings_column(strings_count,
std::move(offsets_column),
std::move(chars_column),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
namespace {
/**
* @brief Functor to compute string sizes and repeat the input strings, each string is repeated by a
* separate number of times.
*/
template <class Iterator>
struct compute_sizes_and_repeat_fn {
column_device_view const strings_dv;
column_device_view const repeat_times_dv;
Iterator const repeat_times_iter;
bool const strings_has_nulls;
bool const rtimes_has_nulls;
size_type* d_offsets{nullptr};
// If d_chars == nullptr: only compute sizes of the output strings.
// If d_chars != nullptr: only repeat strings.
char* d_chars{nullptr};
__device__ void operator()(size_type const idx) const noexcept
{
auto const string_is_valid = !strings_has_nulls || strings_dv.is_valid_nocheck(idx);
auto const rtimes_is_valid = !rtimes_has_nulls || repeat_times_dv.is_valid_nocheck(idx);
// Any null input (either string or repeat_times value) will result in a null output.
auto const is_valid = string_is_valid && rtimes_is_valid;
if (!is_valid) {
if (!d_chars) { d_offsets[idx] = 0; }
return;
}
auto repeat_times = repeat_times_iter[idx];
auto const d_str = strings_dv.element<string_view>(idx);
if (!d_chars) {
// repeat_times could be negative
d_offsets[idx] = (repeat_times > 0) ? (repeat_times * d_str.size_bytes()) : 0;
} else {
auto output_ptr = d_chars + d_offsets[idx];
while (repeat_times-- > 0) {
output_ptr = copy_and_increment(output_ptr, d_str.data(), d_str.size_bytes());
}
}
}
};
} // namespace
std::unique_ptr<column> repeat_strings(strings_column_view const& input,
column_view const& repeat_times,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(input.size() == repeat_times.size(), "The input columns must have the same size.");
CUDF_EXPECTS(cudf::is_index_type(repeat_times.type()),
"repeat_strings expects an integer type for the `repeat_times` input column.");
auto const strings_count = input.size();
if (strings_count == 0) { return make_empty_column(type_id::STRING); }
auto const strings_dv_ptr = column_device_view::create(input.parent(), stream);
auto const repeat_times_dv_ptr = column_device_view::create(repeat_times, stream);
auto const repeat_times_iter =
cudf::detail::indexalator_factory::make_input_iterator(repeat_times);
auto const fn =
compute_sizes_and_repeat_fn<decltype(repeat_times_iter)>{*strings_dv_ptr,
*repeat_times_dv_ptr,
repeat_times_iter,
input.has_nulls(),
repeat_times.has_nulls()};
auto [offsets_column, chars_column] = make_strings_children(fn, strings_count, stream, mr);
// We generate new bitmask by AND of the two input columns' bitmasks.
// Note that if either of the input columns are nullable, the output column will also be nullable
// but may not have nulls.
auto [null_mask, null_count] =
cudf::detail::bitmask_and(table_view{{input.parent(), repeat_times}}, stream, mr);
return make_strings_column(strings_count,
std::move(offsets_column),
std::move(chars_column),
null_count,
std::move(null_mask));
}
} // namespace detail
std::unique_ptr<string_scalar> repeat_string(string_scalar const& input,
size_type repeat_times,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::repeat_string(input, repeat_times, stream, mr);
}
std::unique_ptr<column> repeat_strings(strings_column_view const& input,
size_type repeat_times,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::repeat_strings(input, repeat_times, stream, mr);
}
std::unique_ptr<column> repeat_strings(strings_column_view const& input,
column_view const& repeat_times,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::repeat_strings(input, repeat_times, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/translate.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/strings/translate.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/binary_search.h>
#include <thrust/execution_policy.h>
#include <thrust/host_vector.h>
#include <thrust/pair.h>
#include <thrust/sort.h>
#include <algorithm>
namespace cudf {
namespace strings {
namespace detail {
using translate_table = thrust::pair<char_utf8, char_utf8>;
namespace {
/**
* @brief This is the translate functor for replacing individual characters
* in each string.
*/
struct translate_fn {
column_device_view const d_strings;
rmm::device_uvector<translate_table>::iterator table_begin;
rmm::device_uvector<translate_table>::iterator table_end;
int32_t* d_offsets{};
char* d_chars{};
__device__ void operator()(size_type idx)
{
if (d_strings.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
string_view const d_str = d_strings.element<string_view>(idx);
size_type bytes = d_str.size_bytes();
char* out_ptr = d_chars ? d_chars + d_offsets[idx] : nullptr;
for (auto chr : d_str) {
auto const entry =
thrust::lower_bound(thrust::seq,
table_begin,
table_end,
translate_table{chr, 0},
[](auto const& lhs, auto const& rhs) { return lhs.first < rhs.first; });
if (entry != table_end && entry->first == chr) {
bytes -= bytes_in_char_utf8(chr);
chr = entry->second;
if (chr) // if null, skip the character
bytes += bytes_in_char_utf8(chr);
}
if (chr && out_ptr) out_ptr += from_char_utf8(chr, out_ptr);
}
if (!d_chars) d_offsets[idx] = bytes;
}
};
} // namespace
//
std::unique_ptr<column> translate(strings_column_view const& strings,
std::vector<std::pair<char_utf8, char_utf8>> const& chars_table,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (strings.is_empty()) return make_empty_column(type_id::STRING);
size_type table_size = static_cast<size_type>(chars_table.size());
// convert input table
thrust::host_vector<translate_table> htable(table_size);
std::transform(chars_table.begin(), chars_table.end(), htable.begin(), [](auto entry) {
return translate_table{entry.first, entry.second};
});
// The size of this table is usually much less than 100 so it is was
// found to be more efficient to sort on the CPU than the GPU.
thrust::sort(htable.begin(), htable.end(), [](auto const& lhs, auto const& rhs) {
return lhs.first < rhs.first;
});
// copy translate table to device memory
rmm::device_uvector<translate_table> table =
cudf::detail::make_device_uvector_async(htable, stream, rmm::mr::get_current_device_resource());
auto d_strings = column_device_view::create(strings.parent(), stream);
auto children = make_strings_children(
translate_fn{*d_strings, table.begin(), table.end()}, strings.size(), stream, mr);
return make_strings_column(strings.size(),
std::move(children.first),
std::move(children.second),
strings.null_count(),
cudf::detail::copy_bitmask(strings.parent(), stream, mr));
}
} // namespace detail
// external APIs
std::unique_ptr<column> translate(strings_column_view const& input,
std::vector<std::pair<uint32_t, uint32_t>> const& chars_table,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::translate(input, chars_table, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/capitalize.cu
|
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/capitalize.hpp>
#include <cudf/strings/detail/char_tables.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utf8.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/pair.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
using char_info = thrust::pair<uint32_t, detail::character_flags_table_type>;
/**
* @brief Returns the given character's info flags.
*/
__device__ char_info get_char_info(character_flags_table_type const* d_flags, char_utf8 chr)
{
auto const code_point = detail::utf8_to_codepoint(chr);
auto const flag = code_point <= 0x00'FFFF ? d_flags[code_point] : character_flags_table_type{0};
return char_info{code_point, flag};
}
/**
* @brief Base class for capitalize and title functors.
*
* Utility functions here manage access to the character case and flags tables.
* Any derived class must supply a `capitalize_next` member function.
*
* @tparam Derived class uses the CRTP pattern to reuse code logic.
*/
template <typename Derived>
struct base_fn {
character_flags_table_type const* d_flags;
character_cases_table_type const* d_case_table;
special_case_mapping const* d_special_case_mapping;
column_device_view const d_column;
size_type* d_offsets{};
char* d_chars{};
base_fn(column_device_view const& d_column)
: d_flags(get_character_flags_table()),
d_case_table(get_character_cases_table()),
d_special_case_mapping(get_special_case_mapping_table()),
d_column(d_column)
{
}
__device__ int32_t convert_char(char_info const& info, char* d_buffer) const
{
auto const code_point = info.first;
auto const flag = info.second;
if (!IS_SPECIAL(flag)) {
auto const new_char = codepoint_to_utf8(d_case_table[code_point]);
return d_buffer ? detail::from_char_utf8(new_char, d_buffer)
: detail::bytes_in_char_utf8(new_char);
}
special_case_mapping m = d_special_case_mapping[get_special_case_hash_index(code_point)];
auto const count = IS_LOWER(flag) ? m.num_upper_chars : m.num_lower_chars;
auto const* chars = IS_LOWER(flag) ? m.upper : m.lower;
size_type bytes = 0;
for (uint16_t idx = 0; idx < count; idx++) {
bytes += d_buffer
? detail::from_char_utf8(detail::codepoint_to_utf8(chars[idx]), d_buffer + bytes)
: detail::bytes_in_char_utf8(detail::codepoint_to_utf8(chars[idx]));
}
return bytes;
}
/**
* @brief Operator called for each row in `d_column`.
*
* This logic is shared by capitalize() and title() functions.
* The derived class must supply a `capitalize_next` member function.
*/
__device__ void operator()(size_type idx)
{
if (d_column.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto& derived = static_cast<Derived&>(*this);
auto const d_str = d_column.element<string_view>(idx);
size_type bytes = 0;
auto d_buffer = d_chars ? d_chars + d_offsets[idx] : nullptr;
bool capitalize = true;
for (auto const chr : d_str) {
auto const info = get_char_info(d_flags, chr);
auto const flag = info.second;
auto const change_case = capitalize ? IS_LOWER(flag) : IS_UPPER(flag);
if (change_case) {
auto const char_bytes = convert_char(info, d_buffer);
bytes += char_bytes;
d_buffer += d_buffer ? char_bytes : 0;
} else {
if (d_buffer) {
d_buffer += detail::from_char_utf8(chr, d_buffer);
} else {
bytes += detail::bytes_in_char_utf8(chr);
}
}
// capitalize the next char if this one is a delimiter
capitalize = derived.capitalize_next(chr, flag);
}
if (!d_chars) d_offsets[idx] = bytes;
}
};
/**
* @brief Capitalize functor.
*
* This capitalizes the first character of the string and lower-cases
* the remaining characters.
* If a delimiter is specified, capitalization continues within the string
* on the first eligible character after any delimiter.
*/
struct capitalize_fn : base_fn<capitalize_fn> {
string_view const d_delimiters;
capitalize_fn(column_device_view const& d_column, string_view const& d_delimiters)
: base_fn(d_column), d_delimiters(d_delimiters)
{
}
__device__ bool capitalize_next(char_utf8 const chr, character_flags_table_type const)
{
return !d_delimiters.empty() && (d_delimiters.find(chr) != string_view::npos);
}
};
/**
* @brief Title functor.
*
* This capitalizes the first letter of each word.
* The beginning of a word is identified as the first sequence_type
* character after a non-sequence_type character.
* Also, lower-case all other alphabetic characters.
*/
struct title_fn : base_fn<title_fn> {
string_character_types sequence_type;
title_fn(column_device_view const& d_column, string_character_types sequence_type)
: base_fn(d_column), sequence_type(sequence_type)
{
}
__device__ bool capitalize_next(char_utf8 const, character_flags_table_type const flag)
{
return (flag & sequence_type) == 0;
};
};
/**
* @brief Functor for determining title format for each string in a column.
*
* The first letter of each word should be upper-case (IS_UPPER).
* All other characters should be lower-case (IS_LOWER).
* Non-upper/lower-case (IS_UPPER_OR_LOWER) characters delimit words.
*/
struct is_title_fn {
character_flags_table_type const* d_flags;
column_device_view const d_column;
__device__ bool operator()(size_type idx)
{
if (d_column.is_null(idx)) { return false; }
auto const d_str = d_column.element<string_view>(idx);
bool at_least_one_valid = false; // requires one or more cased characters
bool should_be_capitalized = true; // current character should be upper-case
for (auto const chr : d_str) {
auto const flag = get_char_info(d_flags, chr).second;
if (IS_UPPER_OR_LOWER(flag)) {
if (should_be_capitalized == !IS_UPPER(flag)) return false;
at_least_one_valid = true;
}
should_be_capitalized = !IS_UPPER_OR_LOWER(flag);
}
return at_least_one_valid;
}
};
/**
* @brief Common utility function for title() and capitalize().
*
* @tparam CapitalFn The specific functor.
* @param cfn The functor instance.
* @param input The input strings column.
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used for allocating the new device_buffer
*/
template <typename CapitalFn>
std::unique_ptr<column> capitalizer(CapitalFn cfn,
strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto children = cudf::strings::detail::make_strings_children(cfn, input.size(), stream, mr);
return make_strings_column(input.size(),
std::move(children.first),
std::move(children.second),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
} // namespace
std::unique_ptr<column> capitalize(strings_column_view const& input,
string_scalar const& delimiters,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(delimiters.is_valid(stream), "Delimiter must be a valid string");
if (input.is_empty()) return make_empty_column(type_id::STRING);
auto const d_column = column_device_view::create(input.parent(), stream);
auto const d_delimiters = delimiters.value(stream);
return capitalizer(capitalize_fn{*d_column, d_delimiters}, input, stream, mr);
}
std::unique_ptr<column> title(strings_column_view const& input,
string_character_types sequence_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) return make_empty_column(type_id::STRING);
auto d_column = column_device_view::create(input.parent(), stream);
return capitalizer(title_fn{*d_column, sequence_type}, input, stream, mr);
}
std::unique_ptr<column> is_title(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) return make_empty_column(type_id::BOOL8);
auto results = make_numeric_column(data_type{type_id::BOOL8},
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto d_column = column_device_view::create(input.parent(), stream);
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(input.size()),
results->mutable_view().data<bool>(),
is_title_fn{get_character_flags_table(), *d_column});
results->set_null_count(input.null_count());
return results;
}
} // namespace detail
std::unique_ptr<column> capitalize(strings_column_view const& input,
string_scalar const& delimiter,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::capitalize(input, delimiter, stream, mr);
}
std::unique_ptr<column> title(strings_column_view const& input,
string_character_types sequence_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::title(input, sequence_type, stream, mr);
}
std::unique_ptr<column> is_title(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::is_title(input, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/filter_chars.cu
|
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/strings/translate.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/execution_policy.h>
#include <thrust/find.h>
#include <thrust/host_vector.h>
#include <thrust/pair.h>
#include <algorithm>
namespace cudf {
namespace strings {
namespace detail {
using char_range = thrust::pair<char_utf8, char_utf8>;
namespace {
/**
* @brief This is the filter functor for replacing characters
* in each string given a vector of char_range values.
*/
struct filter_fn {
column_device_view const d_strings;
filter_type keep_characters;
rmm::device_uvector<char_range>::iterator table_begin;
rmm::device_uvector<char_range>::iterator table_end;
string_view const d_replacement;
int32_t* d_offsets{};
char* d_chars{};
/**
* @brief Return true if this character should be removed.
*
* @param ch Character to check
* @return True if character should be removed.
*/
__device__ bool remove_char(char_utf8 ch)
{
auto const entry =
thrust::find_if(thrust::seq, table_begin, table_end, [ch] __device__(auto const& range) {
return (range.first <= ch) && (ch <= range.second);
});
// if keep==true and entry-not-found OR
// if keep==false and entry-found
return (keep_characters == filter_type::KEEP) == (entry == table_end);
}
/**
* @brief Execute the filter operation on each string.
*
* This is also used to calculate the size of the output.
*
* @param idx Index of the current string to process.
*/
__device__ void operator()(size_type idx)
{
if (d_strings.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto const d_str = d_strings.element<string_view>(idx);
auto nbytes = d_str.size_bytes();
auto out_ptr = d_chars ? d_chars + d_offsets[idx] : nullptr;
for (auto itr = d_str.begin(); itr != d_str.end(); ++itr) {
auto const char_size = bytes_in_char_utf8(*itr);
string_view const d_newchar = remove_char(*itr)
? d_replacement
: string_view(d_str.data() + itr.byte_offset(), char_size);
if (out_ptr)
out_ptr = cudf::strings::detail::copy_string(out_ptr, d_newchar);
else
nbytes += d_newchar.size_bytes() - char_size;
}
if (!out_ptr) d_offsets[idx] = nbytes;
}
};
} // namespace
/**
* @copydoc cudf::strings::filter_characters
*/
std::unique_ptr<column> filter_characters(
strings_column_view const& strings,
std::vector<std::pair<cudf::char_utf8, cudf::char_utf8>> characters_to_filter,
filter_type keep_characters,
string_scalar const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = strings.size();
if (strings_count == 0) return make_empty_column(type_id::STRING);
CUDF_EXPECTS(replacement.is_valid(stream), "Parameter replacement must be valid");
cudf::string_view d_replacement(replacement.data(), replacement.size());
// convert input table for copy to device memory
size_type table_size = static_cast<size_type>(characters_to_filter.size());
thrust::host_vector<char_range> htable(table_size);
std::transform(
characters_to_filter.begin(), characters_to_filter.end(), htable.begin(), [](auto entry) {
return char_range{entry.first, entry.second};
});
rmm::device_uvector<char_range> table =
cudf::detail::make_device_uvector_async(htable, stream, rmm::mr::get_current_device_resource());
auto d_strings = column_device_view::create(strings.parent(), stream);
// this utility calls the strip_fn to build the offsets and chars columns
filter_fn ffn{*d_strings, keep_characters, table.begin(), table.end(), d_replacement};
auto children = cudf::strings::detail::make_strings_children(ffn, strings.size(), stream, mr);
return make_strings_column(strings_count,
std::move(children.first),
std::move(children.second),
strings.null_count(),
cudf::detail::copy_bitmask(strings.parent(), stream, mr));
}
} // namespace detail
/**
* @copydoc cudf::strings::filter_characters
*/
std::unique_ptr<column> filter_characters(
strings_column_view const& input,
std::vector<std::pair<cudf::char_utf8, cudf::char_utf8>> characters_to_filter,
filter_type keep_characters,
string_scalar const& replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::filter_characters(
input, characters_to_filter, keep_characters, replacement, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/strings_scalar_factories.cpp
|
/*
* Copyright (c) 2019-2020, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/scalar/scalar.hpp>
#include <rmm/cuda_stream_view.hpp>
namespace cudf {
// Create a strings-type column from array of pointer/size pairs
std::unique_ptr<scalar> make_string_scalar(std::string const& string,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto s = new string_scalar(string, true, stream, mr);
return std::unique_ptr<scalar>(s);
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/count_matches.cu
|
/*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <strings/count_matches.hpp>
#include <strings/regex/utilities.cuh>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/strings/string_view.cuh>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Kernel counts the total matches for the given regex in each string.
*/
struct count_fn {
column_device_view const d_strings;
__device__ int32_t operator()(size_type const idx,
reprog_device const prog,
int32_t const thread_idx)
{
if (d_strings.is_null(idx)) return 0;
auto const d_str = d_strings.element<string_view>(idx);
auto const nchars = d_str.length();
int32_t count = 0;
auto itr = d_str.begin();
while (itr.position() <= nchars) {
auto result = prog.find(thread_idx, d_str, itr);
if (!result) { break; }
++count;
// increment the iterator is faster than creating a new one
// +1 if the match was on a virtual position (e.g. word boundary)
itr += (result->second - itr.position()) + (result->first == result->second);
}
return count;
}
};
} // namespace
std::unique_ptr<column> count_matches(column_device_view const& d_strings,
reprog_device& d_prog,
size_type output_size,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
assert(output_size >= d_strings.size() and "Unexpected output size");
auto results = make_numeric_column(
data_type{type_to_id<size_type>()}, output_size, mask_state::UNALLOCATED, stream, mr);
if (d_strings.size() == 0) return results;
auto d_results = results->mutable_view().data<int32_t>();
launch_transform_kernel(count_fn{d_strings}, d_prog, d_results, d_strings.size(), stream);
return results;
}
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/case.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/cuda.cuh>
#include <cudf/strings/case.hpp>
#include <cudf/strings/detail/char_tables.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utf8.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <cuda/atomic>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Threshold to decide on using string or warp parallel functions.
*
* If the average byte length of a string in a column exceeds this value then
* the warp-parallel function is used to compute the output sizes.
* Otherwise, a regular string-parallel function is used.
*
* This value was found using the strings_lengths benchmark results.
*/
constexpr size_type AVG_CHAR_BYTES_THRESHOLD = 64;
/**
* @brief Utility functions for converting characters to upper or lower case
*/
struct convert_char_fn {
character_flags_table_type case_flag;
character_flags_table_type const* d_flags;
character_cases_table_type const* d_case_table;
special_case_mapping const* d_special_case_mapping;
// compute size or copy the bytes representing the special case mapping for this codepoint
__device__ size_type handle_special_case_bytes(uint32_t code_point,
detail::character_flags_table_type flag,
char* d_buffer = nullptr) const
{
special_case_mapping m = d_special_case_mapping[get_special_case_hash_index(code_point)];
size_type bytes = 0;
auto const count = IS_LOWER(flag) ? m.num_upper_chars : m.num_lower_chars;
auto const* chars = IS_LOWER(flag) ? m.upper : m.lower;
for (uint16_t idx = 0; idx < count; idx++) {
bytes += d_buffer
? detail::from_char_utf8(detail::codepoint_to_utf8(chars[idx]), d_buffer + bytes)
: detail::bytes_in_char_utf8(detail::codepoint_to_utf8(chars[idx]));
}
return bytes;
}
// this is called for converting any UTF-8 characters
__device__ size_type process_character(char_utf8 chr, char* d_buffer = nullptr) const
{
auto const code_point = detail::utf8_to_codepoint(chr);
detail::character_flags_table_type flag = code_point <= 0x00'FFFF ? d_flags[code_point] : 0;
// we apply special mapping in two cases:
// - uncased characters with the special mapping flag: always
// - cased characters with the special mapping flag: when matching the input case_flag
if (IS_SPECIAL(flag) && ((flag & case_flag) || !IS_UPPER_OR_LOWER(flag))) {
return handle_special_case_bytes(code_point, case_flag, d_buffer);
}
char_utf8 const new_char =
(flag & case_flag) ? detail::codepoint_to_utf8(d_case_table[code_point]) : chr;
return (d_buffer) ? detail::from_char_utf8(new_char, d_buffer)
: detail::bytes_in_char_utf8(new_char);
}
// special function for converting ASCII-only characters
__device__ char process_ascii(char chr)
{
return (case_flag & d_flags[chr]) ? static_cast<char>(d_case_table[chr]) : chr;
}
};
/**
* @brief Per string logic for case conversion functions
*
* This can be used in calls to make_strings_children.
*/
struct upper_lower_fn {
convert_char_fn converter;
column_device_view d_strings;
size_type* d_offsets{};
char* d_chars{};
__device__ void operator()(size_type idx) const
{
if (d_strings.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto const d_str = d_strings.element<string_view>(idx);
size_type bytes = 0;
char* d_buffer = d_chars ? d_chars + d_offsets[idx] : nullptr;
for (auto itr = d_str.begin(); itr != d_str.end(); ++itr) {
auto const size = converter.process_character(*itr, d_buffer);
if (d_buffer) {
d_buffer += size;
} else {
bytes += size;
}
}
if (!d_buffer) { d_offsets[idx] = bytes; }
}
};
/**
* @brief Count output bytes in warp-parallel threads
*
* This executes as one warp per string and just computes the output sizes.
*/
struct count_bytes_fn {
convert_char_fn converter;
column_device_view d_strings;
size_type* d_offsets;
__device__ void operator()(size_type idx) const
{
auto const str_idx = idx / cudf::detail::warp_size;
auto const lane_idx = idx % cudf::detail::warp_size;
// initialize the output for the atomicAdd
if (lane_idx == 0) { d_offsets[str_idx] = 0; }
__syncwarp();
if (d_strings.is_null(str_idx)) { return; }
auto const d_str = d_strings.element<string_view>(str_idx);
auto const str_ptr = d_str.data();
size_type size = 0;
for (auto i = lane_idx; i < d_str.size_bytes(); i += cudf::detail::warp_size) {
auto const chr = str_ptr[i];
if (is_utf8_continuation_char(chr)) { continue; }
char_utf8 u8 = 0;
to_char_utf8(str_ptr + i, u8);
size += converter.process_character(u8);
}
// this is every so slightly faster than using the cub::warp_reduce
if (size > 0) {
cuda::atomic_ref<size_type, cuda::thread_scope_block> ref{*(d_offsets + str_idx)};
ref.fetch_add(size, cuda::std::memory_order_relaxed);
}
}
};
/**
* @brief Special functor for processing ASCII-only data
*/
struct ascii_converter_fn {
convert_char_fn converter;
__device__ char operator()(char chr) { return converter.process_ascii(chr); }
};
/**
* @brief Utility method for converting upper and lower case characters
* in a strings column
*
* @param input Strings to convert
* @param case_flag The character type to convert (upper, lower, or both)
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate the returned column's device memory
* @return New strings column with characters converted
*/
std::unique_ptr<column> convert_case(strings_column_view const& input,
character_flags_table_type case_flag,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.size() == input.null_count()) {
return std::make_unique<column>(input.parent(), stream, mr);
}
auto const d_strings = column_device_view::create(input.parent(), stream);
auto const d_flags = get_character_flags_table();
auto const d_cases = get_character_cases_table();
auto const d_special = get_special_case_mapping_table();
convert_char_fn ccfn{case_flag, d_flags, d_cases, d_special};
upper_lower_fn converter{ccfn, *d_strings};
// For smaller strings, use the regular string-parallel algorithm
if ((input.chars_size() / (input.size() - input.null_count())) < AVG_CHAR_BYTES_THRESHOLD) {
auto [offsets, chars] =
cudf::strings::detail::make_strings_children(converter, input.size(), stream, mr);
return make_strings_column(input.size(),
std::move(offsets),
std::move(chars),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
// Check if the input contains any multi-byte characters.
// This check incurs ~20% performance hit for smaller strings and so we only use it
// after the threshold check above. The check makes very little impact for larger strings
// but results in a large performance gain when the input contains only single-byte characters.
// The count_if is faster than any_of or all_of: https://github.com/NVIDIA/thrust/issues/1016
bool const multi_byte_chars =
thrust::count_if(
rmm::exec_policy(stream), input.chars_begin(), input.chars_end(), [] __device__(auto chr) {
return is_utf8_continuation_char(chr);
}) > 0;
if (!multi_byte_chars) {
// optimization for ASCII-only case: copy the input column and inplace replace each character
auto result = std::make_unique<column>(input.parent(), stream, mr);
auto d_chars =
result->mutable_view().child(strings_column_view::chars_column_index).data<char>();
auto const chars_size = strings_column_view(result->view()).chars_size();
thrust::transform(
rmm::exec_policy(stream), d_chars, d_chars + chars_size, d_chars, ascii_converter_fn{ccfn});
result->set_null_count(input.null_count());
return result;
}
// This will use a warp-parallel algorithm to compute the output sizes for each string
// and then uses the normal string parallel functor to build the output.
auto offsets = make_numeric_column(
data_type{type_to_id<size_type>()}, input.size() + 1, mask_state::UNALLOCATED, stream, mr);
auto d_offsets = offsets->mutable_view().data<size_type>();
// first pass, compute output sizes
// note: tried to use segmented-reduce approach instead here and it was consistently slower
count_bytes_fn counter{ccfn, *d_strings, d_offsets};
auto const count_itr = thrust::make_counting_iterator<size_type>(0);
thrust::for_each_n(
rmm::exec_policy(stream), count_itr, input.size() * cudf::detail::warp_size, counter);
// convert sizes to offsets
auto const bytes =
cudf::detail::sizes_to_offsets(d_offsets, d_offsets + input.size() + 1, d_offsets, stream);
CUDF_EXPECTS(bytes <= std::numeric_limits<size_type>::max(),
"Size of output exceeds the column size limit",
std::overflow_error);
auto chars = create_chars_child_column(static_cast<size_type>(bytes), stream, mr);
// second pass, write output
converter.d_offsets = d_offsets;
converter.d_chars = chars->mutable_view().data<char>();
thrust::for_each_n(rmm::exec_policy(stream), count_itr, input.size(), converter);
return make_strings_column(input.size(),
std::move(offsets),
std::move(chars),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
} // namespace
std::unique_ptr<column> to_lower(strings_column_view const& strings,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
character_flags_table_type case_flag = IS_UPPER(0xFF); // convert only upper case characters
return convert_case(strings, case_flag, stream, mr);
}
//
std::unique_ptr<column> to_upper(strings_column_view const& strings,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
character_flags_table_type case_flag = IS_LOWER(0xFF); // convert only lower case characters
return convert_case(strings, case_flag, stream, mr);
}
//
std::unique_ptr<column> swapcase(strings_column_view const& strings,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// convert only upper or lower case characters
character_flags_table_type case_flag = IS_LOWER(0xFF) | IS_UPPER(0xFF);
return convert_case(strings, case_flag, stream, mr);
}
} // namespace detail
// APIs
std::unique_ptr<column> to_lower(strings_column_view const& strings,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::to_lower(strings, stream, mr);
}
std::unique_ptr<column> to_upper(strings_column_view const& strings,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::to_upper(strings, stream, mr);
}
std::unique_ptr<column> swapcase(strings_column_view const& strings,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::swapcase(strings, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/utilities.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <strings/char_types/char_cases.h>
#include <strings/char_types/char_flags.h>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/strings/detail/char_tables.hpp>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
/**
* @copydoc create_string_vector_from_column
*/
rmm::device_uvector<string_view> create_string_vector_from_column(
cudf::strings_column_view const input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto d_strings = column_device_view::create(input.parent(), stream);
auto strings_vector = rmm::device_uvector<string_view>(input.size(), stream, mr);
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(input.size()),
strings_vector.begin(),
[d_strings = *d_strings] __device__(size_type idx) {
// placeholder for factory function that takes a span of string_views
auto const null_string_view = string_view{nullptr, 0};
if (d_strings.is_null(idx)) { return null_string_view; }
auto const d_str = d_strings.element<string_view>(idx);
// special case when the entire column is filled with empty strings:
// here the empty d_str may have a d_str.data() == nullptr
auto const empty_string_view = string_view{};
return d_str.empty() ? empty_string_view : d_str;
});
return strings_vector;
}
std::unique_ptr<column> create_chars_child_column(cudf::size_type total_bytes,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return make_numeric_column(
data_type{type_id::INT8}, total_bytes, mask_state::UNALLOCATED, stream, mr);
}
namespace {
// The device variables are created here to avoid using a singleton that may cause issues
// with RMM initialize/finalize. See PR #3159 for details on this approach.
__device__ character_flags_table_type
character_codepoint_flags[sizeof(g_character_codepoint_flags)];
__device__ character_cases_table_type character_cases_table[sizeof(g_character_cases_table)];
__device__ special_case_mapping character_special_case_mappings[sizeof(g_special_case_mappings)];
thread_safe_per_context_cache<character_flags_table_type> d_character_codepoint_flags;
thread_safe_per_context_cache<character_cases_table_type> d_character_cases_table;
thread_safe_per_context_cache<special_case_mapping> d_special_case_mappings;
} // namespace
/**
* @copydoc cudf::strings::detail::get_character_flags_table
*/
character_flags_table_type const* get_character_flags_table()
{
return d_character_codepoint_flags.find_or_initialize([&](void) {
character_flags_table_type* table = nullptr;
CUDF_CUDA_TRY(cudaMemcpyToSymbol(
character_codepoint_flags, g_character_codepoint_flags, sizeof(g_character_codepoint_flags)));
CUDF_CUDA_TRY(cudaGetSymbolAddress((void**)&table, character_codepoint_flags));
return table;
});
}
/**
* @copydoc cudf::strings::detail::get_character_cases_table
*/
character_cases_table_type const* get_character_cases_table()
{
return d_character_cases_table.find_or_initialize([&](void) {
character_cases_table_type* table = nullptr;
CUDF_CUDA_TRY(cudaMemcpyToSymbol(
character_cases_table, g_character_cases_table, sizeof(g_character_cases_table)));
CUDF_CUDA_TRY(cudaGetSymbolAddress((void**)&table, character_cases_table));
return table;
});
}
/**
* @copydoc cudf::strings::detail::get_special_case_mapping_table
*/
special_case_mapping const* get_special_case_mapping_table()
{
return d_special_case_mappings.find_or_initialize([&](void) {
special_case_mapping* table = nullptr;
CUDF_CUDA_TRY(cudaMemcpyToSymbol(
character_special_case_mappings, g_special_case_mappings, sizeof(g_special_case_mappings)));
CUDF_CUDA_TRY(cudaGetSymbolAddress((void**)&table, character_special_case_mappings));
return table;
});
}
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/wrap.cu
|
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/strings/wrap.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
namespace cudf {
namespace strings {
namespace detail {
namespace { // anonym.
// execute string wrap:
//
struct execute_wrap {
execute_wrap(column_device_view const d_column,
int32_t const* d_offsets,
char* d_chars,
size_type width)
: d_column_(d_column), d_offsets_(d_offsets), d_chars_(d_chars), width_(width)
{
}
__device__ int32_t operator()(size_type idx)
{
if (d_column_.is_null(idx)) return 0; // null string
string_view d_str = d_column_.template element<string_view>(idx);
char* d_buffer = d_chars_ + d_offsets_[idx];
int charOffsetToLastSpace = -1;
int byteOffsetToLastSpace = -1;
int spos = 0;
int bidx = 0;
for (auto itr = d_str.begin(); itr != d_str.end(); ++itr) {
auto const the_chr = *itr;
auto const pos = itr.position();
// execute conditions:
if (the_chr <= ' ') { // convert all whitespace to space
d_buffer[bidx] = ' ';
byteOffsetToLastSpace = bidx;
charOffsetToLastSpace = pos;
}
if (pos - spos >= width_ && byteOffsetToLastSpace >= 0) {
d_buffer[byteOffsetToLastSpace] = '\n';
spos = charOffsetToLastSpace;
byteOffsetToLastSpace = -1;
charOffsetToLastSpace = -1;
}
bidx += detail::bytes_in_char_utf8(the_chr);
}
return 0;
}
private:
column_device_view const d_column_;
int32_t const* d_offsets_;
char* d_chars_;
size_type width_;
};
} // namespace
template <typename device_execute_functor>
std::unique_ptr<column> wrap(strings_column_view const& strings,
size_type width,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(width > 0, "Positive wrap width required");
auto strings_count = strings.size();
if (strings_count == 0) return make_empty_column(type_id::STRING);
auto strings_column = column_device_view::create(strings.parent(), stream);
auto d_column = *strings_column;
size_type null_count = strings.null_count();
// copy null mask
rmm::device_buffer null_mask = cudf::detail::copy_bitmask(strings.parent(), stream, mr);
// build offsets column
auto offsets_column = std::make_unique<column>(strings.offsets(), stream, mr); // makes a copy
auto d_new_offsets = offsets_column->view().template data<int32_t>();
auto chars_column = std::make_unique<column>(strings.chars(), stream, mr); // makes a copy
auto d_chars = chars_column->mutable_view().data<char>();
device_execute_functor d_execute_fctr{d_column, d_new_offsets, d_chars, width};
thrust::for_each_n(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
strings_count,
d_execute_fctr);
return make_strings_column(strings_count,
std::move(offsets_column),
std::move(chars_column),
null_count,
std::move(null_mask));
}
} // namespace detail
std::unique_ptr<column> wrap(strings_column_view const& strings,
size_type width,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::wrap<detail::execute_wrap>(strings, width, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/strings_column_factories.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/strings_column_factories.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf/utilities/span.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/pair.h>
namespace cudf {
namespace {
struct string_view_to_pair {
string_view null_placeholder;
string_view_to_pair(string_view n) : null_placeholder(n) {}
__device__ thrust::pair<char const*, size_type> operator()(string_view const& i)
{
return (i.data() == null_placeholder.data())
? thrust::pair<char const*, size_type>{nullptr, 0}
: thrust::pair<char const*, size_type>{i.data(), i.size_bytes()};
}
};
} // namespace
// Create a strings-type column from vector of pointer/size pairs
std::unique_ptr<column> make_strings_column(
device_span<thrust::pair<char const*, size_type> const> strings,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return cudf::strings::detail::make_strings_column(strings.begin(), strings.end(), stream, mr);
}
std::unique_ptr<column> make_strings_column(device_span<char> chars,
device_span<size_type> offsets,
size_type null_count,
rmm::device_buffer&& null_mask,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return cudf::strings::detail::make_strings_column(chars.begin(),
chars.end(),
offsets.begin(),
offsets.end(),
null_count,
std::move(null_mask),
stream,
mr);
}
std::unique_ptr<column> make_strings_column(device_span<string_view const> string_views,
string_view null_placeholder,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
auto it_pair =
thrust::make_transform_iterator(string_views.begin(), string_view_to_pair{null_placeholder});
return cudf::strings::detail::make_strings_column(
it_pair, it_pair + string_views.size(), stream, mr);
}
// Create a strings-type column from device vector of chars and vector of offsets.
std::unique_ptr<column> make_strings_column(cudf::device_span<char const> strings,
cudf::device_span<size_type const> offsets,
cudf::device_span<bitmask_type const> valid_mask,
size_type null_count,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
// build null bitmask
rmm::device_buffer null_mask{
valid_mask.data(), valid_mask.size() * sizeof(bitmask_type), stream, mr};
return cudf::strings::detail::make_strings_column(strings.begin(),
strings.end(),
offsets.begin(),
offsets.end(),
null_count,
std::move(null_mask),
stream,
mr);
}
//
std::unique_ptr<column> make_strings_column(size_type num_strings,
std::unique_ptr<column> offsets_column,
std::unique_ptr<column> chars_column,
size_type null_count,
rmm::device_buffer&& null_mask)
{
CUDF_FUNC_RANGE();
if (null_count > 0) CUDF_EXPECTS(null_mask.size() > 0, "Column with nulls must be nullable.");
CUDF_EXPECTS(num_strings == offsets_column->size() - 1,
"Invalid offsets column size for strings column.");
CUDF_EXPECTS(offsets_column->null_count() == 0, "Offsets column should not contain nulls");
CUDF_EXPECTS(chars_column->null_count() == 0, "Chars column should not contain nulls");
std::vector<std::unique_ptr<column>> children;
children.emplace_back(std::move(offsets_column));
children.emplace_back(std::move(chars_column));
return std::make_unique<column>(data_type{type_id::STRING},
num_strings,
rmm::device_buffer{},
std::move(null_mask),
null_count,
std::move(children));
}
std::unique_ptr<column> make_strings_column(size_type num_strings,
rmm::device_uvector<size_type>&& offsets,
rmm::device_uvector<char>&& chars,
rmm::device_buffer&& null_mask,
size_type null_count)
{
CUDF_FUNC_RANGE();
auto const offsets_size = static_cast<size_type>(offsets.size());
auto const chars_size = static_cast<size_type>(chars.size());
if (null_count > 0) CUDF_EXPECTS(null_mask.size() > 0, "Column with nulls must be nullable.");
CUDF_EXPECTS(num_strings == offsets_size - 1, "Invalid offsets column size for strings column.");
auto offsets_column = std::make_unique<column>( //
data_type{type_id::INT32},
offsets_size,
offsets.release(),
rmm::device_buffer(),
0);
auto chars_column = std::make_unique<column>( //
data_type{type_id::INT8},
chars_size,
chars.release(),
rmm::device_buffer(),
0);
auto children = std::vector<std::unique_ptr<column>>();
children.emplace_back(std::move(offsets_column));
children.emplace_back(std::move(chars_column));
return std::make_unique<column>(data_type{type_id::STRING},
num_strings,
rmm::device_buffer{},
std::move(null_mask),
null_count,
std::move(children));
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/strings/reverse.cu
|
/*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/utf8.hpp>
#include <cudf/strings/reverse.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Reverse individual characters in each string
*/
struct reverse_characters_fn {
column_device_view const d_strings;
size_type const* d_offsets;
char* d_chars;
__device__ void operator()(size_type idx)
{
if (d_strings.is_null(idx)) { return; }
auto const d_str = d_strings.element<string_view>(idx);
// pointer to the end of the output string
auto d_output = d_chars + d_offsets[idx] + d_str.size_bytes();
for (auto const chr : d_str) { // iterate through each character;
d_output -= bytes_in_char_utf8(chr); // position output;
from_char_utf8(chr, d_output); // place character into output
}
}
};
} // namespace
std::unique_ptr<column> reverse(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) { return make_empty_column(type_id::STRING); }
// copy the column; replace data in the chars column
auto result = std::make_unique<column>(input.parent(), stream, mr);
auto const d_offsets =
result->view().child(strings_column_view::offsets_column_index).data<size_type>();
auto d_chars = result->mutable_view().child(strings_column_view::chars_column_index).data<char>();
auto const d_column = column_device_view::create(input.parent(), stream);
thrust::for_each_n(rmm::exec_policy(stream),
thrust::counting_iterator<size_type>(0),
input.size(),
reverse_characters_fn{*d_column, d_offsets, d_chars});
return result;
}
} // namespace detail
std::unique_ptr<column> reverse(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::reverse(input, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/replace/replace.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/char_tables.hpp>
#include <cudf/strings/detail/replace.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/replace.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/span.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <thrust/binary_search.h>
#include <thrust/copy.h>
#include <thrust/count.h>
#include <thrust/distance.h>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/remove.h>
#include <thrust/scan.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Average string byte-length threshold for deciding character-level vs row-level parallel
* algorithm.
*
* This value was determined by running the replace string scalar benchmark against different
* power-of-2 string lengths and observing the point at which the performance only improved for
* all trials.
*/
constexpr size_type BYTES_PER_VALID_ROW_THRESHOLD = 64;
/**
* @brief Function logic for the row-level parallelism replace API.
*
* This will perform a replace operation on each string.
*/
struct replace_row_parallel_fn {
column_device_view const d_strings;
string_view const d_target;
string_view const d_repl;
int32_t const max_repl;
int32_t* d_offsets{};
char* d_chars{};
__device__ void operator()(size_type idx)
{
if (d_strings.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto const d_str = d_strings.element<string_view>(idx);
char const* in_ptr = d_str.data();
char* out_ptr = d_chars ? d_chars + d_offsets[idx] : nullptr;
auto max_n = (max_repl < 0) ? d_str.length() : max_repl;
auto bytes = d_str.size_bytes();
auto position = d_str.find(d_target);
size_type last_pos = 0;
while ((position != string_view::npos) && (max_n > 0)) {
if (out_ptr) {
auto const curr_pos = d_str.byte_offset(position);
out_ptr = copy_and_increment(out_ptr, in_ptr + last_pos, curr_pos - last_pos); // copy left
out_ptr = copy_string(out_ptr, d_repl); // copy repl
last_pos = curr_pos + d_target.size_bytes();
} else {
bytes += d_repl.size_bytes() - d_target.size_bytes();
}
position = d_str.find(d_target, position + d_target.length());
--max_n;
}
if (out_ptr) // copy whats left (or right depending on your point of view)
memcpy(out_ptr, in_ptr + last_pos, d_str.size_bytes() - last_pos);
else
d_offsets[idx] = bytes;
}
};
/**
* @brief Functor for detecting falsely-overlapped target positions.
*
* This functor examines target positions that have been flagged as potentially overlapped by
* a previous target position and identifies the overlaps that are false. A false overlap can occur
* when a target position is overlapped by another target position that is itself overlapped.
*
* For example, a target string of "+++" and string to search of "++++++" will generate 4 potential
* target positions at char offsets 0 through 3. The targets at offsets 1, 2, and 3 will be flagged
* as potential overlaps since a prior target position is within range of the target string length.
* The targets at offset 1 and 2 are true overlaps, since the footprint of the valid target at
* offset 0 overlaps with them. The target at offset 3 is not truly overlapped because it is only
* overlapped by invalid targets, targets that were themselves overlapped by a valid target.
*/
struct target_false_overlap_filter_fn {
size_type const* const d_overlap_pos_indices{};
size_type const* const d_target_positions{};
size_type const target_size{};
__device__ bool operator()(size_type overlap_idx) const
{
if (overlap_idx == 0) {
// The first overlap has no prior overlap to chain, so it should be kept as an overlap.
return false;
}
size_type const this_pos_idx = d_overlap_pos_indices[overlap_idx];
// Searching backwards for the first target position index of an overlap that is not adjacent
// to its overlap predecessor. The result will be the first overlap in this chain of overlaps.
size_type first_overlap_idx = overlap_idx;
size_type first_pos_idx = this_pos_idx;
while (first_overlap_idx > 0) {
size_type prev_pos_idx = d_overlap_pos_indices[--first_overlap_idx];
if (prev_pos_idx + 1 != first_pos_idx) { break; }
first_pos_idx = prev_pos_idx;
}
// The prior target position to the first overlapped position in the chain is a valid target.
size_type valid_pos_idx = first_pos_idx - 1;
size_type valid_pos = d_target_positions[valid_pos_idx];
// Walk forward from this valid target. Any targets within the range of this valid one are true
// overlaps. The first overlap beyond the range of this valid target is another valid target,
// as it was falsely overlapped by a target that was itself overlapped. Repeat until we get to
// the overlapped position being queried by this call.
while (valid_pos_idx < this_pos_idx) {
size_type next_pos_idx = valid_pos_idx + 1;
size_type next_pos = d_target_positions[next_pos_idx];
// Every target position within the range of a valid target position is a true overlap.
while (next_pos < valid_pos + target_size) {
if (next_pos_idx == this_pos_idx) { return false; }
next_pos = d_target_positions[++next_pos_idx];
}
valid_pos_idx = next_pos_idx;
valid_pos = next_pos;
}
// This was overlapped only by false overlaps and therefore is a valid target.
return true;
}
};
/**
* @brief Functor for replacing each target string with the replacement string.
*
* This will perform a replace operation at each target position.
*/
struct target_replacer_fn {
device_span<size_type const> const d_target_positions;
char const* const d_in_chars{};
char* const d_out_chars{};
size_type const target_size{};
string_view const d_repl;
int32_t const in_char_offset = 0;
__device__ void operator()(size_type input_idx) const
{
// Calculate the adjustment from input index to output index for each prior target position.
auto const repl_size = d_repl.size_bytes();
auto const idx_delta_per_pos = repl_size - target_size;
// determine the number of target positions at or before this character position
size_type const* next_target_pos_ptr = thrust::upper_bound(
thrust::seq, d_target_positions.begin(), d_target_positions.end(), input_idx);
size_type const num_prev_targets = next_target_pos_ptr - d_target_positions.data();
size_type output_idx = input_idx - in_char_offset + idx_delta_per_pos * num_prev_targets;
if (num_prev_targets == 0) {
// not within a target string
d_out_chars[output_idx] = d_in_chars[input_idx];
} else {
// check if this input position is within a target string
size_type const prev_target_pos = *(next_target_pos_ptr - 1);
size_type target_idx = input_idx - prev_target_pos;
if (target_idx < target_size) {
// within the target string, so the original calculation was off by one target string
output_idx -= idx_delta_per_pos;
// Copy the corresponding byte from the replacement string. If the replacement string is
// larger than the target string then the thread reading the last target byte is
// responsible for copying the remainder of the replacement string.
if (target_idx < repl_size) {
d_out_chars[output_idx++] = d_repl.data()[target_idx++];
if (target_idx == target_size) {
memcpy(d_out_chars + output_idx, d_repl.data() + target_idx, repl_size - target_idx);
}
}
} else {
// not within a target string
d_out_chars[output_idx] = d_in_chars[input_idx];
}
}
}
};
/**
* @brief Filter target positions that are overlapped by other, valid target positions.
*
* This performs an in-place modification of the target positions to remove any target positions
* that are overlapped by other, valid target positions. For example, if the target string is "++"
* and the string to search is "+++" then there will be two potential targets at character offsets
* 0 and 1. The target at offset 0 is valid and overlaps the target at offset 1, invalidating the
* target at offset 1.
*
* @param[in,out] d_target_positions Potential target positions to filter in-place.
* @param[in] target_count Number of potential target positions.
* @param[in] target_size Size of the target string in bytes.
* @param[in] stream CUDA stream to use for device operations.
* @return Number of target positions after filtering.
*/
size_type filter_overlap_target_positions(size_type* d_target_positions,
size_type target_count,
size_type target_size,
rmm::cuda_stream_view stream)
{
auto overlap_detector = [d_target_positions, target_size] __device__(size_type pos_idx) -> bool {
return (pos_idx > 0)
? d_target_positions[pos_idx] - d_target_positions[pos_idx - 1] < target_size
: false;
};
// count the potential number of overlapped target positions
size_type overlap_count =
thrust::count_if(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(target_count),
overlap_detector);
if (overlap_count == 0) { return target_count; }
// create a vector indexing the potential overlapped target positions
rmm::device_uvector<size_type> potential_overlapped_pos_indices(overlap_count, stream);
auto d_potential_overlapped_pos_indices = potential_overlapped_pos_indices.data();
thrust::copy_if(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(target_count),
d_potential_overlapped_pos_indices,
overlap_detector);
// filter out the false overlaps that are actually valid
rmm::device_uvector<size_type> overlapped_pos_indices(overlap_count, stream);
auto d_overlapped_pos_indices = overlapped_pos_indices.data();
auto overlap_end =
thrust::remove_copy_if(rmm::exec_policy(stream),
d_potential_overlapped_pos_indices,
d_potential_overlapped_pos_indices + overlap_count,
thrust::make_counting_iterator<size_type>(0),
d_overlapped_pos_indices,
target_false_overlap_filter_fn{
d_potential_overlapped_pos_indices, d_target_positions, target_size});
overlap_count = cudf::distance(d_overlapped_pos_indices, overlap_end);
// In-place remove any target positions that are overlapped by valid target positions
auto target_pos_end = thrust::remove_if(
rmm::exec_policy(stream),
d_target_positions,
d_target_positions + target_count,
thrust::make_counting_iterator<size_type>(0),
[d_overlapped_pos_indices, overlap_count] __device__(size_type target_position_idx) -> bool {
return thrust::binary_search(thrust::seq,
d_overlapped_pos_indices,
d_overlapped_pos_indices + overlap_count,
target_position_idx);
});
return cudf::distance(d_target_positions, target_pos_end);
}
/**
* @brief Filter target positions to remove any invalid target positions.
*
* This performs an in-place modification of the target positions to remove any target positions
* that are invalid, either by the target string overlapping a row boundary or being overlapped by
* another valid target string.
*
* @param[in,out] target_positions Potential target positions to filter in-place.
* @param[in] d_offsets_span Memory range encompassing the string column offsets.
* @param[in] target_size Size of the target string in bytes.
* @param[in] stream CUDA stream to use for device operations.
* @return Number of target positions after filtering.
*/
size_type filter_false_target_positions(rmm::device_uvector<size_type>& target_positions,
device_span<int32_t const> d_offsets_span,
size_type target_size,
rmm::cuda_stream_view stream)
{
// In-place remove any positions for target strings that crossed string boundaries.
auto d_target_positions = target_positions.data();
auto target_pos_end =
thrust::remove_if(rmm::exec_policy(stream),
d_target_positions,
d_target_positions + target_positions.size(),
[d_offsets_span, target_size] __device__(size_type target_pos) -> bool {
// find the end of the string containing the start of this target
size_type const* offset_ptr = thrust::upper_bound(
thrust::seq, d_offsets_span.begin(), d_offsets_span.end(), target_pos);
return target_pos + target_size > *offset_ptr;
});
auto const target_count = cudf::distance(d_target_positions, target_pos_end);
if (target_count == 0) { return 0; }
// Filter out target positions that are the result of overlapping target matches.
return (target_count > 1)
? filter_overlap_target_positions(d_target_positions, target_count, target_size, stream)
: target_count;
}
/**
* @brief Filter target positions beyond the maximum target replacements per row limit.
*
* This performs an in-place modification of the target positions to remove any target positions
* corresponding to targets that should not be replaced due to the maximum target replacement per
* row limit.
*
* @param[in,out] target_positions Target positions to filter in-place.
* @param[in] target_count Number of target positions.
* @param[in] d_offsets_span Memory range encompassing the string column offsets.
* @param[in] max_repl_per_row Maximum target replacements per row limit.
* @param[in] stream CUDA stream to use for device operations.
* @return Number of target positions after filtering.
*/
size_type filter_maxrepl_target_positions(size_type* d_target_positions,
size_type target_count,
device_span<int32_t const> d_offsets_span,
size_type max_repl_per_row,
rmm::cuda_stream_view stream)
{
auto pos_to_row_fn = [d_offsets_span] __device__(size_type target_pos) -> size_type {
auto upper_bound =
thrust::upper_bound(thrust::seq, d_offsets_span.begin(), d_offsets_span.end(), target_pos);
return thrust::distance(d_offsets_span.begin(), upper_bound);
};
// compute the match count per row for each target position
rmm::device_uvector<size_type> match_counts(target_count, stream);
auto d_match_counts = match_counts.data();
thrust::inclusive_scan_by_key(
rmm::exec_policy(stream),
thrust::make_transform_iterator(d_target_positions, pos_to_row_fn),
thrust::make_transform_iterator(d_target_positions + target_count, pos_to_row_fn),
thrust::make_constant_iterator<size_type>(1),
d_match_counts);
// In-place remove any positions that exceed the per-row match limit
auto target_pos_end =
thrust::remove_if(rmm::exec_policy(stream),
d_target_positions,
d_target_positions + target_count,
d_match_counts,
[max_repl_per_row] __device__(size_type match_count) -> bool {
return match_count > max_repl_per_row;
});
return cudf::distance(d_target_positions, target_pos_end);
}
/**
* @brief Scalar string replacement using a character-level parallel algorithm.
*
* Replaces occurrences of the target string with the replacement string using an algorithm with
* character-level parallelism. This algorithm will perform well when the strings in the string
* column are relatively long.
* @see BYTES_PER_VALID_ROW_THRESHOLD
*
* @param strings String column to search for target strings.
* @param chars_start Offset of the first character in the string column.
* @param chars_end Offset beyond the last character in the string column to search.
* @param d_target String to search for within the string column.
* @param d_repl Replacement string if target string is found.
* @param maxrepl Maximum times to replace if target appears multiple times in a string.
* @param stream CUDA stream to use for device operations
* @param mr Device memory resource used to allocate the returned column's device memory
* @return New strings column.
*/
std::unique_ptr<column> replace_char_parallel(strings_column_view const& strings,
size_type chars_start,
size_type chars_end,
string_view const& d_target,
string_view const& d_repl,
int32_t maxrepl,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto const strings_count = strings.size();
auto const offset_count = strings_count + 1;
auto const d_offsets = strings.offsets_begin();
auto const d_in_chars = strings.chars_begin();
auto const chars_bytes = chars_end - chars_start;
auto const target_size = d_target.size_bytes();
// detect a target match at the specified byte position
device_span<char const> const d_chars_span(d_in_chars, chars_end);
auto target_detector = [d_chars_span, d_target] __device__(size_type char_idx) {
auto target_size = d_target.size_bytes();
auto target_ptr = d_chars_span.begin() + char_idx;
return target_ptr + target_size <= d_chars_span.end() &&
d_target.compare(target_ptr, target_size) == 0;
};
// Count target string matches across all character positions, ignoring string boundaries and
// overlapping target strings. This may produce false-positives.
size_type target_count = thrust::count_if(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(chars_start),
thrust::make_counting_iterator<size_type>(chars_end),
target_detector);
if (target_count == 0) {
// nothing to replace, copy the input column
return std::make_unique<cudf::column>(strings.parent(), stream, mr);
}
// create a vector of the potential target match positions
rmm::device_uvector<size_type> target_positions(target_count, stream);
auto d_target_positions = target_positions.data();
thrust::copy_if(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(chars_start),
thrust::make_counting_iterator<size_type>(chars_end),
d_target_positions,
target_detector);
device_span<int32_t const> d_offsets_span(d_offsets, offset_count);
if (target_size > 1) {
target_count =
filter_false_target_positions(target_positions, d_offsets_span, target_size, stream);
if (target_count == 0) {
// nothing to replace, copy the input column
return std::make_unique<cudf::column>(strings.parent(), stream, mr);
}
}
// filter out any target positions that exceed the per-row match limit
if (maxrepl > 0 && target_count > maxrepl) {
target_count = filter_maxrepl_target_positions(
d_target_positions, target_count, d_offsets_span, maxrepl, stream);
}
// build the offsets column
auto offsets_column = make_numeric_column(
data_type{type_id::INT32}, offset_count, mask_state::UNALLOCATED, stream, mr);
auto offsets_view = offsets_column->mutable_view();
auto delta_per_target = d_repl.size_bytes() - target_size;
device_span<size_type const> d_target_positions_span(d_target_positions, target_count);
auto offsets_update_fn =
[d_target_positions_span, delta_per_target, chars_start] __device__(int32_t offset) -> int32_t {
// determine the number of target positions occurring before this offset
size_type const* next_target_pos_ptr = thrust::lower_bound(
thrust::seq, d_target_positions_span.begin(), d_target_positions_span.end(), offset);
size_type num_prev_targets =
thrust::distance(d_target_positions_span.data(), next_target_pos_ptr);
return offset - chars_start + delta_per_target * num_prev_targets;
};
thrust::transform(rmm::exec_policy(stream),
d_offsets_span.begin(),
d_offsets_span.end(),
offsets_view.begin<int32_t>(),
offsets_update_fn);
// build the characters column
auto chars_column =
create_chars_child_column(chars_bytes + (delta_per_target * target_count), stream, mr);
auto d_out_chars = chars_column->mutable_view().data<char>();
thrust::for_each_n(
rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(chars_start),
chars_bytes,
target_replacer_fn{
d_target_positions_span, d_in_chars, d_out_chars, target_size, d_repl, chars_start});
// free the target positions buffer as it is no longer needed
(void)target_positions.release();
return make_strings_column(strings_count,
std::move(offsets_column),
std::move(chars_column),
strings.null_count(),
cudf::detail::copy_bitmask(strings.parent(), stream, mr));
}
/**
* @brief Scalar string replacement using a row-level parallel algorithm.
*
* Replaces occurrences of the target string with the replacement string using an algorithm with
* row-level parallelism. This algorithm will perform well when the strings in the string
* column are relatively short.
* @see BYTES_PER_VALID_ROW_THRESHOLD
*
* @param strings String column to search for target strings.
* @param d_target String to search for within the string column.
* @param d_repl Replacement string if target string is found.
* @param maxrepl Maximum times to replace if target appears multiple times in a string.
* @param stream CUDA stream to use for device operations
* @param mr Device memory resource used to allocate the returned column's device memory
* @return New strings column.
*/
std::unique_ptr<column> replace_row_parallel(strings_column_view const& strings,
string_view const& d_target,
string_view const& d_repl,
int32_t maxrepl,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto d_strings = column_device_view::create(strings.parent(), stream);
// this utility calls the given functor to build the offsets and chars columns
auto children = cudf::strings::detail::make_strings_children(
replace_row_parallel_fn{*d_strings, d_target, d_repl, maxrepl}, strings.size(), stream, mr);
return make_strings_column(strings.size(),
std::move(children.first),
std::move(children.second),
strings.null_count(),
cudf::detail::copy_bitmask(strings.parent(), stream, mr));
}
} // namespace
/**
* @copydoc cudf::strings::detail::replace(strings_column_view const&, string_scalar const&,
* string_scalar const&, int32_t, rmm::cuda_stream_view, rmm::mr::device_memory_resource*)
*/
template <>
std::unique_ptr<column> replace<replace_algorithm::AUTO>(strings_column_view const& strings,
string_scalar const& target,
string_scalar const& repl,
int32_t maxrepl,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (strings.is_empty()) return make_empty_column(type_id::STRING);
if (maxrepl == 0) return std::make_unique<cudf::column>(strings.parent(), stream, mr);
CUDF_EXPECTS(repl.is_valid(stream), "Parameter repl must be valid.");
CUDF_EXPECTS(target.is_valid(stream), "Parameter target must be valid.");
CUDF_EXPECTS(target.size() > 0, "Parameter target must not be empty string.");
string_view d_target(target.data(), target.size());
string_view d_repl(repl.data(), repl.size());
// determine range of characters in the base column
auto const strings_count = strings.size();
auto const offset_count = strings_count + 1;
auto const d_offsets = strings.offsets().data<int32_t>() + strings.offset();
size_type const chars_start =
(strings.offset() == 0)
? 0
: cudf::detail::get_value<int32_t>(strings.offsets(), strings.offset(), stream);
size_type const chars_end = (offset_count == strings.offsets().size())
? strings.chars_size()
: cudf::detail::get_value<int32_t>(
strings.offsets(), strings.offset() + strings_count, stream);
size_type const chars_bytes = chars_end - chars_start;
auto const avg_bytes_per_row = chars_bytes / std::max(strings_count - strings.null_count(), 1);
return (avg_bytes_per_row < BYTES_PER_VALID_ROW_THRESHOLD)
? replace_row_parallel(strings, d_target, d_repl, maxrepl, stream, mr)
: replace_char_parallel(
strings, chars_start, chars_end, d_target, d_repl, maxrepl, stream, mr);
}
template <>
std::unique_ptr<column> replace<replace_algorithm::CHAR_PARALLEL>(
strings_column_view const& strings,
string_scalar const& target,
string_scalar const& repl,
int32_t maxrepl,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (strings.is_empty()) return make_empty_column(type_id::STRING);
if (maxrepl == 0) return std::make_unique<cudf::column>(strings.parent(), stream, mr);
CUDF_EXPECTS(repl.is_valid(stream), "Parameter repl must be valid.");
CUDF_EXPECTS(target.is_valid(stream), "Parameter target must be valid.");
CUDF_EXPECTS(target.size() > 0, "Parameter target must not be empty string.");
string_view d_target(target.data(), target.size());
string_view d_repl(repl.data(), repl.size());
// determine range of characters in the base column
auto const strings_count = strings.size();
auto const offset_count = strings_count + 1;
auto const d_offsets = strings.offsets_begin();
size_type chars_start = (strings.offset() == 0) ? 0
: cudf::detail::get_value<int32_t>(
strings.offsets(), strings.offset(), stream);
size_type chars_end = (offset_count == strings.offsets().size())
? strings.chars_size()
: cudf::detail::get_value<int32_t>(
strings.offsets(), strings.offset() + strings_count, stream);
return replace_char_parallel(
strings, chars_start, chars_end, d_target, d_repl, maxrepl, stream, mr);
}
template <>
std::unique_ptr<column> replace<replace_algorithm::ROW_PARALLEL>(
strings_column_view const& strings,
string_scalar const& target,
string_scalar const& repl,
int32_t maxrepl,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (strings.is_empty()) return make_empty_column(type_id::STRING);
if (maxrepl == 0) return std::make_unique<cudf::column>(strings.parent(), stream, mr);
CUDF_EXPECTS(repl.is_valid(stream), "Parameter repl must be valid.");
CUDF_EXPECTS(target.is_valid(stream), "Parameter target must be valid.");
CUDF_EXPECTS(target.size() > 0, "Parameter target must not be empty string.");
string_view d_target(target.data(), target.size());
string_view d_repl(repl.data(), repl.size());
return replace_row_parallel(strings, d_target, d_repl, maxrepl, stream, mr);
}
namespace {
/**
* @brief Function logic for the replace_slice API.
*
* This will perform a replace_slice operation on each string.
*/
struct replace_slice_fn {
column_device_view const d_strings;
string_view const d_repl;
size_type const start;
size_type const stop;
int32_t* d_offsets{};
char* d_chars{};
__device__ void operator()(size_type idx)
{
if (d_strings.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto const d_str = d_strings.element<string_view>(idx);
auto const length = d_str.length();
char const* in_ptr = d_str.data();
auto const begin = d_str.byte_offset(((start < 0) || (start > length) ? length : start));
auto const end = d_str.byte_offset(((stop < 0) || (stop > length) ? length : stop));
if (d_chars) {
char* out_ptr = d_chars + d_offsets[idx];
out_ptr = copy_and_increment(out_ptr, in_ptr, begin); // copy beginning
out_ptr = copy_string(out_ptr, d_repl); // insert replacement
out_ptr = copy_and_increment(out_ptr, // copy end
in_ptr + end,
d_str.size_bytes() - end);
} else {
d_offsets[idx] = d_str.size_bytes() + d_repl.size_bytes() - (end - begin);
}
}
};
} // namespace
std::unique_ptr<column> replace_slice(strings_column_view const& strings,
string_scalar const& repl,
size_type start,
size_type stop,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (strings.is_empty()) return make_empty_column(type_id::STRING);
CUDF_EXPECTS(repl.is_valid(stream), "Parameter repl must be valid.");
if (stop > 0) CUDF_EXPECTS(start <= stop, "Parameter start must be less than or equal to stop.");
string_view d_repl(repl.data(), repl.size());
auto d_strings = column_device_view::create(strings.parent(), stream);
// this utility calls the given functor to build the offsets and chars columns
auto children = cudf::strings::detail::make_strings_children(
replace_slice_fn{*d_strings, d_repl, start, stop}, strings.size(), stream, mr);
return make_strings_column(strings.size(),
std::move(children.first),
std::move(children.second),
strings.null_count(),
cudf::detail::copy_bitmask(strings.parent(), stream, mr));
}
std::unique_ptr<column> replace_nulls(strings_column_view const& strings,
string_scalar const& repl,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = strings.size();
if (strings_count == 0) return make_empty_column(type_id::STRING);
CUDF_EXPECTS(repl.is_valid(stream), "Parameter repl must be valid.");
string_view d_repl(repl.data(), repl.size());
auto strings_column = column_device_view::create(strings.parent(), stream);
auto d_strings = *strings_column;
// build offsets column
auto offsets_transformer_itr = thrust::make_transform_iterator(
thrust::make_counting_iterator<int32_t>(0), [d_strings, d_repl] __device__(size_type idx) {
return d_strings.is_null(idx) ? d_repl.size_bytes()
: d_strings.element<string_view>(idx).size_bytes();
});
auto [offsets_column, bytes] = cudf::detail::make_offsets_child_column(
offsets_transformer_itr, offsets_transformer_itr + strings_count, stream, mr);
auto d_offsets = offsets_column->view().data<int32_t>();
// build chars column
auto chars_column = create_chars_child_column(bytes, stream, mr);
auto d_chars = chars_column->mutable_view().data<char>();
thrust::for_each_n(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
strings_count,
[d_strings, d_repl, d_offsets, d_chars] __device__(size_type idx) {
string_view d_str = d_repl;
if (!d_strings.is_null(idx)) d_str = d_strings.element<string_view>(idx);
memcpy(d_chars + d_offsets[idx], d_str.data(), d_str.size_bytes());
});
return make_strings_column(
strings_count, std::move(offsets_column), std::move(chars_column), 0, rmm::device_buffer{});
}
} // namespace detail
// external API
std::unique_ptr<column> replace(strings_column_view const& strings,
string_scalar const& target,
string_scalar const& repl,
cudf::size_type maxrepl,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace(strings, target, repl, maxrepl, stream, mr);
}
std::unique_ptr<column> replace_slice(strings_column_view const& strings,
string_scalar const& repl,
size_type start,
size_type stop,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace_slice(strings, repl, start, stop, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/replace/backref_re.cu
|
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "backref_re.cuh"
#include <strings/regex/regex_program_impl.h>
#include <strings/regex/utilities.cuh>
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/strings/replace_re.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <regex>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Return the capturing group index pattern to use with the given replacement string.
*
* Only two patterns are supported at this time `\d` and `${d}` where `d` is an integer in
* the range 0-99. The `\d` pattern is returned by default unless no `\d` pattern is found in
* the `repl` string,
*
* Reference: https://www.regular-expressions.info/refreplacebackref.html
*/
std::string get_backref_pattern(std::string_view repl)
{
std::string const backslash_pattern = "\\\\(\\d+)";
std::string const bracket_pattern = "\\$\\{(\\d+)\\}";
std::string const r{repl};
std::smatch m;
return std::regex_search(r, m, std::regex(backslash_pattern)) ? backslash_pattern
: bracket_pattern;
}
/**
* @brief Parse the back-ref index and position values from a given replace format.
*
* The back-ref numbers are expected to be 1-based.
*
* Returns a modified string without back-ref indicators and a vector of back-ref
* byte position pairs. These are used by the device code to build the output
* string by placing the captured group elements into the replace format.
*
* For example, for input string 'hello \2 and \1' the returned `backref_type` vector
* contains `[(2,6),(1,11)]` and the returned string is 'hello and '.
*/
std::pair<std::string, std::vector<backref_type>> parse_backrefs(std::string_view repl,
int const group_count)
{
std::vector<backref_type> backrefs;
std::string str{repl}; // make a modifiable copy
std::smatch m;
std::regex ex(get_backref_pattern(repl));
std::string rtn;
size_type byte_offset = 0;
while (std::regex_search(str, m, ex) && !m.empty()) {
// parse the back-ref index number
size_type const index = static_cast<size_type>(std::atoi(std::string{m[1]}.c_str()));
CUDF_EXPECTS(index >= 0 && index <= group_count,
"Group index numbers must be in the range 0 to group count");
// store the new byte offset and index value
size_type const position = static_cast<size_type>(m.position(0));
byte_offset += position;
backrefs.push_back({index, byte_offset});
// update the output string
rtn += str.substr(0, position);
// remove the back-ref pattern to continue parsing
str = str.substr(position + static_cast<size_type>(m.length(0)));
}
if (!str.empty()) // add the remainder
rtn += str; // of the string
return {rtn, backrefs};
}
} // namespace
//
std::unique_ptr<column> replace_with_backrefs(strings_column_view const& input,
regex_program const& prog,
std::string_view replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) return make_empty_column(type_id::STRING);
CUDF_EXPECTS(!prog.pattern().empty(), "Parameter pattern must not be empty");
CUDF_EXPECTS(!replacement.empty(), "Parameter replacement must not be empty");
// create device object from regex_program
auto d_prog = regex_device_builder::create_prog_device(prog, stream);
// parse the repl string for back-ref indicators
auto group_count = std::min(99, d_prog->group_counts()); // group count should NOT exceed 99
auto const parse_result = parse_backrefs(replacement, group_count);
rmm::device_uvector<backref_type> backrefs = cudf::detail::make_device_uvector_async(
parse_result.second, stream, rmm::mr::get_current_device_resource());
string_scalar repl_scalar(parse_result.first, true, stream);
string_view const d_repl_template = repl_scalar.value();
auto const d_strings = column_device_view::create(input.parent(), stream);
using BackRefIterator = decltype(backrefs.begin());
auto children = make_strings_children(
backrefs_fn<BackRefIterator>{*d_strings, d_repl_template, backrefs.begin(), backrefs.end()},
*d_prog,
input.size(),
stream,
mr);
return make_strings_column(input.size(),
std::move(children.first),
std::move(children.second),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
} // namespace detail
// external API
std::unique_ptr<column> replace_with_backrefs(strings_column_view const& strings,
regex_program const& prog,
std::string_view replacement,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace_with_backrefs(strings, prog, replacement, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/replace/multi_re.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <strings/regex/regex.cuh>
#include <strings/regex/regex_program_impl.h>
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/replace_re.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/execution_policy.h>
#include <thrust/fill.h>
#include <thrust/find.h>
#include <thrust/pair.h>
#include <algorithm>
namespace cudf {
namespace strings {
namespace detail {
namespace {
// this is a [begin,end) pair of character positions when a substring is matched
using found_range = thrust::pair<size_type, size_type>;
/**
* @brief This functor handles replacing strings by applying the compiled regex patterns
* and inserting the corresponding new string within the matched range of characters.
*/
struct replace_multi_regex_fn {
column_device_view const d_strings;
device_span<reprog_device const> progs; // array of regex progs
found_range* d_found_ranges; // working array matched (begin,end) values
column_device_view const d_repls; // replacement strings
size_type* d_offsets{};
char* d_chars{};
__device__ void operator()(size_type idx)
{
if (d_strings.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto const number_of_patterns = static_cast<size_type>(progs.size());
auto const d_str = d_strings.element<string_view>(idx);
auto const nchars = d_str.length(); // number of characters in input string
auto nbytes = d_str.size_bytes(); // number of bytes in input string
auto in_ptr = d_str.data(); // input pointer
auto out_ptr = d_chars ? d_chars + d_offsets[idx] : nullptr;
auto itr = d_str.begin();
auto last_pos = itr;
found_range* d_ranges = d_found_ranges + (idx * number_of_patterns);
// initialize the working ranges memory to -1's
thrust::fill(thrust::seq, d_ranges, d_ranges + number_of_patterns, found_range{-1, 1});
// process string one character at a time
while (itr.position() < nchars) {
// this minimizes the regex-find calls by only calling it for stale patterns
// -- those that have not previously matched up to this point (ch_pos)
for (size_type ptn_idx = 0; ptn_idx < number_of_patterns; ++ptn_idx) {
if (d_ranges[ptn_idx].first >= itr.position()) { // previously matched here
continue; // or later in the string
}
reprog_device prog = progs[ptn_idx];
auto const result = !prog.is_empty() ? prog.find(idx, d_str, itr) : thrust::nullopt;
d_ranges[ptn_idx] =
result ? found_range{result->first, result->second} : found_range{nchars, nchars};
}
// all the ranges have been updated from each regex match;
// look for any that match at this character position (ch_pos)
auto const ptn_itr =
thrust::find_if(thrust::seq,
d_ranges,
d_ranges + number_of_patterns,
[ch_pos = itr.position()](auto range) { return range.first == ch_pos; });
if (ptn_itr != d_ranges + number_of_patterns) {
// match found, compute and replace the string in the output
auto const ptn_idx = static_cast<size_type>(thrust::distance(d_ranges, ptn_itr));
auto d_repl = d_repls.size() > 1 ? d_repls.element<string_view>(ptn_idx)
: d_repls.element<string_view>(0);
auto const d_range = d_ranges[ptn_idx];
auto const [start_pos, end_pos] =
match_positions_to_bytes({d_range.first, d_range.second}, d_str, last_pos);
nbytes += d_repl.size_bytes() - (end_pos - start_pos);
if (out_ptr) { // copy unmodified content plus new replacement string
out_ptr = copy_and_increment(
out_ptr, in_ptr + last_pos.byte_offset(), start_pos - last_pos.byte_offset());
out_ptr = copy_string(out_ptr, d_repl);
}
last_pos += (d_range.second - last_pos.position());
itr = last_pos - 1;
}
++itr;
}
if (out_ptr) { // copy the remainder
thrust::copy_n(thrust::seq,
in_ptr + last_pos.byte_offset(),
d_str.size_bytes() - last_pos.byte_offset(),
out_ptr);
} else {
d_offsets[idx] = nbytes;
}
}
};
} // namespace
std::unique_ptr<column> replace_re(strings_column_view const& input,
std::vector<std::string> const& patterns,
strings_column_view const& replacements,
regex_flags const flags,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) { return make_empty_column(type_id::STRING); }
if (patterns.empty()) { // if no patterns; just return a copy
return std::make_unique<column>(input.parent(), stream, mr);
}
CUDF_EXPECTS(!replacements.has_nulls(), "Parameter replacements must not have any nulls");
// compile regexes into device objects
auto h_progs = std::vector<std::unique_ptr<reprog_device, std::function<void(reprog_device*)>>>(
patterns.size());
std::transform(
patterns.begin(), patterns.end(), h_progs.begin(), [flags, stream](auto const& ptn) {
auto h_prog = regex_program::create(ptn, flags, capture_groups::NON_CAPTURE);
return regex_device_builder::create_prog_device(*h_prog, stream);
});
// get the longest regex for the dispatcher
auto const max_prog =
std::max_element(h_progs.begin(), h_progs.end(), [](auto const& lhs, auto const& rhs) {
return lhs->insts_counts() < rhs->insts_counts();
});
auto d_max_prog = **max_prog;
auto const buffer_size = d_max_prog.working_memory_size(input.size());
auto d_buffer = rmm::device_buffer(buffer_size, stream);
// copy all the reprog_device instances to a device memory array
std::vector<reprog_device> progs;
std::transform(h_progs.begin(),
h_progs.end(),
std::back_inserter(progs),
[d_buffer = d_buffer.data(), size = input.size()](auto& prog) {
prog->set_working_memory(d_buffer, size);
return *prog;
});
auto d_progs =
cudf::detail::make_device_uvector_async(progs, stream, rmm::mr::get_current_device_resource());
auto const d_strings = column_device_view::create(input.parent(), stream);
auto const d_repls = column_device_view::create(replacements.parent(), stream);
auto found_ranges = rmm::device_uvector<found_range>(d_progs.size() * input.size(), stream);
auto children = make_strings_children(
replace_multi_regex_fn{*d_strings, d_progs, found_ranges.data(), *d_repls},
input.size(),
stream,
mr);
return make_strings_column(input.size(),
std::move(children.first),
std::move(children.second),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
} // namespace detail
// external API
std::unique_ptr<column> replace_re(strings_column_view const& strings,
std::vector<std::string> const& patterns,
strings_column_view const& replacements,
regex_flags const flags,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace_re(strings, patterns, replacements, flags, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/replace/replace_re.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <strings/regex/regex_program_impl.h>
#include <strings/regex/utilities.cuh>
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/replace_re.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief This functor handles replacing strings by applying the compiled regex pattern
* and inserting the new string within the matched range of characters.
*/
struct replace_regex_fn {
column_device_view const d_strings;
string_view const d_repl;
size_type const maxrepl;
size_type* d_offsets{};
char* d_chars{};
__device__ void operator()(size_type const idx, reprog_device const prog, int32_t const prog_idx)
{
if (d_strings.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto const d_str = d_strings.element<string_view>(idx);
auto const nchars = d_str.length();
auto nbytes = d_str.size_bytes(); // number of bytes in input string
auto mxn = maxrepl < 0 ? nchars + 1 : maxrepl; // max possible replaces for this string
auto in_ptr = d_str.data(); // input pointer (i)
auto out_ptr = d_chars ? d_chars + d_offsets[idx] // output pointer (o)
: nullptr;
auto itr = d_str.begin();
auto last_pos = itr;
// copy input to output replacing strings as we go
while (mxn-- > 0 && itr.position() <= nchars && !prog.is_empty()) {
auto const match = prog.find(prog_idx, d_str, itr);
if (!match) { break; } // no more matches
auto const [start_pos, end_pos] = match_positions_to_bytes(*match, d_str, last_pos);
nbytes += d_repl.size_bytes() - (end_pos - start_pos); // add new size
if (out_ptr) { // replace:
// i:bbbbsssseeee
out_ptr = copy_and_increment(out_ptr, // ^
in_ptr + last_pos.byte_offset(), // o:bbbb
start_pos - last_pos.byte_offset()); // ^
out_ptr = copy_string(out_ptr, d_repl); // o:bbbbrrrrrr
} // out_ptr ---^
last_pos += (match->second - last_pos.position()); // i:bbbbsssseeee
// in_ptr --^
itr = last_pos + (match->first == match->second);
}
if (out_ptr) {
thrust::copy_n(thrust::seq, // copy the remainder
in_ptr + last_pos.byte_offset(), // o:bbbbrrrrrreeee
d_str.size_bytes() - last_pos.byte_offset(), // ^ ^
out_ptr);
} else {
d_offsets[idx] = nbytes;
}
}
};
} // namespace
//
std::unique_ptr<column> replace_re(strings_column_view const& input,
regex_program const& prog,
string_scalar const& replacement,
std::optional<size_type> max_replace_count,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) return make_empty_column(type_id::STRING);
CUDF_EXPECTS(replacement.is_valid(stream), "Parameter replacement must be valid");
string_view d_repl(replacement.data(), replacement.size());
// create device object from regex_program
auto d_prog = regex_device_builder::create_prog_device(prog, stream);
auto const maxrepl = max_replace_count.value_or(-1);
auto const d_strings = column_device_view::create(input.parent(), stream);
auto children = make_strings_children(
replace_regex_fn{*d_strings, d_repl, maxrepl}, *d_prog, input.size(), stream, mr);
return make_strings_column(input.size(),
std::move(children.first),
std::move(children.second),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
} // namespace detail
// external API
std::unique_ptr<column> replace_re(strings_column_view const& strings,
regex_program const& prog,
string_scalar const& replacement,
std::optional<size_type> max_replace_count,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace_re(strings, prog, replacement, max_replace_count, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/replace/multi.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/cuda.cuh>
#include <cudf/strings/detail/char_tables.hpp>
#include <cudf/strings/detail/replace.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/strings_column_factories.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/replace.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/span.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <thrust/binary_search.h>
#include <thrust/copy.h>
#include <thrust/count.h>
#include <thrust/distance.h>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/optional.h>
#include <thrust/scan.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Threshold to decide on using string or character-parallel functions.
*
* If the average byte length of a string in a column exceeds this value then
* the character-parallel function is used.
* Otherwise, a regular string-parallel function is used.
*
* This value was found using the replace-multi benchmark results using an
* RTX A6000.
*/
constexpr size_type AVG_CHAR_BYTES_THRESHOLD = 256;
/**
* @brief Type used for holding the target position (first) and the
* target index (second).
*/
using target_pair = thrust::pair<size_type, size_type>;
/**
* @brief Helper functions for performing character-parallel replace
*/
struct replace_multi_parallel_fn {
__device__ char const* get_base_ptr() const
{
return d_strings.child(strings_column_view::chars_column_index).data<char>();
}
__device__ size_type const* get_offsets_ptr() const
{
return d_strings.child(strings_column_view::offsets_column_index).data<size_type>() +
d_strings.offset();
}
__device__ string_view const get_string(size_type idx) const
{
return d_strings.element<string_view>(idx);
}
__device__ string_view const get_replacement_string(size_type idx) const
{
return d_replacements.size() == 1 ? d_replacements[0] : d_replacements[idx];
}
__device__ bool is_valid(size_type idx) const { return d_strings.is_valid(idx); }
/**
* @brief Returns the index of the target string found at the given byte position
* in the input strings column
*
* @param idx Index of the byte position in the chars column
* @param chars_bytes Number of bytes in the chars column
*/
__device__ thrust::optional<size_type> has_target(size_type idx, size_type chars_bytes) const
{
auto const d_offsets = get_offsets_ptr();
auto const d_chars = get_base_ptr() + d_offsets[0] + idx;
size_type str_idx = -1;
for (std::size_t t = 0; t < d_targets.size(); ++t) {
auto const d_tgt = d_targets[t];
if (!d_tgt.empty() && (idx + d_tgt.size_bytes() <= chars_bytes) &&
(d_tgt.compare(d_chars, d_tgt.size_bytes()) == 0)) {
if (str_idx < 0) {
auto const idx_itr =
thrust::upper_bound(thrust::seq, d_offsets, d_offsets + d_strings.size(), idx);
str_idx = thrust::distance(d_offsets, idx_itr) - 1;
}
auto const d_str = get_string(str_idx - d_offsets[0]);
if ((d_chars + d_tgt.size_bytes()) <= (d_str.data() + d_str.size_bytes())) { return t; }
}
}
return thrust::nullopt;
}
/**
* @brief Count the number of strings that will be produced by the replace
*
* This includes segments of the string that are not replaced as well as those
* that are replaced.
*
* @param idx Index of the row in d_strings to be processed
* @param d_positions Positions of the targets found in the chars column
* @param d_targets_offsets Offsets identify which target positions go with the current string
* @return Number of substrings resulting from the replace operations on this row
*/
__device__ size_type count_strings(size_type idx,
target_pair const* d_positions,
size_type const* d_targets_offsets) const
{
if (!is_valid(idx)) { return 0; }
auto const d_str = get_string(idx);
auto const d_str_end = d_str.data() + d_str.size_bytes();
auto const base_ptr = get_base_ptr();
auto const targets_positions = cudf::device_span<target_pair const>(
d_positions + d_targets_offsets[idx], d_targets_offsets[idx + 1] - d_targets_offsets[idx]);
size_type count = 1; // always at least one string
auto str_ptr = d_str.data();
for (auto d_pair : targets_positions) {
auto const d_pos = d_pair.first;
auto const d_tgt = d_targets[d_pair.second];
auto const tgt_ptr = base_ptr + d_pos;
if (str_ptr <= tgt_ptr && tgt_ptr < d_str_end) {
auto const keep_size = static_cast<size_type>(thrust::distance(str_ptr, tgt_ptr));
if (keep_size > 0) { count++; } // don't bother counting empty strings
auto const d_repl = get_replacement_string(d_pair.second);
if (!d_repl.empty()) { count++; }
str_ptr += keep_size + d_tgt.size_bytes();
}
}
return count;
}
/**
* @brief Retrieve the strings for each row
*
* This will return string segments as string_index_pair objects for
* parts of the string that are not replaced interlaced with the
* appropriate replacement string where replacement targets are found.
*
* This function is called only once to produce both the string_index_pair objects
* and the output row size in bytes.
*
* @param idx Index of the row in d_strings
* @param d_offsets Offsets to identify where to store the results of the replace for this string
* @param d_positions The target positions found in the chars column
* @param d_targets_offsets The offsets to identify which target positions go with this string
* @param d_all_strings The output of all the produced string segments
* @return The size in bytes of the output string for this row
*/
__device__ size_type get_strings(size_type idx,
size_type const* d_offsets,
target_pair const* d_positions,
size_type const* d_targets_offsets,
string_index_pair* d_all_strings) const
{
if (!is_valid(idx)) { return 0; }
auto const d_output = d_all_strings + d_offsets[idx];
auto const d_str = get_string(idx);
auto const d_str_end = d_str.data() + d_str.size_bytes();
auto const base_ptr = get_base_ptr();
auto const targets_positions = cudf::device_span<target_pair const>(
d_positions + d_targets_offsets[idx], d_targets_offsets[idx + 1] - d_targets_offsets[idx]);
size_type output_idx = 0;
size_type output_size = 0;
auto str_ptr = d_str.data();
for (auto d_pair : targets_positions) {
auto const d_pos = d_pair.first;
auto const d_tgt = d_targets[d_pair.second];
auto const tgt_ptr = base_ptr + d_pos;
if (str_ptr <= tgt_ptr && tgt_ptr < d_str_end) {
auto const keep_size = static_cast<size_type>(thrust::distance(str_ptr, tgt_ptr));
if (keep_size > 0) { d_output[output_idx++] = string_index_pair{str_ptr, keep_size}; }
output_size += keep_size;
auto const d_repl = get_replacement_string(d_pair.second);
if (!d_repl.empty()) {
d_output[output_idx++] = string_index_pair{d_repl.data(), d_repl.size_bytes()};
}
output_size += d_repl.size_bytes();
str_ptr += keep_size + d_tgt.size_bytes();
}
}
// include any leftover parts of the string
if (str_ptr <= d_str_end) {
auto const left_size = static_cast<size_type>(thrust::distance(str_ptr, d_str_end));
d_output[output_idx] = string_index_pair{str_ptr, left_size};
output_size += left_size;
}
return output_size;
}
replace_multi_parallel_fn(column_device_view const& d_strings,
device_span<string_view const> d_targets,
device_span<string_view const> d_replacements)
: d_strings(d_strings), d_targets{d_targets}, d_replacements{d_replacements}
{
}
protected:
column_device_view d_strings;
device_span<string_view const> d_targets;
device_span<string_view const> d_replacements;
};
/**
* @brief Used by the copy-if function to produce target_pair objects
*
* Using an inplace lambda caused a runtime crash in thrust::copy_if
* (this happens sometimes when passing device lambdas to thrust algorithms)
*/
struct pair_generator {
__device__ target_pair operator()(int idx) const
{
auto pos = fn.has_target(idx, chars_bytes);
return target_pair{idx, pos.value_or(-1)};
}
replace_multi_parallel_fn fn;
size_type chars_bytes;
};
struct copy_if_fn {
__device__ bool operator()(target_pair pos) { return pos.second >= 0; }
};
std::unique_ptr<column> replace_character_parallel(strings_column_view const& input,
strings_column_view const& targets,
strings_column_view const& repls,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto d_strings = column_device_view::create(input.parent(), stream);
auto const strings_count = input.size();
auto const chars_bytes =
cudf::detail::get_value<size_type>(input.offsets(), input.offset() + strings_count, stream) -
cudf::detail::get_value<size_type>(input.offsets(), input.offset(), stream);
auto d_targets =
create_string_vector_from_column(targets, stream, rmm::mr::get_current_device_resource());
auto d_replacements =
create_string_vector_from_column(repls, stream, rmm::mr::get_current_device_resource());
replace_multi_parallel_fn fn{*d_strings, d_targets, d_replacements};
// count the number of targets in the entire column
auto const target_count = thrust::count_if(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(chars_bytes),
[fn, chars_bytes] __device__(size_type idx) {
return fn.has_target(idx, chars_bytes).has_value();
});
// Create a vector of every target position in the chars column.
// These may include overlapping targets which will be resolved later.
auto targets_positions = rmm::device_uvector<target_pair>(target_count, stream);
auto d_positions = targets_positions.data();
auto const copy_itr =
cudf::detail::make_counting_transform_iterator(0, pair_generator{fn, chars_bytes});
auto const copy_end = thrust::copy_if(
rmm::exec_policy(stream), copy_itr, copy_itr + chars_bytes, d_positions, copy_if_fn{});
// create a vector of offsets to each string's set of target positions
auto const targets_offsets = [&] {
auto string_indices = rmm::device_uvector<size_type>(target_count, stream);
auto const pos_itr = cudf::detail::make_counting_transform_iterator(
0, [d_positions] __device__(auto idx) -> size_type { return d_positions[idx].first; });
auto pos_count = std::distance(d_positions, copy_end);
thrust::upper_bound(rmm::exec_policy(stream),
input.offsets_begin(),
input.offsets_end(),
pos_itr,
pos_itr + pos_count,
string_indices.begin());
// compute offsets per string
auto targets_offsets = rmm::device_uvector<size_type>(strings_count + 1, stream);
auto d_targets_offsets = targets_offsets.data();
// memset to zero-out the target counts for any null-entries or strings with no targets
thrust::uninitialized_fill(
rmm::exec_policy(stream), targets_offsets.begin(), targets_offsets.end(), 0);
// next, count the number of targets per string
auto d_string_indices = string_indices.data();
thrust::for_each_n(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
target_count,
[d_string_indices, d_targets_offsets] __device__(size_type idx) {
auto const str_idx = d_string_indices[idx] - 1;
atomicAdd(d_targets_offsets + str_idx, 1);
});
// finally, convert the counts into offsets
thrust::exclusive_scan(rmm::exec_policy(stream),
targets_offsets.begin(),
targets_offsets.end(),
targets_offsets.begin());
return targets_offsets;
}();
auto const d_targets_offsets = targets_offsets.data();
// compute the number of string segments produced by replace in each string
auto counts = rmm::device_uvector<size_type>(strings_count, stream);
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_count),
counts.begin(),
[fn, d_positions, d_targets_offsets] __device__(size_type idx) -> size_type {
return fn.count_strings(idx, d_positions, d_targets_offsets);
});
// create offsets from the counts
auto offsets =
std::get<0>(cudf::detail::make_offsets_child_column(counts.begin(), counts.end(), stream, mr));
auto const total_strings =
cudf::detail::get_value<size_type>(offsets->view(), strings_count, stream);
auto const d_strings_offsets = offsets->view().data<size_type>();
// build a vector of all the positions for all the strings
auto indices = rmm::device_uvector<string_index_pair>(total_strings, stream);
auto d_indices = indices.data();
auto d_sizes = counts.data(); // reusing this vector to hold output sizes now
thrust::for_each_n(
rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
strings_count,
[fn, d_strings_offsets, d_positions, d_targets_offsets, d_indices, d_sizes] __device__(
size_type idx) {
d_sizes[idx] =
fn.get_strings(idx, d_strings_offsets, d_positions, d_targets_offsets, d_indices);
});
// use this utility to gather the string parts into a contiguous chars column
auto chars = make_strings_column(indices.begin(), indices.end(), stream, mr);
// create offsets from the sizes
offsets =
std::get<0>(cudf::detail::make_offsets_child_column(counts.begin(), counts.end(), stream, mr));
// build the strings columns from the chars and offsets
return make_strings_column(strings_count,
std::move(offsets),
std::move(chars->release().children.back()),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
/**
* @brief Function logic for the replace_string_parallel
*
* Performs the multi-replace operation with a thread per string.
* This performs best on smaller strings. @see AVG_CHAR_BYTES_THRESHOLD
*/
struct replace_multi_fn {
column_device_view const d_strings;
column_device_view const d_targets;
column_device_view const d_repls;
int32_t* d_offsets{};
char* d_chars{};
__device__ void operator()(size_type idx)
{
if (d_strings.is_null(idx)) {
if (!d_chars) { d_offsets[idx] = 0; }
return;
}
auto const d_str = d_strings.element<string_view>(idx);
char const* in_ptr = d_str.data();
size_type bytes = d_str.size_bytes();
size_type spos = 0;
size_type lpos = 0;
char* out_ptr = d_chars ? d_chars + d_offsets[idx] : nullptr;
// check each character against each target
while (spos < d_str.size_bytes()) {
for (int tgt_idx = 0; tgt_idx < d_targets.size(); ++tgt_idx) {
auto const d_tgt = d_targets.element<string_view>(tgt_idx);
if ((d_tgt.size_bytes() <= (d_str.size_bytes() - spos)) && // check fit
(d_tgt.compare(in_ptr + spos, d_tgt.size_bytes()) == 0)) // and match
{
auto const d_repl = (d_repls.size() == 1) ? d_repls.element<string_view>(0)
: d_repls.element<string_view>(tgt_idx);
bytes += d_repl.size_bytes() - d_tgt.size_bytes();
if (out_ptr) {
out_ptr = copy_and_increment(out_ptr, in_ptr + lpos, spos - lpos);
out_ptr = copy_string(out_ptr, d_repl);
lpos = spos + d_tgt.size_bytes();
}
spos += d_tgt.size_bytes() - 1;
break;
}
}
++spos;
}
if (out_ptr) // copy remainder
memcpy(out_ptr, in_ptr + lpos, d_str.size_bytes() - lpos);
else
d_offsets[idx] = bytes;
}
};
std::unique_ptr<column> replace_string_parallel(strings_column_view const& input,
strings_column_view const& targets,
strings_column_view const& repls,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto d_strings = column_device_view::create(input.parent(), stream);
auto d_targets = column_device_view::create(targets.parent(), stream);
auto d_replacements = column_device_view::create(repls.parent(), stream);
auto children = cudf::strings::detail::make_strings_children(
replace_multi_fn{*d_strings, *d_targets, *d_replacements}, input.size(), stream, mr);
return make_strings_column(input.size(),
std::move(children.first),
std::move(children.second),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
} // namespace
std::unique_ptr<column> replace(strings_column_view const& input,
strings_column_view const& targets,
strings_column_view const& repls,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) { return make_empty_column(type_id::STRING); }
CUDF_EXPECTS(((targets.size() > 0) && (targets.null_count() == 0)),
"Parameters targets must not be empty and must not have nulls");
CUDF_EXPECTS(((repls.size() > 0) && (repls.null_count() == 0)),
"Parameters repls must not be empty and must not have nulls");
if (repls.size() > 1)
CUDF_EXPECTS(repls.size() == targets.size(), "Sizes for targets and repls must match");
return (input.size() == input.null_count() ||
((input.chars_size() / (input.size() - input.null_count())) < AVG_CHAR_BYTES_THRESHOLD))
? replace_string_parallel(input, targets, repls, stream, mr)
: replace_character_parallel(input, targets, repls, stream, mr);
}
} // namespace detail
// external API
std::unique_ptr<column> replace(strings_column_view const& strings,
strings_column_view const& targets,
strings_column_view const& repls,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::replace(strings, targets, repls, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/replace/backref_re.cuh
|
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <strings/regex/regex.cuh>
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/string_view.cuh>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/pair.h>
namespace cudf {
namespace strings {
namespace detail {
using backref_type = thrust::pair<size_type, size_type>;
/**
* @brief This functor handles replacing strings by applying the compiled regex pattern
* and inserting the at the backref position indicated in the replacement template.
*
* The logic includes computing the size of each string and also writing the output.
*/
template <typename Iterator>
struct backrefs_fn {
column_device_view const d_strings;
string_view const d_repl; // string replacement template
Iterator backrefs_begin;
Iterator backrefs_end;
size_type* d_offsets{};
char* d_chars{};
__device__ void operator()(size_type const idx, reprog_device const prog, int32_t const prog_idx)
{
if (d_strings.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto const d_str = d_strings.element<string_view>(idx);
auto const in_ptr = d_str.data();
auto const nchars = d_str.length(); // number of characters in input string
auto nbytes = d_str.size_bytes(); // number of bytes for the output string
auto out_ptr = d_chars ? (d_chars + d_offsets[idx]) : nullptr;
auto itr = d_str.begin();
auto last_pos = itr;
// copy input to output replacing strings as we go
while (itr.position() <= nchars) // inits the begin/end vars
{
auto const match = prog.find(prog_idx, d_str, itr);
if (!match) { break; }
auto const [start_pos, end_pos] = match_positions_to_bytes(*match, d_str, itr);
nbytes += d_repl.size_bytes() - (end_pos - start_pos); // compute the output size
// copy the string data before the matched section
if (out_ptr) {
out_ptr = copy_and_increment(
out_ptr, in_ptr + last_pos.byte_offset(), start_pos - last_pos.byte_offset());
}
size_type lpos_template = 0; // last end pos of replace template
auto const repl_ptr = d_repl.data(); // replace template pattern
itr += (match->first - itr.position());
thrust::for_each(
thrust::seq, backrefs_begin, backrefs_end, [&] __device__(backref_type backref) {
if (out_ptr) {
auto const copy_length = backref.second - lpos_template;
out_ptr = copy_and_increment(out_ptr, repl_ptr + lpos_template, copy_length);
lpos_template += copy_length;
}
// extract the specific group's string for this backref's index
auto extracted = prog.extract(prog_idx, d_str, itr, match->second, backref.first - 1);
if (!extracted || (extracted->second < extracted->first)) {
return; // no value for this backref number; that is ok
}
auto const d_str_ex = string_from_match(*extracted, d_str, itr);
nbytes += d_str_ex.size_bytes();
if (out_ptr) { out_ptr = copy_string(out_ptr, d_str_ex); }
});
// copy remainder of template
if (out_ptr && (lpos_template < d_repl.size_bytes())) {
out_ptr = copy_and_increment(
out_ptr, repl_ptr + lpos_template, d_repl.size_bytes() - lpos_template);
}
// setup to match the next section
last_pos += (match->second - last_pos.position());
itr = last_pos + (match->first == match->second);
}
// finally, copy remainder of input string
if (out_ptr) {
thrust::copy_n(
thrust::seq, in_ptr + itr.byte_offset(), d_str.size_bytes() - itr.byte_offset(), out_ptr);
} else {
d_offsets[idx] = nbytes;
}
}
};
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/filling/fill.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/valid_if.cuh>
#include <cudf/null_mask.hpp>
#include <cudf/scalar/scalar_device_view.cuh>
#include <cudf/strings/detail/fill.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
namespace cudf {
namespace strings {
namespace detail {
std::unique_ptr<column> fill(strings_column_view const& strings,
size_type begin,
size_type end,
string_scalar const& value,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto strings_count = strings.size();
if (strings_count == 0) return make_empty_column(type_id::STRING);
CUDF_EXPECTS((begin >= 0) && (end <= strings_count),
"Parameters [begin,end) are outside the range of the provided strings column");
CUDF_EXPECTS(begin <= end, "Parameters [begin,end) have invalid range values");
if (begin == end) // return a copy
return std::make_unique<column>(strings.parent(), stream, mr);
// string_scalar.data() is null for valid, empty strings
auto d_value = get_scalar_device_view(const_cast<string_scalar&>(value));
auto strings_column = column_device_view::create(strings.parent(), stream);
auto d_strings = *strings_column;
// create resulting null mask
auto valid_mask = [begin, end, d_value, value, d_strings, stream, mr] {
if (begin == 0 and end == d_strings.size() and value.is_valid(stream))
return std::pair(rmm::device_buffer{}, 0);
return cudf::detail::valid_if(
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(d_strings.size()),
[d_strings, begin, end, d_value] __device__(size_type idx) {
return ((begin <= idx) && (idx < end)) ? d_value.is_valid() : !d_strings.is_null(idx);
},
stream,
mr);
}();
auto null_count = valid_mask.second;
rmm::device_buffer& null_mask = valid_mask.first;
// build offsets column
auto offsets_transformer = [d_strings, begin, end, d_value] __device__(size_type idx) {
if (((begin <= idx) && (idx < end)) ? !d_value.is_valid() : d_strings.is_null(idx)) return 0;
return ((begin <= idx) && (idx < end)) ? d_value.size()
: d_strings.element<string_view>(idx).size_bytes();
};
auto offsets_transformer_itr = thrust::make_transform_iterator(
thrust::make_counting_iterator<size_type>(0), offsets_transformer);
auto [offsets_column, bytes] = cudf::detail::make_offsets_child_column(
offsets_transformer_itr, offsets_transformer_itr + strings_count, stream, mr);
auto d_offsets = offsets_column->view().data<int32_t>();
// create the chars column
auto chars_column = create_chars_child_column(bytes, stream, mr);
// fill the chars column
auto d_chars = chars_column->mutable_view().data<char>();
thrust::for_each_n(
rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
strings_count,
[d_strings, begin, end, d_value, d_offsets, d_chars] __device__(size_type idx) {
if (((begin <= idx) && (idx < end)) ? !d_value.is_valid() : d_strings.is_null(idx)) return;
string_view const d_str =
((begin <= idx) && (idx < end)) ? d_value.value() : d_strings.element<string_view>(idx);
memcpy(d_chars + d_offsets[idx], d_str.data(), d_str.size_bytes());
});
return make_strings_column(strings_count,
std::move(offsets_column),
std::move(chars_column),
null_count,
std::move(null_mask));
}
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/char_types/char_types.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/char_types/char_types.hpp>
#include <cudf/strings/detail/char_tables.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utf8.hpp>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Returns true for each string where all characters match the given types.
*
* Only the characters that match to `verify_types` are checked.
* Returns false if no characters are checked or one character does not match `types`.
* Returns true if at least one character is checked and all checked characters match `types`.
*/
struct char_types_fn {
column_device_view const d_column;
character_flags_table_type const* d_flags;
string_character_types const types;
string_character_types const verify_types;
__device__ bool operator()(size_type idx) const
{
if (d_column.is_null(idx)) { return false; }
auto const d_str = d_column.element<string_view>(idx);
auto const end = d_str.data() + d_str.size_bytes();
bool type_matched = !d_str.empty(); // require at least one character;
size_type check_count = 0; // count checked characters
for (auto itr = d_str.data(); type_matched && (itr < end); ++itr) {
uint8_t const chr = static_cast<uint8_t>(*itr);
if (is_utf8_continuation_char(chr)) { continue; }
auto u8 = static_cast<char_utf8>(chr); // holds UTF8 value
// using max(int8) here since max(char)=255 on ARM systems
if (u8 > std::numeric_limits<int8_t>::max()) { to_char_utf8(itr, u8); }
// lookup flags in table by codepoint
auto const code_point = utf8_to_codepoint(u8);
auto const flag = code_point <= 0x00'FFFF ? d_flags[code_point] : 0;
if ((verify_types & flag) || // should flag be verified;
(flag == 0 && verify_types == ALL_TYPES)) // special edge case
{
type_matched = (types & flag) > 0;
++check_count;
}
}
return type_matched && (check_count > 0);
}
};
} // namespace
std::unique_ptr<column> all_characters_of_type(strings_column_view const& input,
string_character_types types,
string_character_types verify_types,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto d_strings = column_device_view::create(input.parent(), stream);
// create output column
auto results = make_numeric_column(data_type{type_id::BOOL8},
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
// get the static character types table
auto d_flags = detail::get_character_flags_table();
// set the output values by checking the character types for each string
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(input.size()),
results->mutable_view().data<bool>(),
char_types_fn{*d_strings, d_flags, types, verify_types});
results->set_null_count(input.null_count());
return results;
}
namespace {
/**
* @brief Removes individual characters from a strings column based on character type.
*
* Types to remove are specified by `types_to_remove` OR
* types to not remove are specified by `types_to_keep`.
*
* This is called twice. The first pass calculates the size of each output string.
* The final pass copies the results to the output strings column memory.
*/
struct filter_chars_fn {
column_device_view const d_column;
character_flags_table_type const* d_flags;
string_character_types const types_to_remove;
string_character_types const types_to_keep;
string_view const d_replacement; ///< optional replacement for removed characters
int32_t* d_offsets{}; ///< size of the output string stored here during first pass
char* d_chars{}; ///< this is null only during the first pass
/**
* @brief Returns true if the given character should be replaced.
*/
__device__ bool replace_char(char_utf8 ch)
{
auto const code_point = detail::utf8_to_codepoint(ch);
auto const flag = code_point <= 0x00'FFFF ? d_flags[code_point] : 0;
if (flag == 0) // all types pass unless specifically identified
return (types_to_remove == ALL_TYPES);
if (types_to_keep == ALL_TYPES) // filter case
return (types_to_remove & flag) != 0;
return (types_to_keep & flag) == 0; // keep case
}
__device__ void operator()(size_type idx)
{
if (d_column.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto const d_str = d_column.element<string_view>(idx);
auto const in_ptr = d_str.data();
auto out_ptr = d_chars ? d_chars + d_offsets[idx] : nullptr;
auto nbytes = d_str.size_bytes();
for (auto itr = d_str.begin(); itr != d_str.end(); ++itr) {
auto const char_size = bytes_in_char_utf8(*itr);
string_view const d_newchar =
replace_char(*itr) ? d_replacement : string_view(in_ptr + itr.byte_offset(), char_size);
nbytes += d_newchar.size_bytes() - char_size;
if (out_ptr) out_ptr = cudf::strings::detail::copy_string(out_ptr, d_newchar);
}
if (!out_ptr) d_offsets[idx] = nbytes;
}
};
} // namespace
std::unique_ptr<column> filter_characters_of_type(strings_column_view const& strings,
string_character_types types_to_remove,
string_scalar const& replacement,
string_character_types types_to_keep,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(replacement.is_valid(stream), "Parameter replacement must be valid");
if (types_to_remove == ALL_TYPES)
CUDF_EXPECTS(types_to_keep != ALL_TYPES,
"Parameters types_to_remove and types_to_keep must not be both ALL_TYPES");
else
CUDF_EXPECTS(types_to_keep == ALL_TYPES,
"One of parameter types_to_remove and types_to_keep must be set to ALL_TYPES");
auto const strings_count = strings.size();
if (strings_count == 0) return make_empty_column(cudf::data_type{cudf::type_id::STRING});
auto strings_column = cudf::column_device_view::create(strings.parent(), stream);
cudf::string_view d_replacement(replacement.data(), replacement.size());
filter_chars_fn filterer{*strings_column,
detail::get_character_flags_table(),
types_to_remove,
types_to_keep,
d_replacement};
// copy null mask from input column
rmm::device_buffer null_mask = cudf::detail::copy_bitmask(strings.parent(), stream, mr);
// this utility calls filterer to build the offsets and chars columns
auto children = cudf::strings::detail::make_strings_children(filterer, strings_count, stream, mr);
// return new strings column
return make_strings_column(strings_count,
std::move(children.first),
std::move(children.second),
strings.null_count(),
std::move(null_mask));
}
} // namespace detail
// external API
std::unique_ptr<column> all_characters_of_type(strings_column_view const& input,
string_character_types types,
string_character_types verify_types,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::all_characters_of_type(input, types, verify_types, stream, mr);
}
std::unique_ptr<column> filter_characters_of_type(strings_column_view const& input,
string_character_types types_to_remove,
string_scalar const& replacement,
string_character_types types_to_keep,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::filter_characters_of_type(
input, types_to_remove, replacement, types_to_keep, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/char_types/char_cases.cu
|
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <algorithm>
#include <array>
#include <unordered_set>
#include <vector>
#include <cudf/utilities/error.hpp>
//
namespace cudf {
namespace strings {
namespace detail {
namespace {
struct special_case_mapping_in {
uint16_t num_upper_chars;
uint16_t upper[3];
uint16_t num_lower_chars;
uint16_t lower[3];
};
constexpr special_case_mapping_in codepoint_mapping_in[] = {
{2, {83, 83, 0}, 0, {0, 0, 0}}, {0, {0, 0, 0}, 2, {105, 775, 0}},
{2, {700, 78, 0}, 0, {0, 0, 0}}, {1, {452, 0, 0}, 1, {454, 0, 0}},
{1, {455, 0, 0}, 1, {457, 0, 0}}, {1, {458, 0, 0}, 1, {460, 0, 0}},
{2, {74, 780, 0}, 0, {0, 0, 0}}, {1, {497, 0, 0}, 1, {499, 0, 0}},
{3, {921, 776, 769}, 0, {0, 0, 0}}, {3, {933, 776, 769}, 0, {0, 0, 0}},
{2, {1333, 1362, 0}, 0, {0, 0, 0}}, {2, {72, 817, 0}, 0, {0, 0, 0}},
{2, {84, 776, 0}, 0, {0, 0, 0}}, {2, {87, 778, 0}, 0, {0, 0, 0}},
{2, {89, 778, 0}, 0, {0, 0, 0}}, {2, {65, 702, 0}, 0, {0, 0, 0}},
{2, {933, 787, 0}, 0, {0, 0, 0}}, {3, {933, 787, 768}, 0, {0, 0, 0}},
{3, {933, 787, 769}, 0, {0, 0, 0}}, {3, {933, 787, 834}, 0, {0, 0, 0}},
{2, {7944, 921, 0}, 0, {0, 0, 0}}, {2, {7945, 921, 0}, 0, {0, 0, 0}},
{2, {7946, 921, 0}, 0, {0, 0, 0}}, {2, {7947, 921, 0}, 0, {0, 0, 0}},
{2, {7948, 921, 0}, 0, {0, 0, 0}}, {2, {7949, 921, 0}, 0, {0, 0, 0}},
{2, {7950, 921, 0}, 0, {0, 0, 0}}, {2, {7951, 921, 0}, 0, {0, 0, 0}},
{2, {7944, 921, 0}, 1, {8064, 0, 0}}, {2, {7945, 921, 0}, 1, {8065, 0, 0}},
{2, {7946, 921, 0}, 1, {8066, 0, 0}}, {2, {7947, 921, 0}, 1, {8067, 0, 0}},
{2, {7948, 921, 0}, 1, {8068, 0, 0}}, {2, {7949, 921, 0}, 1, {8069, 0, 0}},
{2, {7950, 921, 0}, 1, {8070, 0, 0}}, {2, {7951, 921, 0}, 1, {8071, 0, 0}},
{2, {7976, 921, 0}, 0, {0, 0, 0}}, {2, {7977, 921, 0}, 0, {0, 0, 0}},
{2, {7978, 921, 0}, 0, {0, 0, 0}}, {2, {7979, 921, 0}, 0, {0, 0, 0}},
{2, {7980, 921, 0}, 0, {0, 0, 0}}, {2, {7981, 921, 0}, 0, {0, 0, 0}},
{2, {7982, 921, 0}, 0, {0, 0, 0}}, {2, {7983, 921, 0}, 0, {0, 0, 0}},
{2, {7976, 921, 0}, 1, {8080, 0, 0}}, {2, {7977, 921, 0}, 1, {8081, 0, 0}},
{2, {7978, 921, 0}, 1, {8082, 0, 0}}, {2, {7979, 921, 0}, 1, {8083, 0, 0}},
{2, {7980, 921, 0}, 1, {8084, 0, 0}}, {2, {7981, 921, 0}, 1, {8085, 0, 0}},
{2, {7982, 921, 0}, 1, {8086, 0, 0}}, {2, {7983, 921, 0}, 1, {8087, 0, 0}},
{2, {8040, 921, 0}, 0, {0, 0, 0}}, {2, {8041, 921, 0}, 0, {0, 0, 0}},
{2, {8042, 921, 0}, 0, {0, 0, 0}}, {2, {8043, 921, 0}, 0, {0, 0, 0}},
{2, {8044, 921, 0}, 0, {0, 0, 0}}, {2, {8045, 921, 0}, 0, {0, 0, 0}},
{2, {8046, 921, 0}, 0, {0, 0, 0}}, {2, {8047, 921, 0}, 0, {0, 0, 0}},
{2, {8040, 921, 0}, 1, {8096, 0, 0}}, {2, {8041, 921, 0}, 1, {8097, 0, 0}},
{2, {8042, 921, 0}, 1, {8098, 0, 0}}, {2, {8043, 921, 0}, 1, {8099, 0, 0}},
{2, {8044, 921, 0}, 1, {8100, 0, 0}}, {2, {8045, 921, 0}, 1, {8101, 0, 0}},
{2, {8046, 921, 0}, 1, {8102, 0, 0}}, {2, {8047, 921, 0}, 1, {8103, 0, 0}},
{2, {8122, 921, 0}, 0, {0, 0, 0}}, {2, {913, 921, 0}, 0, {0, 0, 0}},
{2, {902, 921, 0}, 0, {0, 0, 0}}, {2, {913, 834, 0}, 0, {0, 0, 0}},
{3, {913, 834, 921}, 0, {0, 0, 0}}, {2, {913, 921, 0}, 1, {8115, 0, 0}},
{2, {8138, 921, 0}, 0, {0, 0, 0}}, {2, {919, 921, 0}, 0, {0, 0, 0}},
{2, {905, 921, 0}, 0, {0, 0, 0}}, {2, {919, 834, 0}, 0, {0, 0, 0}},
{3, {919, 834, 921}, 0, {0, 0, 0}}, {2, {919, 921, 0}, 1, {8131, 0, 0}},
{3, {921, 776, 768}, 0, {0, 0, 0}}, {3, {921, 776, 769}, 0, {0, 0, 0}},
{2, {921, 834, 0}, 0, {0, 0, 0}}, {3, {921, 776, 834}, 0, {0, 0, 0}},
{3, {933, 776, 768}, 0, {0, 0, 0}}, {3, {933, 776, 769}, 0, {0, 0, 0}},
{2, {929, 787, 0}, 0, {0, 0, 0}}, {2, {933, 834, 0}, 0, {0, 0, 0}},
{3, {933, 776, 834}, 0, {0, 0, 0}}, {2, {8186, 921, 0}, 0, {0, 0, 0}},
{2, {937, 921, 0}, 0, {0, 0, 0}}, {2, {911, 921, 0}, 0, {0, 0, 0}},
{2, {937, 834, 0}, 0, {0, 0, 0}}, {3, {937, 834, 921}, 0, {0, 0, 0}},
{2, {937, 921, 0}, 1, {8179, 0, 0}}, {2, {70, 70, 0}, 0, {0, 0, 0}},
{2, {70, 73, 0}, 0, {0, 0, 0}}, {2, {70, 76, 0}, 0, {0, 0, 0}},
{3, {70, 70, 73}, 0, {0, 0, 0}}, {3, {70, 70, 76}, 0, {0, 0, 0}},
{2, {83, 84, 0}, 0, {0, 0, 0}}, {2, {83, 84, 0}, 0, {0, 0, 0}},
{2, {1348, 1350, 0}, 0, {0, 0, 0}}, {2, {1348, 1333, 0}, 0, {0, 0, 0}},
{2, {1348, 1339, 0}, 0, {0, 0, 0}}, {2, {1358, 1350, 0}, 0, {0, 0, 0}},
{2, {1348, 1341, 0}, 0, {0, 0, 0}},
};
constexpr std::array<uint16_t, 107> codepoints_in = {
223, 304, 329, 453, 456, 459, 496, 498, 912, 944, 1415, 7830, 7831, 7832,
7833, 7834, 8016, 8018, 8020, 8022, 8064, 8065, 8066, 8067, 8068, 8069, 8070, 8071,
8072, 8073, 8074, 8075, 8076, 8077, 8078, 8079, 8080, 8081, 8082, 8083, 8084, 8085,
8086, 8087, 8088, 8089, 8090, 8091, 8092, 8093, 8094, 8095, 8096, 8097, 8098, 8099,
8100, 8101, 8102, 8103, 8104, 8105, 8106, 8107, 8108, 8109, 8110, 8111, 8114, 8115,
8116, 8118, 8119, 8124, 8130, 8131, 8132, 8134, 8135, 8140, 8146, 8147, 8150, 8151,
8162, 8163, 8164, 8166, 8167, 8178, 8179, 8180, 8182, 8183, 8188, 64256, 64257, 64258,
64259, 64260, 64261, 64262, 64275, 64276, 64277, 64278, 64279,
};
constexpr std::array<uint16_t, 269> primes = {
227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311,
313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409,
419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503,
509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613,
617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719,
727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827,
829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049,
1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163,
1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283,
1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423,
1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511,
1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619,
1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747,
1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877,
1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003,
2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099,
};
// find a prime number that generates no collisions for all possible input data
uint16_t find_collision_proof_prime()
{
for (auto const& prime : primes) {
std::unordered_set<uint16_t> keys;
std::for_each(std::cbegin(codepoints_in),
std::cend(codepoints_in),
[&](uint16_t const codepoint) { keys.insert(codepoint % prime); });
if (keys.size() == codepoints_in.size()) return prime;
}
// couldn't find a collision-proof prime
return 0;
}
} // anonymous namespace
/**
* @copydoc cudf::strings::detail::generate_special_mapping_hash_table
*/
void generate_special_mapping_hash_table()
{
uint16_t hash_prime = find_collision_proof_prime();
if (hash_prime == 0) { CUDF_FAIL("Could not find a usable prime number for hash table"); }
// generate hash index table
// size of the table is the prime #, since we're just doing (key % hash_prime)
std::vector<std::pair<bool, uint16_t>> hash_indices(hash_prime,
std::pair<bool, uint16_t>(false, 0));
int index = 0;
std::for_each(std::begin(codepoints_in), std::end(codepoints_in), [&](uint16_t codepoint) {
hash_indices[codepoint % hash_prime].first = true;
hash_indices[codepoint % hash_prime].second = index++;
});
// print out the code
// the mappings
printf("struct special_case_mapping {\n");
printf(" uint16_t num_upper_chars;\n");
printf(" uint16_t upper[3];\n");
printf(" uint16_t num_lower_chars;\n");
printf(" uint16_t lower[3];\n");
printf("};\n");
printf("constexpr special_case_mapping g_special_case_mappings[] = {\n");
bool prev_empty = false;
std::for_each(
hash_indices.begin(), hash_indices.end(), [&prev_empty](std::pair<bool, uint16_t> entry) {
if (entry.first) {
special_case_mapping_in m = codepoint_mapping_in[entry.second];
printf("%s { %d, { %d, %d, %d }, %d, {%d, %d, %d} },\n",
prev_empty ? "\n" : "",
m.num_upper_chars,
m.upper[0],
m.upper[1],
m.upper[2],
m.num_lower_chars,
m.lower[0],
m.lower[1],
m.lower[2]);
} else {
printf("%s{},", prev_empty ? "" : " ");
}
prev_empty = !entry.first;
});
printf("};\n");
printf(
"// the special case mapping table is a perfect hash table with no collisions, allowing us\n"
"// to 'hash' by simply modding by the incoming codepoint\n"
"constexpr uint16_t get_special_case_hash_index(uint32_t code_point){\n"
" constexpr uint16_t special_case_prime = %d;\n"
" return static_cast<uint16_t>(code_point %% special_case_prime);"
"\n}\n",
hash_prime);
}
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/char_types/char_flags.h
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cstdint>
//
// 8-bit flag for each code-point.
// Bit values assigned as follows
// 7 - special casing. this character has unusual rules when it comes to
// upper casing, lower casing or title casing. typically this is because of
// a single character mapping to multiple characters upon case change. codepoints
// with this flag set go through an auxiliary hash table (g_special_case_mappings)
// instead of the trivial lookup in g_character_cases_table.
// 6 - lower
// 5 - upper
// 4 - space
// 3 - alpha
// 2 - digit
// 1 - numeric
// 0 - decimal
//
uint8_t const g_character_codepoint_flags[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 0, 0, 0, 0, 0, 0, 0, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0, 0, 0, 0,
0, 0, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72,
0, 0, 0, 0, 0, 0, 0, 6, 6, 0, 72, 0, 0, 0, 6, 72, 0, 2, 2,
2, 0, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 0, 40, 40, 40, 40, 40, 40, 40, 200, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
0, 72, 72, 72, 72, 72, 72, 72, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
168, 72, 40, 72, 40, 72, 40, 72, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 200, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 40, 72, 40,
72, 40, 72, 72, 72, 40, 40, 72, 40, 72, 40, 40, 72, 40, 40, 40, 72, 72, 40,
40, 40, 40, 72, 40, 40, 72, 40, 40, 40, 72, 72, 72, 40, 40, 72, 40, 40, 72,
40, 72, 40, 72, 40, 40, 72, 40, 72, 72, 40, 72, 40, 40, 72, 40, 40, 40, 72,
40, 72, 40, 40, 72, 72, 8, 40, 72, 72, 72, 8, 8, 8, 8, 40, 136, 72, 40,
136, 72, 40, 136, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 200, 40, 136, 72, 40, 72, 40, 40, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 72, 72, 72, 72, 72, 72,
40, 40, 72, 40, 40, 72, 72, 40, 72, 40, 40, 40, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 8, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 8, 8, 8, 8, 8, 8,
8, 72, 72, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 72, 72, 72, 72,
0, 0, 0, 0, 0, 0, 0, 8, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 40, 72, 40, 72, 8, 0, 40, 72, 0, 0, 72, 72, 72,
72, 0, 40, 0, 0, 0, 0, 0, 0, 40, 0, 40, 40, 40, 0, 40, 0, 40, 40,
200, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0,
40, 40, 40, 40, 40, 40, 40, 40, 40, 72, 72, 72, 72, 200, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 40, 72, 72, 40, 40, 40, 72, 72, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 72, 72, 72, 72, 40, 72, 0, 40, 72, 40, 40, 72, 72, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 0, 0, 0, 0, 0,
0, 0, 0, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 0, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0,
0, 8, 0, 0, 0, 0, 0, 0, 0, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0,
8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 0, 8, 8, 8, 8,
0, 0, 0, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 200, 200, 200, 200, 200, 72, 72, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 72, 72, 72, 72, 72, 72,
72, 72, 40, 40, 40, 40, 40, 40, 40, 40, 72, 72, 72, 72, 72, 72, 0, 0, 40,
40, 40, 40, 40, 40, 0, 0, 72, 72, 72, 72, 72, 72, 72, 72, 40, 40, 40, 40,
40, 40, 40, 40, 72, 72, 72, 72, 72, 72, 72, 72, 40, 40, 40, 40, 40, 40, 40,
40, 72, 72, 72, 72, 72, 72, 0, 0, 40, 40, 40, 40, 40, 40, 0, 0, 200, 72,
200, 72, 200, 72, 200, 72, 0, 40, 0, 40, 0, 40, 0, 40, 72, 72, 72, 72, 72,
72, 72, 72, 40, 40, 40, 40, 40, 40, 40, 40, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 0, 0, 200, 200, 200, 200, 200, 200, 200, 200, 136, 136, 136,
136, 136, 136, 136, 136, 200, 200, 200, 200, 200, 200, 200, 200, 136, 136, 136, 136, 136, 136,
136, 136, 200, 200, 200, 200, 200, 200, 200, 200, 136, 136, 136, 136, 136, 136, 136, 136, 72,
72, 200, 200, 200, 0, 200, 200, 40, 40, 40, 40, 136, 0, 72, 0, 0, 0, 200, 200,
200, 0, 200, 200, 40, 40, 40, 40, 136, 0, 0, 0, 72, 72, 200, 200, 0, 0, 200,
200, 40, 40, 40, 40, 0, 0, 0, 0, 72, 72, 200, 200, 200, 72, 200, 200, 40, 40,
40, 40, 40, 0, 0, 0, 0, 0, 200, 200, 200, 0, 200, 200, 40, 40, 40, 40, 136,
0, 0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 16, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 6, 72, 0, 0, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, 72, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 40, 40, 0, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 0, 40, 72,
40, 40, 40, 72, 72, 40, 72, 40, 72, 40, 72, 40, 40, 40, 40, 72, 40, 72, 72,
40, 72, 72, 72, 72, 72, 72, 72, 72, 40, 40, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 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, 7, 7, 7, 7, 7, 7, 8, 8, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 8, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 72, 72, 0,
0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 72, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40,
72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72, 40, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72,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 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0,
8, 8, 8, 8, 8, 8, 0, 0, 8, 8, 8, 8, 8, 8, 0, 0, 8, 8, 8,
8, 8, 8, 0, 0, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
};
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/char_types/char_cases.h
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cudf/strings/detail/char_tables.hpp>
#include <cstdint>
//
// Each entry is the code-point's 'case opposite'
// For example, if the code-point is an upper-case character, the entry is its lower-case
// counterpart.
//
uint16_t const g_character_cases_table[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 97, 98, 99, 100, 101,
102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
116, 117, 118, 119, 120, 121, 122, 0, 0, 0, 0, 0, 0, 65,
66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 924,
0, 0, 0, 0, 186, 0, 0, 0, 0, 0, 224, 225, 226, 227,
228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241,
242, 243, 244, 245, 246, 0, 248, 249, 250, 251, 252, 253, 254, 83,
192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
206, 207, 208, 209, 210, 211, 212, 213, 214, 0, 216, 217, 218, 219,
220, 221, 222, 376, 257, 256, 259, 258, 261, 260, 263, 262, 265, 264,
267, 266, 269, 268, 271, 270, 273, 272, 275, 274, 277, 276, 279, 278,
281, 280, 283, 282, 285, 284, 287, 286, 289, 288, 291, 290, 293, 292,
295, 294, 297, 296, 299, 298, 301, 300, 303, 302, 105, 73, 307, 306,
309, 308, 311, 310, 312, 314, 313, 316, 315, 318, 317, 320, 319, 322,
321, 324, 323, 326, 325, 328, 327, 700, 331, 330, 333, 332, 335, 334,
337, 336, 339, 338, 341, 340, 343, 342, 345, 344, 347, 346, 349, 348,
351, 350, 353, 352, 355, 354, 357, 356, 359, 358, 361, 360, 363, 362,
365, 364, 367, 366, 369, 368, 371, 370, 373, 372, 375, 374, 255, 378,
377, 380, 379, 382, 381, 83, 579, 595, 387, 386, 389, 388, 596, 392,
391, 598, 599, 396, 395, 397, 477, 601, 603, 402, 401, 608, 611, 502,
617, 616, 409, 408, 573, 411, 623, 626, 544, 629, 417, 416, 419, 418,
421, 420, 640, 424, 423, 643, 426, 427, 429, 428, 648, 432, 431, 650,
651, 436, 435, 438, 437, 658, 441, 440, 442, 0, 445, 444, 446, 503,
0, 0, 0, 0, 454, 0, 452, 457, 0, 455, 460, 0, 458, 462,
461, 464, 463, 466, 465, 468, 467, 470, 469, 472, 471, 474, 473, 476,
475, 398, 479, 478, 481, 480, 483, 482, 485, 484, 487, 486, 489, 488,
491, 490, 493, 492, 495, 494, 74, 499, 0, 497, 501, 500, 405, 447,
505, 504, 507, 506, 509, 508, 511, 510, 513, 512, 515, 514, 517, 516,
519, 518, 521, 520, 523, 522, 525, 524, 527, 526, 529, 528, 531, 530,
533, 532, 535, 534, 537, 536, 539, 538, 541, 540, 543, 542, 414, 545,
547, 546, 549, 548, 551, 550, 553, 552, 555, 554, 557, 556, 559, 558,
561, 560, 563, 562, 564, 565, 566, 567, 568, 569, 11365, 572, 571, 410,
11366, 11390, 11391, 578, 577, 384, 649, 652, 583, 582, 585, 584, 587, 586,
589, 588, 591, 590, 11375, 11373, 11376, 385, 390, 597, 393, 394, 600, 399,
602, 400, 42923, 605, 606, 607, 403, 42924, 610, 404, 612, 42893, 42922, 615,
407, 406, 42926, 11362, 42925, 621, 622, 412, 624, 11374, 413, 627, 628, 415,
630, 631, 632, 633, 634, 635, 636, 11364, 638, 639, 422, 641, 42949, 425,
644, 645, 646, 42929, 430, 580, 433, 434, 581, 653, 654, 655, 656, 657,
439, 659, 0, 661, 662, 663, 664, 665, 666, 667, 668, 42930, 42928, 671,
672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685,
686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 0, 0, 0,
0, 0, 0, 0, 704, 705, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 736, 737, 738, 739, 740, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 921, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 881, 880,
883, 882, 0, 0, 887, 886, 0, 0, 890, 1021, 1022, 1023, 0, 1011,
0, 0, 0, 0, 0, 0, 940, 0, 941, 942, 943, 0, 972, 0,
973, 974, 921, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955,
956, 957, 958, 959, 960, 961, 0, 963, 964, 965, 966, 967, 968, 969,
970, 971, 902, 904, 905, 906, 933, 913, 914, 915, 916, 917, 918, 919,
920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 931, 932, 933,
934, 935, 936, 937, 938, 939, 908, 910, 911, 983, 914, 920, 978, 979,
980, 934, 928, 975, 985, 984, 987, 986, 989, 988, 991, 990, 993, 992,
995, 994, 997, 996, 999, 998, 1001, 1000, 1003, 1002, 1005, 1004, 1007, 1006,
922, 929, 1017, 895, 952, 917, 0, 1016, 1015, 1010, 1019, 1018, 1020, 891,
892, 893, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115,
1116, 1117, 1118, 1119, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081,
1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095,
1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1040, 1041, 1042, 1043, 1044, 1045,
1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059,
1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1024, 1025,
1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039,
1121, 1120, 1123, 1122, 1125, 1124, 1127, 1126, 1129, 1128, 1131, 1130, 1133, 1132,
1135, 1134, 1137, 1136, 1139, 1138, 1141, 1140, 1143, 1142, 1145, 1144, 1147, 1146,
1149, 1148, 1151, 1150, 1153, 1152, 0, 0, 0, 0, 0, 0, 0, 0,
1163, 1162, 1165, 1164, 1167, 1166, 1169, 1168, 1171, 1170, 1173, 1172, 1175, 1174,
1177, 1176, 1179, 1178, 1181, 1180, 1183, 1182, 1185, 1184, 1187, 1186, 1189, 1188,
1191, 1190, 1193, 1192, 1195, 1194, 1197, 1196, 1199, 1198, 1201, 1200, 1203, 1202,
1205, 1204, 1207, 1206, 1209, 1208, 1211, 1210, 1213, 1212, 1215, 1214, 1231, 1218,
1217, 1220, 1219, 1222, 1221, 1224, 1223, 1226, 1225, 1228, 1227, 1230, 1229, 1216,
1233, 1232, 1235, 1234, 1237, 1236, 1239, 1238, 1241, 1240, 1243, 1242, 1245, 1244,
1247, 1246, 1249, 1248, 1251, 1250, 1253, 1252, 1255, 1254, 1257, 1256, 1259, 1258,
1261, 1260, 1263, 1262, 1265, 1264, 1267, 1266, 1269, 1268, 1271, 1270, 1273, 1272,
1275, 1274, 1277, 1276, 1279, 1278, 1281, 1280, 1283, 1282, 1285, 1284, 1287, 1286,
1289, 1288, 1291, 1290, 1293, 1292, 1295, 1294, 1297, 1296, 1299, 1298, 1301, 1300,
1303, 1302, 1305, 1304, 1307, 1306, 1309, 1308, 1311, 1310, 1313, 1312, 1315, 1314,
1317, 1316, 1319, 1318, 1321, 1320, 1323, 1322, 1325, 1324, 1327, 1326, 0, 1377,
1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391,
1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405,
1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413, 1414, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337,
1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351,
1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365,
1366, 1333, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
11520, 11521, 11522, 11523, 11524, 11525, 11526, 11527, 11528, 11529, 11530, 11531, 11532, 11533,
11534, 11535, 11536, 11537, 11538, 11539, 11540, 11541, 11542, 11543, 11544, 11545, 11546, 11547,
11548, 11549, 11550, 11551, 11552, 11553, 11554, 11555, 11556, 11557, 0, 11559, 0, 0,
0, 0, 0, 11565, 0, 0, 7312, 7313, 7314, 7315, 7316, 7317, 7318, 7319,
7320, 7321, 7322, 7323, 7324, 7325, 7326, 7327, 7328, 7329, 7330, 7331, 7332, 7333,
7334, 7335, 7336, 7337, 7338, 7339, 7340, 7341, 7342, 7343, 7344, 7345, 7346, 7347,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0, 0, 0, 0, 0, 43888, 43889,
43890, 43891, 43892, 43893, 43894, 43895, 43896, 43897, 43898, 43899, 43900, 43901, 43902, 43903,
43904, 43905, 43906, 43907, 43908, 43909, 43910, 43911, 43912, 43913, 43914, 43915, 43916, 43917,
43918, 43919, 43920, 43921, 43922, 43923, 43924, 43925, 43926, 43927, 43928, 43929, 43930, 43931,
43932, 43933, 43934, 43935, 43936, 43937, 43938, 43939, 43940, 43941, 43942, 43943, 43944, 43945,
43946, 43947, 43948, 43949, 43950, 43951, 43952, 43953, 43954, 43955, 43956, 43957, 43958, 43959,
43960, 43961, 43962, 43963, 43964, 43965, 43966, 43967, 5112, 5113, 5114, 5115, 5116, 5117,
0, 0, 5104, 5105, 5106, 5107, 5108, 5109, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1042, 1044, 1054, 1057, 1058, 1058, 1066, 1122, 42570, 0, 0, 0,
0, 0, 0, 0, 4304, 4305, 4306, 4307, 4308, 4309, 4310, 4311, 4312, 4313,
4314, 4315, 4316, 4317, 4318, 4319, 4320, 4321, 4322, 4323, 4324, 4325, 4326, 4327,
4328, 4329, 4330, 4331, 4332, 4333, 4334, 4335, 4336, 4337, 4338, 4339, 4340, 4341,
4342, 4343, 4344, 4345, 4346, 0, 0, 4349, 4350, 4351, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 7424, 7425, 7426, 7427, 7428, 7429, 7430, 7431, 7432, 7433,
7434, 7435, 7436, 7437, 7438, 7439, 7440, 7441, 7442, 7443, 7444, 7445, 7446, 7447,
7448, 7449, 7450, 7451, 7452, 7453, 7454, 7455, 7456, 7457, 7458, 7459, 7460, 7461,
7462, 7463, 7464, 7465, 7466, 7467, 7468, 7469, 7470, 7471, 7472, 7473, 7474, 7475,
7476, 7477, 7478, 7479, 7480, 7481, 7482, 7483, 7484, 7485, 7486, 7487, 7488, 7489,
7490, 7491, 7492, 7493, 7494, 7495, 7496, 7497, 7498, 7499, 7500, 7501, 7502, 7503,
7504, 7505, 7506, 7507, 7508, 7509, 7510, 7511, 7512, 7513, 7514, 7515, 7516, 7517,
7518, 7519, 7520, 7521, 7522, 7523, 7524, 7525, 7526, 7527, 7528, 7529, 7530, 7531,
7532, 7533, 7534, 7535, 7536, 7537, 7538, 7539, 7540, 7541, 7542, 7543, 7544, 42877,
7546, 7547, 7548, 11363, 7550, 7551, 7552, 7553, 7554, 7555, 7556, 7557, 7558, 7559,
7560, 7561, 7562, 7563, 7564, 7565, 42950, 7567, 7568, 7569, 7570, 7571, 7572, 7573,
7574, 7575, 7576, 7577, 7578, 7579, 7580, 7581, 7582, 7583, 7584, 7585, 7586, 7587,
7588, 7589, 7590, 7591, 7592, 7593, 7594, 7595, 7596, 7597, 7598, 7599, 7600, 7601,
7602, 7603, 7604, 7605, 7606, 7607, 7608, 7609, 7610, 7611, 7612, 7613, 7614, 7615,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 7681, 7680, 7683, 7682, 7685, 7684,
7687, 7686, 7689, 7688, 7691, 7690, 7693, 7692, 7695, 7694, 7697, 7696, 7699, 7698,
7701, 7700, 7703, 7702, 7705, 7704, 7707, 7706, 7709, 7708, 7711, 7710, 7713, 7712,
7715, 7714, 7717, 7716, 7719, 7718, 7721, 7720, 7723, 7722, 7725, 7724, 7727, 7726,
7729, 7728, 7731, 7730, 7733, 7732, 7735, 7734, 7737, 7736, 7739, 7738, 7741, 7740,
7743, 7742, 7745, 7744, 7747, 7746, 7749, 7748, 7751, 7750, 7753, 7752, 7755, 7754,
7757, 7756, 7759, 7758, 7761, 7760, 7763, 7762, 7765, 7764, 7767, 7766, 7769, 7768,
7771, 7770, 7773, 7772, 7775, 7774, 7777, 7776, 7779, 7778, 7781, 7780, 7783, 7782,
7785, 7784, 7787, 7786, 7789, 7788, 7791, 7790, 7793, 7792, 7795, 7794, 7797, 7796,
7799, 7798, 7801, 7800, 7803, 7802, 7805, 7804, 7807, 7806, 7809, 7808, 7811, 7810,
7813, 7812, 7815, 7814, 7817, 7816, 7819, 7818, 7821, 7820, 7823, 7822, 7825, 7824,
7827, 7826, 7829, 7828, 72, 84, 87, 89, 65, 7776, 7836, 7837, 223, 7839,
7841, 7840, 7843, 7842, 7845, 7844, 7847, 7846, 7849, 7848, 7851, 7850, 7853, 7852,
7855, 7854, 7857, 7856, 7859, 7858, 7861, 7860, 7863, 7862, 7865, 7864, 7867, 7866,
7869, 7868, 7871, 7870, 7873, 7872, 7875, 7874, 7877, 7876, 7879, 7878, 7881, 7880,
7883, 7882, 7885, 7884, 7887, 7886, 7889, 7888, 7891, 7890, 7893, 7892, 7895, 7894,
7897, 7896, 7899, 7898, 7901, 7900, 7903, 7902, 7905, 7904, 7907, 7906, 7909, 7908,
7911, 7910, 7913, 7912, 7915, 7914, 7917, 7916, 7919, 7918, 7921, 7920, 7923, 7922,
7925, 7924, 7927, 7926, 7929, 7928, 7931, 7930, 7933, 7932, 7935, 7934, 7944, 7945,
7946, 7947, 7948, 7949, 7950, 7951, 7936, 7937, 7938, 7939, 7940, 7941, 7942, 7943,
7960, 7961, 7962, 7963, 7964, 7965, 0, 0, 7952, 7953, 7954, 7955, 7956, 7957,
0, 0, 7976, 7977, 7978, 7979, 7980, 7981, 7982, 7983, 7968, 7969, 7970, 7971,
7972, 7973, 7974, 7975, 7992, 7993, 7994, 7995, 7996, 7997, 7998, 7999, 7984, 7985,
7986, 7987, 7988, 7989, 7990, 7991, 8008, 8009, 8010, 8011, 8012, 8013, 0, 0,
8000, 8001, 8002, 8003, 8004, 8005, 0, 0, 933, 8025, 933, 8027, 933, 8029,
933, 8031, 0, 8017, 0, 8019, 0, 8021, 0, 8023, 8040, 8041, 8042, 8043,
8044, 8045, 8046, 8047, 8032, 8033, 8034, 8035, 8036, 8037, 8038, 8039, 8122, 8123,
8136, 8137, 8138, 8139, 8154, 8155, 8184, 8185, 8170, 8171, 8186, 8187, 0, 0,
7944, 7945, 7946, 7947, 7948, 7949, 7950, 7951, 8064, 8065, 8066, 8067, 8068, 8069,
8070, 8071, 7976, 7977, 7978, 7979, 7980, 7981, 7982, 7983, 8080, 8081, 8082, 8083,
8084, 8085, 8086, 8087, 8040, 8041, 8042, 8043, 8044, 8045, 8046, 8047, 8096, 8097,
8098, 8099, 8100, 8101, 8102, 8103, 8120, 8121, 8122, 913, 902, 0, 913, 913,
8112, 8113, 8048, 8049, 8115, 0, 921, 0, 0, 0, 8138, 919, 905, 0,
919, 919, 8050, 8051, 8052, 8053, 8131, 0, 0, 0, 8152, 8153, 921, 921,
0, 0, 921, 921, 8144, 8145, 8054, 8055, 0, 0, 0, 0, 8168, 8169,
933, 933, 929, 8172, 933, 933, 8160, 8161, 8058, 8059, 8165, 0, 0, 0,
0, 0, 8186, 937, 911, 0, 937, 937, 8056, 8057, 8060, 8061, 8179, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 8305, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 8319, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 8336, 8337, 8338, 8339, 8340, 8341, 8342, 8343,
8344, 8345, 8346, 8347, 8348, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 8450, 0, 0, 0, 0, 8455,
0, 0, 8458, 8459, 8460, 8461, 8462, 8463, 8464, 8465, 8466, 8467, 0, 8469,
0, 0, 0, 8473, 8474, 8475, 8476, 8477, 0, 0, 0, 0, 0, 0,
8484, 0, 969, 0, 8488, 0, 107, 229, 8492, 8493, 0, 8495, 8496, 8497,
8526, 8499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 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 9424, 9425, 9426, 9427, 9428, 9429, 9430, 9431, 9432, 9433,
9434, 9435, 9436, 9437, 9438, 9439, 9440, 9441, 9442, 9443, 9444, 9445, 9446, 9447,
9448, 9449, 9398, 9399, 9400, 9401, 9402, 9403, 9404, 9405, 9406, 9407, 9408, 9409,
9410, 9411, 9412, 9413, 9414, 9415, 9416, 9417, 9418, 9419, 9420, 9421, 9422, 9423,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 11312, 11313, 11314, 11315, 11316, 11317,
11318, 11319, 11320, 11321, 11322, 11323, 11324, 11325, 11326, 11327, 11328, 11329, 11330, 11331,
11332, 11333, 11334, 11335, 11336, 11337, 11338, 11339, 11340, 11341, 11342, 11343, 11344, 11345,
11346, 11347, 11348, 11349, 11350, 11351, 11352, 11353, 11354, 11355, 11356, 11357, 11358, 0,
11264, 11265, 11266, 11267, 11268, 11269, 11270, 11271, 11272, 11273, 11274, 11275, 11276, 11277,
11278, 11279, 11280, 11281, 11282, 11283, 11284, 11285, 11286, 11287, 11288, 11289, 11290, 11291,
11292, 11293, 11294, 11295, 11296, 11297, 11298, 11299, 11300, 11301, 11302, 11303, 11304, 11305,
11306, 11307, 11308, 11309, 11310, 0, 11361, 11360, 619, 7549, 637, 570, 574, 11368,
11367, 11370, 11369, 11372, 11371, 593, 625, 592, 594, 11377, 11379, 11378, 11380, 11382,
11381, 11383, 11384, 11385, 11386, 11387, 11388, 11389, 575, 576, 11393, 11392, 11395, 11394,
11397, 11396, 11399, 11398, 11401, 11400, 11403, 11402, 11405, 11404, 11407, 11406, 11409, 11408,
11411, 11410, 11413, 11412, 11415, 11414, 11417, 11416, 11419, 11418, 11421, 11420, 11423, 11422,
11425, 11424, 11427, 11426, 11429, 11428, 11431, 11430, 11433, 11432, 11435, 11434, 11437, 11436,
11439, 11438, 11441, 11440, 11443, 11442, 11445, 11444, 11447, 11446, 11449, 11448, 11451, 11450,
11453, 11452, 11455, 11454, 11457, 11456, 11459, 11458, 11461, 11460, 11463, 11462, 11465, 11464,
11467, 11466, 11469, 11468, 11471, 11470, 11473, 11472, 11475, 11474, 11477, 11476, 11479, 11478,
11481, 11480, 11483, 11482, 11485, 11484, 11487, 11486, 11489, 11488, 11491, 11490, 11492, 0,
0, 0, 0, 0, 0, 11500, 11499, 11502, 11501, 0, 0, 0, 11507, 11506,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4256, 4257,
4258, 4259, 4260, 4261, 4262, 4263, 4264, 4265, 4266, 4267, 4268, 4269, 4270, 4271,
4272, 4273, 4274, 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285,
4286, 4287, 4288, 4289, 4290, 4291, 4292, 4293, 0, 4295, 0, 0, 0, 0,
0, 4301, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0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, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
42561, 42560, 42563, 42562, 42565, 42564, 42567, 42566, 42569, 42568, 42571, 42570, 42573, 42572,
42575, 42574, 42577, 42576, 42579, 42578, 42581, 42580, 42583, 42582, 42585, 42584, 42587, 42586,
42589, 42588, 42591, 42590, 42593, 42592, 42595, 42594, 42597, 42596, 42599, 42598, 42601, 42600,
42603, 42602, 42605, 42604, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 42625, 42624, 42627, 42626, 42629, 42628,
42631, 42630, 42633, 42632, 42635, 42634, 42637, 42636, 42639, 42638, 42641, 42640, 42643, 42642,
42645, 42644, 42647, 42646, 42649, 42648, 42651, 42650, 42652, 42653, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 42787, 42786, 42789, 42788, 42791, 42790, 42793, 42792, 42795, 42794, 42797, 42796,
42799, 42798, 42800, 42801, 42803, 42802, 42805, 42804, 42807, 42806, 42809, 42808, 42811, 42810,
42813, 42812, 42815, 42814, 42817, 42816, 42819, 42818, 42821, 42820, 42823, 42822, 42825, 42824,
42827, 42826, 42829, 42828, 42831, 42830, 42833, 42832, 42835, 42834, 42837, 42836, 42839, 42838,
42841, 42840, 42843, 42842, 42845, 42844, 42847, 42846, 42849, 42848, 42851, 42850, 42853, 42852,
42855, 42854, 42857, 42856, 42859, 42858, 42861, 42860, 42863, 42862, 42864, 42865, 42866, 42867,
42868, 42869, 42870, 42871, 42872, 42874, 42873, 42876, 42875, 7545, 42879, 42878, 42881, 42880,
42883, 42882, 42885, 42884, 42887, 42886, 0, 0, 0, 42892, 42891, 613, 42894, 0,
42897, 42896, 42899, 42898, 42948, 42901, 42903, 42902, 42905, 42904, 42907, 42906, 42909, 42908,
42911, 42910, 42913, 42912, 42915, 42914, 42917, 42916, 42919, 42918, 42921, 42920, 614, 604,
609, 620, 618, 0, 670, 647, 669, 43859, 42933, 42932, 42935, 42934, 42937, 42936,
42939, 42938, 42941, 42940, 42943, 42942, 0, 0, 42947, 42946, 42900, 642, 7566, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 43000, 43001, 43002, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 43824, 43825, 43826, 43827, 43828, 43829, 43830, 43831, 43832, 43833,
43834, 43835, 43836, 43837, 43838, 43839, 43840, 43841, 43842, 43843, 43844, 43845, 43846, 43847,
43848, 43849, 43850, 43851, 43852, 43853, 43854, 43855, 43856, 43857, 43858, 42931, 43860, 43861,
43862, 43863, 43864, 43865, 43866, 0, 43868, 43869, 43870, 43871, 43872, 43873, 43874, 43875,
43876, 43877, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5024, 5025,
5026, 5027, 5028, 5029, 5030, 5031, 5032, 5033, 5034, 5035, 5036, 5037, 5038, 5039,
5040, 5041, 5042, 5043, 5044, 5045, 5046, 5047, 5048, 5049, 5050, 5051, 5052, 5053,
5054, 5055, 5056, 5057, 5058, 5059, 5060, 5061, 5062, 5063, 5064, 5065, 5066, 5067,
5068, 5069, 5070, 5071, 5072, 5073, 5074, 5075, 5076, 5077, 5078, 5079, 5080, 5081,
5082, 5083, 5084, 5085, 5086, 5087, 5088, 5089, 5090, 5091, 5092, 5093, 5094, 5095,
5096, 5097, 5098, 5099, 5100, 5101, 5102, 5103, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355,
65356, 65357, 65358, 65359, 65360, 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369,
65370, 0, 0, 0, 0, 0, 0, 65313, 65314, 65315, 65316, 65317, 65318, 65319,
65320, 65321, 65322, 65323, 65324, 65325, 65326, 65327, 65328, 65329, 65330, 65331, 65332, 65333,
65334, 65335, 65336, 65337, 65338, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0,
};
namespace cudf {
namespace strings {
namespace detail {
/**
* @brief The following structs and arrays are autogenerated using
* generate_special_mapping_hash_table(). They represent a 'perfect' hash table that
* allows special cased code points (those with the special case flag, 1<<7 set in the
* g_character_codepoint_flags array) to have their mapping information retrieved in
* constant time (codepoint % special_case_prime).
*
* 'special' cased characters are those defined as not having trivial single->single character
* mappings when having upper(), lower() or titlecase() operations applied. Typically this is
* for cases where a single character maps to multiple, but there are also cases of
* non-reversible mappings, where: codepoint != lower(upper(code_point)). The mappings for
* these cases are explicitly specified by g_special_case_mappings.
*
* special_case_mapping, g_special_case_mappings, and special_case_prime can be regenerated with
* cudf::strings::detail::generate_special_mapping_hash_table
*/
constexpr special_case_mapping g_special_case_mappings[] = {
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{2, {933, 787, 0}, 0, {0, 0, 0}},
{},
{3, {933, 787, 768}, 0, {0, 0, 0}},
{},
{3, {933, 787, 769}, 0, {0, 0, 0}},
{},
{3, {933, 787, 834}, 0, {0, 0, 0}},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{2, {7944, 921, 0}, 0, {0, 0, 0}},
{2, {7945, 921, 0}, 0, {0, 0, 0}},
{2, {7946, 921, 0}, 0, {0, 0, 0}},
{2, {7947, 921, 0}, 0, {0, 0, 0}},
{2, {7948, 921, 0}, 0, {0, 0, 0}},
{2, {7949, 921, 0}, 0, {0, 0, 0}},
{2, {7950, 921, 0}, 0, {0, 0, 0}},
{2, {7951, 921, 0}, 0, {0, 0, 0}},
{2, {7944, 921, 0}, 1, {8064, 0, 0}},
{2, {7945, 921, 0}, 1, {8065, 0, 0}},
{2, {7946, 921, 0}, 1, {8066, 0, 0}},
{2, {7947, 921, 0}, 1, {8067, 0, 0}},
{2, {7948, 921, 0}, 1, {8068, 0, 0}},
{2, {7949, 921, 0}, 1, {8069, 0, 0}},
{2, {7950, 921, 0}, 1, {8070, 0, 0}},
{2, {7951, 921, 0}, 1, {8071, 0, 0}},
{2, {7976, 921, 0}, 0, {0, 0, 0}},
{2, {7977, 921, 0}, 0, {0, 0, 0}},
{2, {7978, 921, 0}, 0, {0, 0, 0}},
{2, {7979, 921, 0}, 0, {0, 0, 0}},
{2, {7980, 921, 0}, 0, {0, 0, 0}},
{2, {7981, 921, 0}, 0, {0, 0, 0}},
{2, {7982, 921, 0}, 0, {0, 0, 0}},
{2, {7983, 921, 0}, 0, {0, 0, 0}},
{2, {7976, 921, 0}, 1, {8080, 0, 0}},
{2, {7977, 921, 0}, 1, {8081, 0, 0}},
{2, {7978, 921, 0}, 1, {8082, 0, 0}},
{2, {7979, 921, 0}, 1, {8083, 0, 0}},
{2, {7980, 921, 0}, 1, {8084, 0, 0}},
{2, {7981, 921, 0}, 1, {8085, 0, 0}},
{2, {7982, 921, 0}, 1, {8086, 0, 0}},
{2, {7983, 921, 0}, 1, {8087, 0, 0}},
{2, {8040, 921, 0}, 0, {0, 0, 0}},
{2, {8041, 921, 0}, 0, {0, 0, 0}},
{2, {8042, 921, 0}, 0, {0, 0, 0}},
{2, {8043, 921, 0}, 0, {0, 0, 0}},
{2, {8044, 921, 0}, 0, {0, 0, 0}},
{2, {8045, 921, 0}, 0, {0, 0, 0}},
{2, {8046, 921, 0}, 0, {0, 0, 0}},
{2, {8047, 921, 0}, 0, {0, 0, 0}},
{2, {8040, 921, 0}, 1, {8096, 0, 0}},
{2, {8041, 921, 0}, 1, {8097, 0, 0}},
{2, {8042, 921, 0}, 1, {8098, 0, 0}},
{2, {8043, 921, 0}, 1, {8099, 0, 0}},
{2, {8044, 921, 0}, 1, {8100, 0, 0}},
{2, {8045, 921, 0}, 1, {8101, 0, 0}},
{2, {8046, 921, 0}, 1, {8102, 0, 0}},
{2, {8047, 921, 0}, 1, {8103, 0, 0}},
{},
{},
{2, {8122, 921, 0}, 0, {0, 0, 0}},
{2, {913, 921, 0}, 0, {0, 0, 0}},
{2, {902, 921, 0}, 0, {0, 0, 0}},
{},
{2, {913, 834, 0}, 0, {0, 0, 0}},
{3, {913, 834, 921}, 0, {0, 0, 0}},
{},
{},
{},
{},
{2, {913, 921, 0}, 1, {8115, 0, 0}},
{},
{},
{},
{},
{},
{2, {8138, 921, 0}, 0, {0, 0, 0}},
{2, {919, 921, 0}, 0, {0, 0, 0}},
{2, {905, 921, 0}, 0, {0, 0, 0}},
{},
{2, {919, 834, 0}, 0, {0, 0, 0}},
{3, {919, 834, 921}, 0, {0, 0, 0}},
{},
{},
{},
{},
{2, {919, 921, 0}, 1, {8131, 0, 0}},
{},
{},
{},
{},
{},
{3, {921, 776, 768}, 0, {0, 0, 0}},
{3, {921, 776, 769}, 0, {0, 0, 0}},
{},
{},
{2, {921, 834, 0}, 0, {0, 0, 0}},
{3, {921, 776, 834}, 0, {0, 0, 0}},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{3, {933, 776, 768}, 0, {0, 0, 0}},
{3, {933, 776, 769}, 0, {0, 0, 0}},
{2, {929, 787, 0}, 0, {0, 0, 0}},
{},
{2, {933, 834, 0}, 0, {0, 0, 0}},
{3, {933, 776, 834}, 0, {0, 0, 0}},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{2, {8186, 921, 0}, 0, {0, 0, 0}},
{2, {937, 921, 0}, 0, {0, 0, 0}},
{2, {911, 921, 0}, 0, {0, 0, 0}},
{},
{2, {937, 834, 0}, 0, {0, 0, 0}},
{3, {937, 834, 921}, 0, {0, 0, 0}},
{},
{},
{},
{},
{2, {937, 921, 0}, 1, {8179, 0, 0}},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{2, {83, 83, 0}, 0, {0, 0, 0}},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{0, {0, 0, 0}, 2, {105, 775, 0}},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{2, {700, 78, 0}, 0, {0, 0, 0}},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{2, {72, 817, 0}, 0, {0, 0, 0}},
{2, {84, 776, 0}, 0, {0, 0, 0}},
{2, {87, 778, 0}, 0, {0, 0, 0}},
{2, {89, 778, 0}, 0, {0, 0, 0}},
{2, {65, 702, 0}, 0, {0, 0, 0}},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{2, {70, 70, 0}, 0, {0, 0, 0}},
{2, {70, 73, 0}, 0, {0, 0, 0}},
{2, {70, 76, 0}, 0, {0, 0, 0}},
{3, {70, 70, 73}, 0, {0, 0, 0}},
{3, {70, 70, 76}, 0, {0, 0, 0}},
{2, {83, 84, 0}, 0, {0, 0, 0}},
{2, {83, 84, 0}, 0, {0, 0, 0}},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{2, {1348, 1350, 0}, 0, {0, 0, 0}},
{2, {1348, 1333, 0}, 0, {0, 0, 0}},
{2, {1348, 1339, 0}, 0, {0, 0, 0}},
{2, {1358, 1350, 0}, 0, {0, 0, 0}},
{2, {1348, 1341, 0}, 0, {0, 0, 0}},
{},
{},
{},
{},
{},
{3, {921, 776, 769}, 0, {0, 0, 0}},
{},
{},
{},
{2, {1333, 1362, 0}, 0, {0, 0, 0}},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{3, {933, 776, 769}, 0, {0, 0, 0}},
{},
{},
{},
{},
{},
{},
{},
{1, {452, 0, 0}, 1, {454, 0, 0}},
{},
{},
{1, {455, 0, 0}, 1, {457, 0, 0}},
{},
{},
{1, {458, 0, 0}, 1, {460, 0, 0}},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{2, {74, 780, 0}, 0, {0, 0, 0}},
{},
{1, {497, 0, 0}, 1, {499, 0, 0}},
};
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/scan/scan_inclusive.cu
|
/*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/gather.hpp>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/utilities/device_operators.cuh>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/scan.h>
#include <thrust/scatter.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Min/Max inclusive scan operator
*
* This operator will accept index values, check them and then
* run the `Op` operation on the individual element objects.
* The returned result is the appropriate index value.
*
* This was specifically created to workaround a thrust issue
* https://github.com/NVIDIA/thrust/issues/1479
* where invalid values are passed to the operator.
*/
template <typename Element, typename Op>
struct min_max_scan_operator {
column_device_view const col; ///< strings column device view
Element const null_replacement{}; ///< value used when element is null
bool const has_nulls; ///< true if col has null elements
min_max_scan_operator(column_device_view const& col, bool has_nulls = true)
: col{col}, null_replacement{Op::template identity<Element>()}, has_nulls{has_nulls}
{
// verify validity bitmask is non-null, otherwise, is_null_nocheck() will crash
if (has_nulls) CUDF_EXPECTS(col.nullable(), "column with nulls must have a validity bitmask");
}
__device__ inline size_type operator()(size_type lhs, size_type rhs) const
{
// thrust::inclusive_scan may pass us garbage values so we need to protect ourselves;
// in these cases the return value does not matter since the result is not used
if (lhs < 0 || rhs < 0 || lhs >= col.size() || rhs >= col.size()) return 0;
Element d_lhs =
has_nulls && col.is_null_nocheck(lhs) ? null_replacement : col.element<Element>(lhs);
Element d_rhs =
has_nulls && col.is_null_nocheck(rhs) ? null_replacement : col.element<Element>(rhs);
return Op{}(d_lhs, d_rhs) == d_lhs ? lhs : rhs;
}
};
struct null_iterator {
bitmask_type const* mask;
__device__ bool operator()(size_type idx) const { return !bit_is_set(mask, idx); }
};
} // namespace
template <typename Op>
std::unique_ptr<column> scan_inclusive(column_view const& input,
bitmask_type const* mask,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto d_input = column_device_view::create(input, stream);
// build indices of the scan operation results
rmm::device_uvector<size_type> result_map(input.size(), stream);
thrust::inclusive_scan(rmm::exec_policy(stream),
thrust::counting_iterator<size_type>(0),
thrust::counting_iterator<size_type>(input.size()),
result_map.begin(),
min_max_scan_operator<cudf::string_view, Op>{*d_input, input.has_nulls()});
if (input.has_nulls()) {
// fill the null rows with out-of-bounds values so gather records them as null;
// this prevents un-sanitized null entries in the output
auto null_itr = cudf::detail::make_counting_transform_iterator(0, null_iterator{mask});
auto oob_val = thrust::constant_iterator<size_type>(input.size());
thrust::scatter_if(rmm::exec_policy(stream),
oob_val,
oob_val + input.size(),
thrust::counting_iterator<size_type>(0),
null_itr,
result_map.data());
}
// call gather using the indices to build the output column
auto result_table = cudf::detail::gather(cudf::table_view({input}),
result_map,
cudf::out_of_bounds_policy::NULLIFY,
cudf::detail::negative_index_policy::NOT_ALLOWED,
stream,
mr);
return std::move(result_table->release().front());
}
template std::unique_ptr<column> scan_inclusive<DeviceMin>(column_view const& input,
bitmask_type const* mask,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);
template std::unique_ptr<column> scan_inclusive<DeviceMax>(column_view const& input,
bitmask_type const* mask,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/extract/extract_all.cu
|
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <strings/count_matches.hpp>
#include <strings/regex/regex_program_impl.h>
#include <strings/regex/utilities.cuh>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/lists/detail/lists_column_factories.hpp>
#include <cudf/strings/detail/strings_column_factories.cuh>
#include <cudf/strings/extract.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/functional.h>
#include <thrust/transform_scan.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Functor extracts matched string pointers for each input string.
*
* For regex match within a string, the specified groups are extracted into
* the `d_indices` output vector.
* The `d_offsets` are pre-computed to identify the location of where each
* string's output groups are to be written.
*/
struct extract_fn {
column_device_view const d_strings;
size_type const* d_offsets;
string_index_pair* d_indices;
__device__ void operator()(size_type const idx,
reprog_device const d_prog,
int32_t const prog_idx)
{
if (d_strings.is_null(idx)) { return; }
auto const d_str = d_strings.element<string_view>(idx);
auto const nchars = d_str.length();
auto const groups = d_prog.group_counts();
auto d_output = d_indices + d_offsets[idx];
size_type output_idx = 0;
auto itr = d_str.begin();
while (itr.position() < nchars) {
// first, match the regex
auto const match = d_prog.find(prog_idx, d_str, itr);
if (!match) { break; }
itr += (match->first - itr.position()); // position to beginning of the match
auto last_pos = itr;
// extract each group into the output
for (auto group_idx = 0; group_idx < groups; ++group_idx) {
// result is an optional containing the bounds of the extracted string at group_idx
auto const extracted = d_prog.extract(prog_idx, d_str, itr, match->second, group_idx);
if (extracted) {
auto const d_result = string_from_match(*extracted, d_str, last_pos);
d_output[group_idx + output_idx] =
string_index_pair{d_result.data(), d_result.size_bytes()};
} else {
d_output[group_idx + output_idx] = string_index_pair{nullptr, 0};
}
last_pos += (extracted->second - last_pos.position());
}
// point to the end of this match to start the next match
itr += (match->second - itr.position());
output_idx += groups;
}
}
};
} // namespace
/**
* @copydoc cudf::strings::extract_all_record
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
std::unique_ptr<column> extract_all_record(strings_column_view const& input,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto const strings_count = input.size();
auto const d_strings = column_device_view::create(input.parent(), stream);
// create device object from regex_program
auto d_prog = regex_device_builder::create_prog_device(prog, stream);
// The extract pattern should always include groups.
auto const groups = d_prog->group_counts();
CUDF_EXPECTS(groups > 0, "extract_all requires group indicators in the regex pattern.");
// Get the match counts for each string.
// This column will become the output lists child offsets column.
auto offsets = count_matches(*d_strings, *d_prog, strings_count + 1, stream, mr);
auto d_offsets = offsets->mutable_view().data<size_type>();
// Compute null output rows
auto [null_mask, null_count] = cudf::detail::valid_if(
d_offsets, d_offsets + strings_count, [] __device__(auto v) { return v > 0; }, stream, mr);
// Return an empty lists column if there are no valid rows
if (strings_count == null_count) {
return cudf::lists::detail::make_empty_lists_column(data_type{type_id::STRING}, stream, mr);
}
// Convert counts into offsets.
// Multiply each count by the number of groups.
thrust::transform_exclusive_scan(
rmm::exec_policy(stream),
d_offsets,
d_offsets + strings_count + 1,
d_offsets,
[groups] __device__(auto v) { return v * groups; },
size_type{0},
thrust::plus{});
auto const total_groups =
cudf::detail::get_value<size_type>(offsets->view(), strings_count, stream);
rmm::device_uvector<string_index_pair> indices(total_groups, stream);
launch_for_each_kernel(
extract_fn{*d_strings, d_offsets, indices.data()}, *d_prog, strings_count, stream);
auto strings_output = make_strings_column(indices.begin(), indices.end(), stream, mr);
// Build the lists column from the offsets and the strings.
return make_lists_column(strings_count,
std::move(offsets),
std::move(strings_output),
null_count,
std::move(null_mask),
stream,
mr);
}
} // namespace detail
// external API
std::unique_ptr<column> extract_all_record(strings_column_view const& input,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::extract_all_record(input, prog, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/extract/extract.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <strings/regex/regex_program_impl.h>
#include <strings/regex/utilities.cuh>
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/strings_column_factories.cuh>
#include <cudf/strings/extract.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/span.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/execution_policy.h>
#include <thrust/fill.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/permutation_iterator.h>
#include <thrust/pair.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
using string_index_pair = thrust::pair<char const*, size_type>;
/**
* @brief This functor handles extracting strings by applying the compiled regex pattern
* and creating string_index_pairs for all the substrings.
*/
struct extract_fn {
column_device_view const d_strings;
cudf::detail::device_2dspan<string_index_pair> d_indices;
__device__ void operator()(size_type const idx,
reprog_device const d_prog,
int32_t const prog_idx)
{
auto const groups = d_prog.group_counts();
auto d_output = d_indices[idx];
if (d_strings.is_valid(idx)) {
auto const d_str = d_strings.element<string_view>(idx);
auto const match = d_prog.find(prog_idx, d_str, d_str.begin());
if (match) {
auto const itr = d_str.begin() + match->first;
auto last_pos = itr;
for (auto col_idx = 0; col_idx < groups; ++col_idx) {
auto const extracted = d_prog.extract(prog_idx, d_str, itr, match->second, col_idx);
if (extracted) {
auto const d_extracted = string_from_match(*extracted, d_str, last_pos);
d_output[col_idx] = string_index_pair{d_extracted.data(), d_extracted.size_bytes()};
last_pos += (extracted->second - last_pos.position());
} else {
d_output[col_idx] = string_index_pair{nullptr, 0};
}
}
return;
}
}
// if null row or no match found, fill the output with null entries
thrust::fill(thrust::seq, d_output.begin(), d_output.end(), string_index_pair{nullptr, 0});
}
};
} // namespace
//
std::unique_ptr<table> extract(strings_column_view const& input,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// create device object from regex_program
auto d_prog = regex_device_builder::create_prog_device(prog, stream);
auto const groups = d_prog->group_counts();
CUDF_EXPECTS(groups > 0, "Group indicators not found in regex pattern");
auto indices = rmm::device_uvector<string_index_pair>(input.size() * groups, stream);
auto d_indices =
cudf::detail::device_2dspan<string_index_pair>(indices.data(), input.size(), groups);
auto const d_strings = column_device_view::create(input.parent(), stream);
launch_for_each_kernel(extract_fn{*d_strings, d_indices}, *d_prog, input.size(), stream);
// build a result column for each group
std::vector<std::unique_ptr<column>> results(groups);
auto make_strings_lambda = [&](size_type column_index) {
// this iterator transposes the extract results into column order
auto indices_itr =
thrust::make_permutation_iterator(indices.begin(),
cudf::detail::make_counting_transform_iterator(
0, [column_index, groups] __device__(size_type idx) {
return (idx * groups) + column_index;
}));
return make_strings_column(indices_itr, indices_itr + input.size(), stream, mr);
};
std::transform(thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(groups),
results.begin(),
make_strings_lambda);
return std::make_unique<table>(std::move(results));
}
} // namespace detail
// external API
std::unique_ptr<table> extract(strings_column_view const& input,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::extract(input, prog, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/split/partition.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/utilities.hpp>
#include <cudf/strings/split/partition.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/pair.h>
#include <vector>
namespace cudf {
namespace strings {
namespace detail {
using string_index_pair = thrust::pair<char const*, size_type>;
namespace {
//
// Partition splits the string at the first occurrence of delimiter, and returns 3 elements
// containing the part before the delimiter, the delimiter itself, and the part after the delimiter.
// If the delimiter is not found, return 3 elements containing the string itself, followed by two
// empty strings.
//
// strs = ["abcde", nullptr, "a_bc_def", "a__bc", "_ab_cd", "ab_cd_"]
// results = partition(strs,"_")
// col0 col1 col2
// 0 abcde "" ""
// 1 null null null
// 2 a _ bc_déf
// 3 a _ _bc
// 4 "" _ ab_cd
// 5 ab _ cd_
//
struct partition_fn {
column_device_view const d_strings; // strings to split
string_view const d_delimiter; // delimiter for split
string_index_pair* d_indices_left{}; // the three
string_index_pair* d_indices_delim{}; // output columns
string_index_pair* d_indices_right{}; // amigos
partition_fn(column_device_view const& d_strings,
string_view const& d_delimiter,
rmm::device_uvector<string_index_pair>& indices_left,
rmm::device_uvector<string_index_pair>& indices_delim,
rmm::device_uvector<string_index_pair>& indices_right)
: d_strings(d_strings),
d_delimiter(d_delimiter),
d_indices_left(indices_left.data()),
d_indices_delim(indices_delim.data()),
d_indices_right(indices_right.data())
{
}
__device__ void set_null_entries(size_type idx)
{
if (d_indices_left) {
d_indices_left[idx] = string_index_pair{nullptr, 0};
d_indices_delim[idx] = string_index_pair{nullptr, 0};
d_indices_right[idx] = string_index_pair{nullptr, 0};
}
}
__device__ size_type check_delimiter(size_type idx,
string_view const& d_str,
string_view::const_iterator& itr)
{
size_type offset = itr.byte_offset();
size_type pos = -1;
if (d_delimiter.empty()) {
if (*itr <= ' ') // whitespace delimited
pos = offset;
} else {
auto bytes = std::min(d_str.size_bytes() - offset, d_delimiter.size_bytes());
if (d_delimiter.compare(d_str.data() + offset, bytes) == 0) pos = offset;
}
if (pos >= 0) // delimiter found, set results
{
d_indices_left[idx] = string_index_pair{d_str.data(), offset};
if (d_delimiter.empty()) {
d_indices_delim[idx] = string_index_pair{d_str.data() + offset, 1};
++offset;
} else {
d_indices_delim[idx] = string_index_pair{d_delimiter.data(), d_delimiter.size_bytes()};
offset += d_delimiter.size_bytes();
}
d_indices_right[idx] = string_index_pair{d_str.data() + offset, d_str.size_bytes() - offset};
}
return pos;
}
__device__ void operator()(size_type idx)
{
if (d_strings.is_null(idx)) {
set_null_entries(idx);
return;
}
string_view d_str = d_strings.element<string_view>(idx);
size_type pos = -1;
for (auto itr = d_str.begin(); (pos < 0) && (itr < d_str.end()); ++itr)
pos = check_delimiter(idx, d_str, itr);
if (pos < 0) // delimiter not found
{
d_indices_left[idx] = string_index_pair{d_str.data(), d_str.size_bytes()};
d_indices_delim[idx] = string_index_pair{"", 0}; // two empty
d_indices_right[idx] = string_index_pair{"", 0}; // strings added
}
}
};
//
// This follows most of the same logic as partition above except that the delimiter
// search starts from the end of each string. Also, if no delimiter is found the
// resulting array includes two empty strings followed by the original string.
//
// strs = ["abcde", nullptr, "a_bc_def", "a__bc", "_ab_cd", "ab_cd_"]
// results = rpartition(strs,"_")
// col0 col1 col2
// 0 "" "" abcde
// 1 null null null
// 2 a_bc _ déf
// 3 a_ _ bc
// 4 ab _ cd
// 5 ab_cd _ ""
//
struct rpartition_fn : public partition_fn {
rpartition_fn(column_device_view const& d_strings,
string_view const& d_delimiter,
rmm::device_uvector<string_index_pair>& indices_left,
rmm::device_uvector<string_index_pair>& indices_delim,
rmm::device_uvector<string_index_pair>& indices_right)
: partition_fn(d_strings, d_delimiter, indices_left, indices_delim, indices_right)
{
}
__device__ void operator()(size_type idx)
{
if (d_strings.is_null(idx)) {
set_null_entries(idx);
return;
}
string_view d_str = d_strings.element<string_view>(idx);
size_type pos = -1;
auto itr = d_str.end();
while ((pos < 0) && (d_str.begin() < itr)) {
--itr;
pos = check_delimiter(idx, d_str, itr);
}
if (pos < 0) // delimiter not found
{
d_indices_left[idx] = string_index_pair{"", 0}; // two empty
d_indices_delim[idx] = string_index_pair{"", 0}; // strings
d_indices_right[idx] = string_index_pair{d_str.data(), d_str.size_bytes()};
}
}
};
} // namespace
std::unique_ptr<table> partition(strings_column_view const& strings,
string_scalar const& delimiter,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(delimiter.is_valid(stream), "Parameter delimiter must be valid");
auto strings_count = strings.size();
if (strings_count == 0) return std::make_unique<table>(std::vector<std::unique_ptr<column>>());
auto strings_column = column_device_view::create(strings.parent(), stream);
string_view d_delimiter(delimiter.data(), delimiter.size());
auto left_indices = rmm::device_uvector<string_index_pair>(strings_count, stream);
auto delim_indices = rmm::device_uvector<string_index_pair>(strings_count, stream);
auto right_indices = rmm::device_uvector<string_index_pair>(strings_count, stream);
partition_fn partitioner(
*strings_column, d_delimiter, left_indices, delim_indices, right_indices);
thrust::for_each_n(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
strings_count,
partitioner);
std::vector<std::unique_ptr<column>> results;
results.emplace_back(make_strings_column(left_indices, stream, mr));
results.emplace_back(make_strings_column(delim_indices, stream, mr));
results.emplace_back(make_strings_column(right_indices, stream, mr));
return std::make_unique<table>(std::move(results));
}
std::unique_ptr<table> rpartition(strings_column_view const& strings,
string_scalar const& delimiter,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(delimiter.is_valid(stream), "Parameter delimiter must be valid");
auto strings_count = strings.size();
if (strings_count == 0) return std::make_unique<table>(std::vector<std::unique_ptr<column>>());
auto strings_column = column_device_view::create(strings.parent(), stream);
string_view d_delimiter(delimiter.data(), delimiter.size());
auto left_indices = rmm::device_uvector<string_index_pair>(strings_count, stream);
auto delim_indices = rmm::device_uvector<string_index_pair>(strings_count, stream);
auto right_indices = rmm::device_uvector<string_index_pair>(strings_count, stream);
rpartition_fn partitioner(
*strings_column, d_delimiter, left_indices, delim_indices, right_indices);
thrust::for_each_n(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
strings_count,
partitioner);
std::vector<std::unique_ptr<column>> results;
results.emplace_back(make_strings_column(left_indices, stream, mr));
results.emplace_back(make_strings_column(delim_indices, stream, mr));
results.emplace_back(make_strings_column(right_indices, stream, mr));
return std::make_unique<table>(std::move(results));
}
} // namespace detail
// external APIs
std::unique_ptr<table> partition(strings_column_view const& input,
string_scalar const& delimiter,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::partition(input, delimiter, stream, mr);
}
std::unique_ptr<table> rpartition(strings_column_view const& input,
string_scalar const& delimiter,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::rpartition(input, delimiter, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/split/split_re.cu
|
/*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <strings/count_matches.hpp>
#include <strings/regex/regex_program_impl.h>
#include <strings/regex/utilities.cuh>
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/strings_column_factories.cuh>
#include <cudf/strings/split/split_re.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/distance.h>
#include <thrust/functional.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/pair.h>
#include <thrust/transform_reduce.h>
#include <thrust/transform_scan.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
using string_index_pair = thrust::pair<char const*, size_type>;
enum class split_direction {
FORWARD, ///< for split logic
BACKWARD ///< for rsplit logic
};
/**
* @brief Identify the tokens from the `idx'th` string element of `d_strings`.
*
* Each string's tokens are stored in the `d_tokens` vector.
* The `d_token_offsets` specifies the output position within `d_tokens`
* for each string.
*/
struct token_reader_fn {
column_device_view const d_strings;
split_direction const direction;
size_type const* d_token_offsets;
string_index_pair* d_tokens;
__device__ void operator()(size_type const idx, reprog_device const prog, int32_t const prog_idx)
{
if (d_strings.is_null(idx)) { return; }
auto const d_str = d_strings.element<string_view>(idx);
auto const nchars = d_str.length();
auto const token_offset = d_token_offsets[idx];
auto const token_count = d_token_offsets[idx + 1] - token_offset;
auto const d_result = d_tokens + token_offset; // store tokens here
size_type token_idx = 0;
auto itr = d_str.begin();
auto last_pos = itr;
while (itr.position() <= nchars) {
auto const match = prog.find(prog_idx, d_str, itr);
if (!match) { break; }
auto const start_pos = thrust::get<0>(match_positions_to_bytes(*match, d_str, last_pos));
// get the token (characters just before this match)
auto const token = string_index_pair{d_str.data() + last_pos.byte_offset(),
start_pos - last_pos.byte_offset()};
// store it if we have space
if (token_idx < token_count - 1) {
d_result[token_idx++] = token;
} else {
if (direction == split_direction::FORWARD) { break; } // we are done
for (auto l = 0; l < token_idx - 1; ++l) {
d_result[l] = d_result[l + 1]; // shift left
}
d_result[token_idx - 1] = token;
}
// setup for next match
last_pos += (match->second - last_pos.position());
itr = last_pos + (match->first == match->second);
}
// set the last token to the remainder of the string
d_result[token_idx] = string_index_pair{d_str.data() + last_pos.byte_offset(),
d_str.size_bytes() - last_pos.byte_offset()};
if (direction == split_direction::BACKWARD) {
// update first entry -- this happens when max_tokens is hit before the end of the string
auto const first_offset =
d_result[0].first
? static_cast<size_type>(thrust::distance(d_str.data(), d_result[0].first))
: 0;
if (first_offset) {
d_result[0] = string_index_pair{d_str.data(), first_offset + d_result[0].second};
}
}
}
};
/**
* @brief Call regex to split each input string into tokens.
*
* This will also convert the `offsets` values from counts to offsets.
*
* @param d_strings Strings to split
* @param d_prog Regex to evaluate against each string
* @param direction Whether tokens are generated forwards or backwards.
* @param max_tokens The maximum number of tokens for each split.
* @param offsets The number of matches on input.
* The offsets for each token in each string on output.
* @param stream CUDA stream used for kernel launches.
*/
rmm::device_uvector<string_index_pair> generate_tokens(column_device_view const& d_strings,
reprog_device& d_prog,
split_direction direction,
size_type maxsplit,
mutable_column_view& offsets,
rmm::cuda_stream_view stream)
{
auto const strings_count = d_strings.size();
auto const max_tokens = maxsplit > 0 ? maxsplit : std::numeric_limits<size_type>::max();
auto const begin = thrust::make_counting_iterator<size_type>(0);
auto const end = thrust::make_counting_iterator<size_type>(strings_count);
auto const d_offsets = offsets.data<size_type>();
// convert match counts to token offsets
auto map_fn = [d_strings, d_offsets, max_tokens] __device__(auto idx) {
return d_strings.is_null(idx) ? 0 : std::min(d_offsets[idx], max_tokens) + 1;
};
thrust::transform_exclusive_scan(
rmm::exec_policy(stream), begin, end + 1, d_offsets, map_fn, 0, thrust::plus<size_type>{});
// the last offset entry is the total number of tokens to be generated
auto const total_tokens = cudf::detail::get_value<size_type>(offsets, strings_count, stream);
rmm::device_uvector<string_index_pair> tokens(total_tokens, stream);
if (total_tokens == 0) { return tokens; }
launch_for_each_kernel(token_reader_fn{d_strings, direction, d_offsets, tokens.data()},
d_prog,
d_strings.size(),
stream);
return tokens;
}
/**
* @brief Returns string pair for the specified column for each string in `d_strings`
*
* This is used to build the table result of a split.
* Null is returned if the row is null or if the `column_index` is larger
* than the token count for that string.
*/
struct tokens_transform_fn {
column_device_view const d_strings;
string_index_pair const* d_tokens;
size_type const* d_token_offsets;
size_type const column_index;
__device__ string_index_pair operator()(size_type idx) const
{
auto const offset = d_token_offsets[idx];
auto const token_count = d_token_offsets[idx + 1] - offset;
return (column_index >= token_count) || d_strings.is_null(idx)
? string_index_pair{nullptr, 0}
: d_tokens[offset + column_index];
}
};
std::unique_ptr<table> split_re(strings_column_view const& input,
regex_program const& prog,
split_direction direction,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(!prog.pattern().empty(), "Parameter pattern must not be empty");
auto const strings_count = input.size();
std::vector<std::unique_ptr<column>> results;
if (strings_count == 0) {
results.push_back(make_empty_column(type_id::STRING));
return std::make_unique<table>(std::move(results));
}
// create device object from regex_program
auto d_prog = regex_device_builder::create_prog_device(prog, stream);
auto d_strings = column_device_view::create(input.parent(), stream);
// count the number of delimiters matched in each string
auto offsets = count_matches(
*d_strings, *d_prog, strings_count + 1, stream, rmm::mr::get_current_device_resource());
auto offsets_view = offsets->mutable_view();
auto d_offsets = offsets_view.data<size_type>();
// get the split tokens from the input column; this also converts the counts into offsets
auto tokens = generate_tokens(*d_strings, *d_prog, direction, maxsplit, offsets_view, stream);
// the output column count is the maximum number of tokens generated for any input string
auto const columns_count = thrust::transform_reduce(
rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_count),
[d_offsets] __device__(auto const idx) -> size_type {
return d_offsets[idx + 1] - d_offsets[idx];
},
0,
thrust::maximum<size_type>{});
// boundary case: if no columns, return one all-null column (custrings issue #119)
if (columns_count == 0) {
results.push_back(std::make_unique<column>(
data_type{type_id::STRING},
strings_count,
rmm::device_buffer{0, stream, mr}, // no data
cudf::detail::create_null_mask(strings_count, mask_state::ALL_NULL, stream, mr),
strings_count));
return std::make_unique<table>(std::move(results));
}
// convert the tokens into multiple strings columns
auto make_strings_lambda = [&](size_type column_index) {
// returns appropriate token for each row/column
auto indices_itr = cudf::detail::make_counting_transform_iterator(
0, tokens_transform_fn{*d_strings, tokens.data(), d_offsets, column_index});
return make_strings_column(indices_itr, indices_itr + strings_count, stream, mr);
};
// build a vector of columns
results.resize(columns_count);
std::transform(thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(columns_count),
results.begin(),
make_strings_lambda);
return std::make_unique<table>(std::move(results));
}
std::unique_ptr<column> split_record_re(strings_column_view const& input,
regex_program const& prog,
split_direction direction,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(!prog.pattern().empty(), "Parameter pattern must not be empty");
auto const strings_count = input.size();
// create device object from regex_program
auto d_prog = regex_device_builder::create_prog_device(prog, stream);
auto d_strings = column_device_view::create(input.parent(), stream);
// count the number of delimiters matched in each string
auto offsets = count_matches(*d_strings, *d_prog, strings_count + 1, stream, mr);
auto offsets_view = offsets->mutable_view();
// get the split tokens from the input column; this also converts the counts into offsets
auto tokens = generate_tokens(*d_strings, *d_prog, direction, maxsplit, offsets_view, stream);
// convert the tokens into one big strings column
auto strings_output = make_strings_column(tokens.begin(), tokens.end(), stream, mr);
// create a lists column using the offsets and the strings columns
return make_lists_column(strings_count,
std::move(offsets),
std::move(strings_output),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
stream,
mr);
}
} // namespace
std::unique_ptr<table> split_re(strings_column_view const& input,
regex_program const& prog,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return split_re(input, prog, split_direction::FORWARD, maxsplit, stream, mr);
}
std::unique_ptr<column> split_record_re(strings_column_view const& input,
regex_program const& prog,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return split_record_re(input, prog, split_direction::FORWARD, maxsplit, stream, mr);
}
std::unique_ptr<table> rsplit_re(strings_column_view const& input,
regex_program const& prog,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return split_re(input, prog, split_direction::BACKWARD, maxsplit, stream, mr);
}
std::unique_ptr<column> rsplit_record_re(strings_column_view const& input,
regex_program const& prog,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return split_record_re(input, prog, split_direction::BACKWARD, maxsplit, stream, mr);
}
} // namespace detail
// external APIs
std::unique_ptr<table> split_re(strings_column_view const& input,
regex_program const& prog,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::split_re(input, prog, maxsplit, stream, mr);
}
std::unique_ptr<column> split_record_re(strings_column_view const& input,
regex_program const& prog,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::split_record_re(input, prog, maxsplit, stream, mr);
}
std::unique_ptr<table> rsplit_re(strings_column_view const& input,
regex_program const& prog,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::rsplit_re(input, prog, maxsplit, stream, mr);
}
std::unique_ptr<column> rsplit_record_re(strings_column_view const& input,
regex_program const& prog,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::rsplit_record_re(input, prog, maxsplit, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/split/split.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "split.cuh"
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/split_utils.cuh>
#include <cudf/strings/detail/strings_column_factories.cuh>
#include <cudf/strings/split/split.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/fill.h>
#include <thrust/for_each.h>
#include <thrust/functional.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/reduce.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Generic split function called by split() and rsplit().
*
* This function will first count the number of delimiters in the entire strings
* column. Next it records the position of all the delimiters. These positions
* are used for the remainder of the code to build string_index_pair elements
* for each output column.
*
* The number of tokens for each string is computed by analyzing the delimiter
* position values and mapping them to each string.
* The number of output columns is determined by the string with the most tokens.
* Next the `string_index_pairs` for the entire column are created using the
* delimiter positions and their string indices vector.
*
* Finally, each column is built by creating a vector of tokens (`string_index_pairs`)
* according to their position in each string. The first token from each string goes
* into the first output column, the 2nd token from each string goes into the 2nd
* output column, etc.
*
* Output should be comparable to Pandas `split()` with `expand=True` but the
* rows/columns are transposed.
*
* ```
* import pandas as pd
* pd_series = pd.Series(['', None, 'a_b', '_a_b_', '__aa__bb__', '_a__bbb___c', '_aa_b__ccc__'])
* print(pd_series.str.split(pat='_', expand=True))
* 0 1 2 3 4 5 6
* 0 '' None None None None None None
* 1 None None None None None None None
* 2 a b None None None None None
* 3 '' a b '' None None None
* 4 '' '' aa '' bb '' ''
* 5 '' a '' bbb '' '' c
* 6 '' aa b '' ccc '' ''
*
* print(pd_series.str.split(pat='_', n=1, expand=True))
* 0 1
* 0 '' None
* 1 None None
* 2 a b
* 3 '' a_b_
* 4 '' _aa__bb__
* 5 '' a__bbb___c
* 6 '' aa_b__ccc__
*
* print(pd_series.str.split(pat='_', n=2, expand=True))
* 0 1 2
* 0 '' None None
* 1 None None None
* 2 a b None
* 3 '' a b_
* 4 '' aa__bb__
* 5 '' a _bbb___c
* 6 '' aa b__ccc__
* ```
*
* @tparam Tokenizer provides unique functions for split/rsplit.
* @param strings_column The strings to split
* @param tokenizer Tokenizer for counting and producing tokens
* @return table of columns for the output of the split
*/
template <typename Tokenizer>
std::unique_ptr<table> split_fn(strings_column_view const& input,
Tokenizer tokenizer,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
std::vector<std::unique_ptr<column>> results;
if (input.size() == input.null_count()) {
results.push_back(std::make_unique<column>(input.parent(), stream, mr));
return std::make_unique<table>(std::move(results));
}
// builds the offsets and the vector of all tokens
auto [offsets, tokens] = split_helper(input, tokenizer, stream, mr);
auto const d_offsets = offsets->view().template data<size_type>();
auto const d_tokens = tokens.data();
// compute the maximum number of tokens for any string
auto const columns_count = thrust::transform_reduce(
rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(input.size()),
[d_offsets] __device__(auto idx) -> size_type { return d_offsets[idx + 1] - d_offsets[idx]; },
0,
thrust::maximum{});
// build strings columns for each token position
for (size_type col = 0; col < columns_count; ++col) {
auto itr = cudf::detail::make_counting_transform_iterator(
0, [d_tokens, d_offsets, col] __device__(size_type idx) {
auto const offset = d_offsets[idx];
auto const token_count = d_offsets[idx + 1] - offset;
return (col < token_count) ? d_tokens[offset + col] : string_index_pair{nullptr, 0};
});
results.emplace_back(make_strings_column(itr, itr + input.size(), stream, mr));
}
return std::make_unique<table>(std::move(results));
}
/**
* @brief Base class for whitespace tokenizers.
*
* These are common methods used by both split and rsplit tokenizer functors.
*/
struct base_whitespace_split_tokenizer {
// count the tokens only between non-whitespace characters
__device__ size_type count_tokens(size_type idx) const
{
if (d_strings.is_null(idx)) return 0;
string_view const d_str = d_strings.element<string_view>(idx);
return count_tokens_whitespace(d_str, max_tokens);
}
base_whitespace_split_tokenizer(column_device_view const& d_strings, size_type max_tokens)
: d_strings(d_strings), max_tokens(max_tokens)
{
}
protected:
column_device_view const d_strings;
size_type max_tokens; // maximum number of tokens
};
/**
* @brief The tokenizer functions for split() with whitespace.
*
* The whitespace tokenizer has no delimiter and handles one or more
* consecutive whitespace characters as a single delimiter.
*/
struct whitespace_split_tokenizer_fn : base_whitespace_split_tokenizer {
/**
* @brief This will create tokens around each runs of whitespace characters.
*
* Each token is placed in `d_all_tokens` so they align consecutively
* with other tokens for the same output column.
* That is, `d_tokens[col * strings_count + string_index]` is the token at column `col`
* for string at `string_index`.
*
* @param idx Index of the string to process
* @param d_token_counts Token counts for each string
* @param d_all_tokens All output tokens for the strings column
*/
__device__ void process_tokens(size_type idx,
size_type const* d_token_counts,
string_index_pair* d_all_tokens) const
{
string_index_pair* d_tokens = d_all_tokens + idx;
if (d_strings.is_null(idx)) return;
string_view const d_str = d_strings.element<cudf::string_view>(idx);
if (d_str.empty()) return;
whitespace_string_tokenizer tokenizer(d_str);
size_type token_count = d_token_counts[idx];
size_type token_idx = 0;
position_pair token{0, 0};
while (tokenizer.next_token() && (token_idx < token_count)) {
token = tokenizer.get_token();
d_tokens[d_strings.size() * (token_idx++)] =
string_index_pair{d_str.data() + token.first, (token.second - token.first)};
}
if (token_count == max_tokens)
d_tokens[d_strings.size() * (token_idx - 1)] =
string_index_pair{d_str.data() + token.first, (d_str.size_bytes() - token.first)};
}
whitespace_split_tokenizer_fn(column_device_view const& d_strings, size_type max_tokens)
: base_whitespace_split_tokenizer(d_strings, max_tokens)
{
}
};
/**
* @brief The tokenizer functions for rsplit() with whitespace.
*
* The whitespace tokenizer has no delimiter and handles one or more
* consecutive whitespace characters as a single delimiter.
*
* This one processes tokens from the end of each string.
*/
struct whitespace_rsplit_tokenizer_fn : base_whitespace_split_tokenizer {
/**
* @brief This will create tokens around each runs of whitespace characters.
*
* Each token is placed in `d_all_tokens` so they align consecutively
* with other tokens for the same output column.
* That is, `d_tokens[col * strings_count + string_index]` is the token at column `col`
* for string at `string_index`.
*
* @param idx Index of the string to process
* @param d_token_counts Token counts for each string
* @param d_all_tokens All output tokens for the strings column
*/
__device__ void process_tokens(size_type idx, // string position index
size_type const* d_token_counts,
string_index_pair* d_all_tokens) const
{
string_index_pair* d_tokens = d_all_tokens + idx;
if (d_strings.is_null(idx)) return;
string_view const d_str = d_strings.element<cudf::string_view>(idx);
if (d_str.empty()) return;
whitespace_string_tokenizer tokenizer(d_str, true);
size_type token_count = d_token_counts[idx];
size_type token_idx = 0;
position_pair token{0, 0};
while (tokenizer.prev_token() && (token_idx < token_count)) {
token = tokenizer.get_token();
d_tokens[d_strings.size() * (token_count - 1 - token_idx)] =
string_index_pair{d_str.data() + token.first, (token.second - token.first)};
++token_idx;
}
if (token_count == max_tokens)
d_tokens[d_strings.size() * (token_count - token_idx)] =
string_index_pair{d_str.data(), token.second};
}
whitespace_rsplit_tokenizer_fn(column_device_view const& d_strings, size_type max_tokens)
: base_whitespace_split_tokenizer(d_strings, max_tokens)
{
}
};
/**
* @brief Generic split function called by split() and rsplit() using whitespace as a delimiter.
*
* The number of tokens for each string is computed by counting consecutive characters
* between runs of whitespace in each string. The number of output columns is determined
* by the string with the most tokens. Next the string_index_pairs for the entire column
* is created.
*
* Finally, each column is built by creating a vector of tokens (string_index_pairs)
* according to their position in each string. The first token from each string goes
* into the first output column, the 2nd token from each string goes into the 2nd
* output column, etc.
*
* This can be compared to Pandas `split()` with no delimiter and with `expand=True` but
* with the rows/columns transposed.
*
* import pandas as pd
* pd_series = pd.Series(['', None, 'a b', ' a b ', ' aa bb ', ' a bbb c', ' aa b ccc '])
* print(pd_series.str.split(pat=None, expand=True))
* 0 1 2
* 0 None None None
* 1 None None None
* 2 a b None
* 3 a b None
* 4 aa bb None
* 5 a bbb c
* 6 aa b ccc
*
* print(pd_series.str.split(pat=None, n=1, expand=True))
* 0 1
* 0 None None
* 1 None None
* 2 a b
* 3 a b
* 4 aa bb
* 5 a bbb c
* 6 aa b ccc
*
* print(pd_series.str.split(pat=None, n=2, expand=True))
* 0 1 2
* 0 None None None
* 1 None None None
* 2 a b None
* 3 a b None
* 4 aa bb None
* 5 a bbb c
* 6 aa b ccc
*
* @tparam Tokenizer provides unique functions for split/rsplit.
* @param strings_count The number of strings in the column
* @param tokenizer Tokenizer for counting and producing tokens
* @return table of columns for the output of the split
*/
template <typename Tokenizer>
std::unique_ptr<table> whitespace_split_fn(size_type strings_count,
Tokenizer tokenizer,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// compute the number of tokens per string
rmm::device_uvector<size_type> token_counts(strings_count, stream);
auto d_token_counts = token_counts.data();
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_count),
d_token_counts,
[tokenizer] __device__(size_type idx) { return tokenizer.count_tokens(idx); });
// column count is the maximum number of tokens for any string
size_type const columns_count = thrust::reduce(
rmm::exec_policy(stream), token_counts.begin(), token_counts.end(), 0, thrust::maximum{});
std::vector<std::unique_ptr<column>> results;
// boundary case: if no columns, return one null column (issue #119)
if (columns_count == 0) {
results.push_back(std::make_unique<column>(
data_type{type_id::STRING},
strings_count,
rmm::device_buffer{0, stream, mr}, // no data
cudf::detail::create_null_mask(strings_count, mask_state::ALL_NULL, stream, mr),
strings_count));
}
// get the positions for every token
rmm::device_uvector<string_index_pair> tokens(columns_count * strings_count, stream);
string_index_pair* d_tokens = tokens.data();
thrust::fill(rmm::exec_policy(stream),
d_tokens,
d_tokens + (columns_count * strings_count),
string_index_pair{nullptr, 0});
thrust::for_each_n(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
strings_count,
[tokenizer, d_token_counts, d_tokens] __device__(size_type idx) {
tokenizer.process_tokens(idx, d_token_counts, d_tokens);
});
// Create each column.
// - Each pair points to a string for that column for each row.
// - Create the strings column from the vector using the strings factory.
for (size_type col = 0; col < columns_count; ++col) {
auto column_tokens = d_tokens + (col * strings_count);
results.emplace_back(
make_strings_column(column_tokens, column_tokens + strings_count, stream, mr));
}
return std::make_unique<table>(std::move(results));
}
} // namespace
std::unique_ptr<table> split(strings_column_view const& strings_column,
string_scalar const& delimiter,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(delimiter.is_valid(stream), "Parameter delimiter must be valid");
size_type max_tokens = maxsplit > 0 ? maxsplit + 1 : std::numeric_limits<size_type>::max();
auto strings_device_view = column_device_view::create(strings_column.parent(), stream);
if (delimiter.size() == 0) {
return whitespace_split_fn(strings_column.size(),
whitespace_split_tokenizer_fn{*strings_device_view, max_tokens},
stream,
mr);
}
string_view d_delimiter(delimiter.data(), delimiter.size());
return split_fn(
strings_column, split_tokenizer_fn{*strings_device_view, d_delimiter, max_tokens}, stream, mr);
}
std::unique_ptr<table> rsplit(strings_column_view const& strings_column,
string_scalar const& delimiter,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(delimiter.is_valid(stream), "Parameter delimiter must be valid");
size_type max_tokens = maxsplit > 0 ? maxsplit + 1 : std::numeric_limits<size_type>::max();
auto strings_device_view = column_device_view::create(strings_column.parent(), stream);
if (delimiter.size() == 0) {
return whitespace_split_fn(strings_column.size(),
whitespace_rsplit_tokenizer_fn{*strings_device_view, max_tokens},
stream,
mr);
}
string_view d_delimiter(delimiter.data(), delimiter.size());
return split_fn(
strings_column, rsplit_tokenizer_fn{*strings_device_view, d_delimiter, max_tokens}, stream, mr);
}
} // namespace detail
// external APIs
std::unique_ptr<table> split(strings_column_view const& strings_column,
string_scalar const& delimiter,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::split(strings_column, delimiter, maxsplit, stream, mr);
}
std::unique_ptr<table> rsplit(strings_column_view const& strings_column,
string_scalar const& delimiter,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::rsplit(strings_column, delimiter, maxsplit, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/split/split_record.cu
|
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "split.cuh"
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/lists/detail/lists_column_factories.hpp>
#include <cudf/strings/detail/split_utils.cuh>
#include <cudf/strings/detail/strings_column_factories.cuh>
#include <cudf/strings/split/split.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/scan.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
template <typename Tokenizer>
std::unique_ptr<column> split_record_fn(strings_column_view const& input,
Tokenizer tokenizer,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) {
return cudf::lists::detail::make_empty_lists_column(data_type{type_id::STRING}, stream, mr);
}
if (input.size() == input.null_count()) {
auto offsets = std::make_unique<column>(input.offsets(), stream, mr);
auto results = make_empty_column(type_id::STRING);
return make_lists_column(input.size(),
std::move(offsets),
std::move(results),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
stream,
mr);
}
// builds the offsets and the vector of all tokens
auto [offsets, tokens] = split_helper(input, tokenizer, stream, mr);
// build a strings column from the tokens
auto strings_child = make_strings_column(tokens.begin(), tokens.end(), stream, mr);
return make_lists_column(input.size(),
std::move(offsets),
std::move(strings_child),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
stream,
mr);
}
enum class Direction { FORWARD, BACKWARD };
/**
* @brief Identify the tokens from the `idx'th` string element of `d_strings`.
*/
template <Direction direction>
struct whitespace_token_reader_fn {
column_device_view const d_strings; // strings to split
size_type const max_tokens = std::numeric_limits<size_type>::max();
size_type const* d_token_offsets{};
string_index_pair* d_tokens{};
__device__ size_type count_tokens(size_type idx) const
{
if (d_strings.is_null(idx)) { return 0; }
auto const d_str = d_strings.element<string_view>(idx);
return count_tokens_whitespace(d_str, max_tokens);
}
__device__ void operator()(size_type idx)
{
auto const token_offset = d_token_offsets[idx];
auto const token_count = d_token_offsets[idx + 1] - token_offset;
if (token_count == 0) { return; }
auto d_result = d_tokens + token_offset;
auto const d_str = d_strings.element<string_view>(idx);
whitespace_string_tokenizer tokenizer(d_str, direction != Direction::FORWARD);
size_type token_idx = 0;
position_pair token{0, 0};
if constexpr (direction == Direction::FORWARD) {
while (tokenizer.next_token() && (token_idx < token_count)) {
token = tokenizer.get_token();
d_result[token_idx++] =
string_index_pair{d_str.data() + token.first, token.second - token.first};
}
--token_idx;
token.second = d_str.size_bytes() - token.first;
} else {
while (tokenizer.prev_token() && (token_idx < token_count)) {
token = tokenizer.get_token();
d_result[token_count - 1 - token_idx] =
string_index_pair{d_str.data() + token.first, token.second - token.first};
++token_idx;
}
token_idx = token_count - token_idx; // token_count - 1 - (token_idx-1)
token.first = 0;
}
// reset last token only if we hit the max
if (token_count == max_tokens)
d_result[token_idx] = string_index_pair{d_str.data() + token.first, token.second};
}
};
} // namespace
// The output is one list item per string
template <typename TokenReader>
std::unique_ptr<column> whitespace_split_record_fn(strings_column_view const& input,
TokenReader reader,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// create offsets column by counting the number of tokens per string
auto sizes_itr = cudf::detail::make_counting_transform_iterator(
0, [reader] __device__(auto idx) { return reader.count_tokens(idx); });
auto [offsets, total_tokens] =
cudf::detail::make_offsets_child_column(sizes_itr, sizes_itr + input.size(), stream, mr);
auto d_offsets = offsets->view().template data<cudf::size_type>();
// split each string into an array of index-pair values
rmm::device_uvector<string_index_pair> tokens(total_tokens, stream);
reader.d_token_offsets = d_offsets;
reader.d_tokens = tokens.data();
thrust::for_each_n(
rmm::exec_policy(stream), thrust::make_counting_iterator<size_type>(0), input.size(), reader);
// convert the index-pairs into one big strings column
auto strings_output = make_strings_column(tokens.begin(), tokens.end(), stream, mr);
// create a lists column using the offsets and the strings columns
return make_lists_column(input.size(),
std::move(offsets),
std::move(strings_output),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
stream,
mr);
}
template <Direction direction>
std::unique_ptr<column> split_record(strings_column_view const& strings,
string_scalar const& delimiter,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(delimiter.is_valid(stream), "Parameter delimiter must be valid");
// makes consistent with Pandas
size_type max_tokens = maxsplit > 0 ? maxsplit + 1 : std::numeric_limits<size_type>::max();
auto d_strings_column_ptr = column_device_view::create(strings.parent(), stream);
if (delimiter.size() == 0) {
return whitespace_split_record_fn(
strings,
whitespace_token_reader_fn<direction>{*d_strings_column_ptr, max_tokens},
stream,
mr);
} else {
string_view d_delimiter(delimiter.data(), delimiter.size());
if (direction == Direction::FORWARD) {
return split_record_fn(
strings, split_tokenizer_fn{*d_strings_column_ptr, d_delimiter, max_tokens}, stream, mr);
} else {
return split_record_fn(
strings, rsplit_tokenizer_fn{*d_strings_column_ptr, d_delimiter, max_tokens}, stream, mr);
}
}
}
} // namespace detail
// external APIs
std::unique_ptr<column> split_record(strings_column_view const& strings,
string_scalar const& delimiter,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::split_record<detail::Direction::FORWARD>(strings, delimiter, maxsplit, stream, mr);
}
std::unique_ptr<column> rsplit_record(strings_column_view const& strings,
string_scalar const& delimiter,
size_type maxsplit,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::split_record<detail::Direction::BACKWARD>(
strings, delimiter, maxsplit, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/split/split.cuh
|
/*
* Copyright (c) 2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/sizes_to_offsets_iterator.cuh>
#include <cudf/strings/detail/split_utils.cuh>
#include <cudf/strings/detail/strings_column_factories.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/span.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/binary_search.h>
#include <thrust/copy.h>
#include <thrust/count.h>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/scan.h>
#include <thrust/transform.h>
#include <cuda/atomic>
namespace cudf::strings::detail {
/**
* @brief Base class for delimiter-based tokenizers
*
* These are common methods used by both split and rsplit tokenizer functors.
*
* The Derived class is required to implement the `process_tokens` function.
*/
template <typename Derived>
struct base_split_tokenizer {
__device__ char const* get_base_ptr() const
{
return d_strings.child(strings_column_view::chars_column_index).data<char>();
}
__device__ string_view const get_string(size_type idx) const
{
return d_strings.element<string_view>(idx);
}
__device__ bool is_valid(size_type idx) const { return d_strings.is_valid(idx); }
/**
* @brief Returns `true` if the byte at `idx` is the start of the delimiter
*
* @param idx Index of a byte in the chars column
* @param d_offsets Offsets values to locate the chars ranges
* @param chars_bytes Total number of characters to process
* @return true if delimiter is found starting at position `idx`
*/
__device__ bool is_delimiter(size_type idx,
size_type const* d_offsets,
size_type chars_bytes) const
{
auto const d_chars = get_base_ptr() + d_offsets[0];
if (idx + d_delimiter.size_bytes() > chars_bytes) { return false; }
return d_delimiter.compare(d_chars + idx, d_delimiter.size_bytes()) == 0;
}
/**
* @brief This counts the tokens for strings that contain delimiters
*
* Counting tokens is the same regardless if counting from the left
* or from the right. This logic counts from the left which is simpler.
* The count will be truncated appropriately to the max_tokens value.
*
* @param idx Index of input string
* @param d_positions Start positions of all the delimiters
* @param d_delimiter_offsets Offsets per string to delimiters in d_positions
*/
__device__ size_type count_tokens(size_type idx,
size_type const* d_positions,
size_type const* d_delimiter_offsets) const
{
if (!is_valid(idx)) { return 0; }
auto const delim_size = d_delimiter.size_bytes();
auto const d_str = get_string(idx);
auto const d_str_end = d_str.data() + d_str.size_bytes();
auto const base_ptr = get_base_ptr() + delim_size - 1;
auto const delimiters =
cudf::device_span<size_type const>(d_positions + d_delimiter_offsets[idx],
d_delimiter_offsets[idx + 1] - d_delimiter_offsets[idx]);
size_type token_count = 1; // all strings will have at least one token
size_type last_pos = delimiters[0] - delim_size;
for (auto d_pos : delimiters) {
// delimiter must fit in string && overlapping delimiters are ignored
if (((base_ptr + d_pos) < d_str_end) && ((d_pos - last_pos) >= delim_size)) {
++token_count;
last_pos = d_pos;
}
}
// number of tokens is capped to max_tokens
return ((max_tokens > 0) && (token_count > max_tokens)) ? max_tokens : token_count;
}
/**
* @brief This will create tokens around each delimiter honoring the string boundaries
* in which the delimiter resides
*
* Each token is placed in `d_all_tokens` so they align consecutively
* with other tokens for the same output column.
*
* The actual token extraction is performed in the subclass process_tokens() function.
*
* @param idx Index of the string to tokenize
* @param d_tokens_offsets Token offsets for each string
* @param d_positions The beginning byte position of each delimiter
* @param d_delimiter_offsets Offsets to d_positions to each delimiter set per string
* @param d_all_tokens All output tokens for the strings column
*/
__device__ void get_tokens(size_type idx,
size_type const* d_tokens_offsets,
size_type const* d_positions,
size_type const* d_delimiter_offsets,
string_index_pair* d_all_tokens) const
{
auto const d_tokens = // this string's tokens output
cudf::device_span<string_index_pair>(d_all_tokens + d_tokens_offsets[idx],
d_tokens_offsets[idx + 1] - d_tokens_offsets[idx]);
if (!is_valid(idx)) { return; }
auto const d_str = get_string(idx);
// max_tokens already included in token counts
if (d_tokens.size() == 1) {
d_tokens[0] = string_index_pair{d_str.data(), d_str.size_bytes()};
return;
}
auto const delimiters =
cudf::device_span<size_type const>(d_positions + d_delimiter_offsets[idx],
d_delimiter_offsets[idx + 1] - d_delimiter_offsets[idx]);
auto& derived = static_cast<Derived const&>(*this);
derived.process_tokens(d_str, delimiters, d_tokens);
}
base_split_tokenizer(column_device_view const& d_strings,
string_view const& d_delimiter,
size_type max_tokens)
: d_strings(d_strings), d_delimiter(d_delimiter), max_tokens(max_tokens)
{
}
protected:
column_device_view const d_strings; // strings to split
string_view const d_delimiter; // delimiter for split
size_type max_tokens; // maximum number of tokens to identify
};
/**
* @brief The tokenizer functions for forward splitting
*/
struct split_tokenizer_fn : base_split_tokenizer<split_tokenizer_fn> {
/**
* @brief This will create tokens around each delimiter honoring the string boundaries
*
* The tokens are processed from the beginning of each string ignoring overlapping
* delimiters and honoring the `max_tokens` value.
*
* @param d_str String to tokenize
* @param d_delimiters Positions of delimiters for this string
* @param d_tokens Output vector to store tokens for this string
*/
__device__ void process_tokens(string_view const d_str,
device_span<size_type const> d_delimiters,
device_span<string_index_pair> d_tokens) const
{
auto const base_ptr = get_base_ptr(); // d_positions values based on this
auto str_ptr = d_str.data();
auto const str_end = str_ptr + d_str.size_bytes(); // end of the string
auto const token_count = static_cast<size_type>(d_tokens.size());
auto const delim_size = d_delimiter.size_bytes();
// build the index-pair of each token for this string
size_type token_idx = 0;
for (auto d_pos : d_delimiters) {
auto const next_delim = base_ptr + d_pos;
if (next_delim < str_ptr || ((next_delim + delim_size) > str_end)) { continue; }
auto const end_ptr = (token_idx + 1 < token_count) ? next_delim : str_end;
// store the token into the output vector
d_tokens[token_idx++] =
string_index_pair{str_ptr, static_cast<size_type>(thrust::distance(str_ptr, end_ptr))};
// setup for next token
str_ptr = end_ptr + delim_size;
}
// include anything leftover
if (token_idx < token_count) {
d_tokens[token_idx] =
string_index_pair{str_ptr, static_cast<size_type>(thrust::distance(str_ptr, str_end))};
}
}
split_tokenizer_fn(column_device_view const& d_strings,
string_view const& d_delimiter,
size_type max_tokens)
: base_split_tokenizer(d_strings, d_delimiter, max_tokens)
{
}
};
/**
* @brief The tokenizer functions for backwards splitting
*
* Same as split_tokenizer_fn except delimiters are searched from the end of each string.
*/
struct rsplit_tokenizer_fn : base_split_tokenizer<rsplit_tokenizer_fn> {
/**
* @brief This will create tokens around each delimiter honoring the string boundaries
*
* The tokens are processed from the end of each string ignoring overlapping
* delimiters and honoring the `max_tokens` value.
*
* @param d_str String to tokenize
* @param d_delimiters Positions of delimiters for this string
* @param d_tokens Output vector to store tokens for this string
*/
__device__ void process_tokens(string_view const d_str,
device_span<size_type const> d_delimiters,
device_span<string_index_pair> d_tokens) const
{
auto const base_ptr = get_base_ptr(); // d_positions values are based on this ptr
auto const str_begin = d_str.data(); // beginning of the string
auto const token_count = static_cast<size_type>(d_tokens.size());
auto const delim_count = static_cast<size_type>(d_delimiters.size());
auto const delim_size = d_delimiter.size_bytes();
// build the index-pair of each token for this string
auto str_ptr = str_begin + d_str.size_bytes();
size_type token_idx = 0;
for (auto d = delim_count - 1; d >= 0; --d) { // read right-to-left
auto const prev_delim = base_ptr + d_delimiters[d] + delim_size;
if (prev_delim > str_ptr || ((prev_delim - delim_size) < str_begin)) { continue; }
auto const start_ptr = (token_idx + 1 < token_count) ? prev_delim : str_begin;
// store the token into the output vector right-to-left
d_tokens[token_count - token_idx - 1] =
string_index_pair{start_ptr, static_cast<size_type>(thrust::distance(start_ptr, str_ptr))};
// setup for next token
str_ptr = start_ptr - delim_size;
++token_idx;
}
// include anything leftover (rightover?)
if (token_idx < token_count) {
d_tokens[0] =
string_index_pair{str_begin, static_cast<size_type>(thrust::distance(str_begin, str_ptr))};
}
}
rsplit_tokenizer_fn(column_device_view const& d_strings,
string_view const& d_delimiter,
size_type max_tokens)
: base_split_tokenizer(d_strings, d_delimiter, max_tokens)
{
}
};
/**
* @brief Helper function used by split/rsplit and split_record/rsplit_record
*
* This function returns all the token/split positions within the input column as processed by
* the given tokenizer. It also returns the offsets for each set of tokens identified per string.
*
* @tparam Tokenizer Type of the tokenizer object
*
* @param input The input column of strings to split
* @param tokenizer Object used for counting and identifying delimiters and tokens
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate the returned objects' device memory.
*/
template <typename Tokenizer>
std::pair<std::unique_ptr<column>, rmm::device_uvector<string_index_pair>> split_helper(
strings_column_view const& input,
Tokenizer tokenizer,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto const strings_count = input.size();
auto const chars_bytes =
cudf::detail::get_value<size_type>(input.offsets(), input.offset() + strings_count, stream) -
cudf::detail::get_value<size_type>(input.offsets(), input.offset(), stream);
auto d_offsets = input.offsets_begin();
// count the number of delimiters in the entire column
auto const delimiter_count =
thrust::count_if(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(chars_bytes),
[tokenizer, d_offsets, chars_bytes] __device__(size_type idx) {
return tokenizer.is_delimiter(idx, d_offsets, chars_bytes);
});
// Create a vector of every delimiter position in the chars column.
// These may include overlapping or otherwise out-of-bounds delimiters which
// will be resolved during token processing.
auto delimiter_positions = rmm::device_uvector<size_type>(delimiter_count, stream);
auto d_positions = delimiter_positions.data();
auto const copy_end =
thrust::copy_if(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(chars_bytes),
delimiter_positions.begin(),
[tokenizer, d_offsets, chars_bytes] __device__(size_type idx) {
return tokenizer.is_delimiter(idx, d_offsets, chars_bytes);
});
// create a vector of offsets to each string's delimiter set within delimiter_positions
auto const delimiter_offsets = [&] {
// first, create a vector of string indices for each delimiter
auto string_indices = rmm::device_uvector<size_type>(delimiter_count, stream);
thrust::upper_bound(rmm::exec_policy(stream),
d_offsets,
d_offsets + strings_count,
delimiter_positions.begin(),
copy_end,
string_indices.begin());
// compute delimiter offsets per string
auto delimiter_offsets = rmm::device_uvector<size_type>(strings_count + 1, stream);
auto d_delimiter_offsets = delimiter_offsets.data();
// memset to zero-out the delimiter counts for any null-entries or strings with no delimiters
CUDF_CUDA_TRY(cudaMemsetAsync(
d_delimiter_offsets, 0, delimiter_offsets.size() * sizeof(size_type), stream.value()));
// next, count the number of delimiters per string
auto d_string_indices = string_indices.data(); // identifies strings with delimiters only
thrust::for_each_n(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
delimiter_count,
[d_string_indices, d_delimiter_offsets] __device__(size_type idx) {
auto const str_idx = d_string_indices[idx] - 1;
cuda::atomic_ref<size_type, cuda::thread_scope_device> ref{
*(d_delimiter_offsets + str_idx)};
ref.fetch_add(1, cuda::std::memory_order_relaxed);
});
// finally, convert the delimiter counts into offsets
thrust::exclusive_scan(rmm::exec_policy(stream),
delimiter_offsets.begin(),
delimiter_offsets.end(),
delimiter_offsets.begin());
return delimiter_offsets;
}();
auto const d_delimiter_offsets = delimiter_offsets.data();
// compute the number of tokens per string
auto token_counts = rmm::device_uvector<size_type>(strings_count, stream);
thrust::transform(
rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_count),
token_counts.begin(),
[tokenizer, d_positions, d_delimiter_offsets] __device__(size_type idx) -> size_type {
return tokenizer.count_tokens(idx, d_positions, d_delimiter_offsets);
});
// create offsets from the counts for return to the caller
auto offsets = std::get<0>(
cudf::detail::make_offsets_child_column(token_counts.begin(), token_counts.end(), stream, mr));
auto const total_tokens =
cudf::detail::get_value<size_type>(offsets->view(), strings_count, stream);
auto const d_tokens_offsets = offsets->view().data<size_type>();
// build a vector of all the token positions for all the strings
auto tokens = rmm::device_uvector<string_index_pair>(total_tokens, stream);
auto d_tokens = tokens.data();
thrust::for_each_n(
rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
strings_count,
[tokenizer, d_tokens_offsets, d_positions, d_delimiter_offsets, d_tokens] __device__(
size_type idx) {
tokenizer.get_tokens(idx, d_tokens_offsets, d_positions, d_delimiter_offsets, d_tokens);
});
return std::make_pair(std::move(offsets), std::move(tokens));
}
} // namespace cudf::strings::detail
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/copying/concatenate.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/utilities/cuda.cuh>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/strings/detail/concatenate.hpp>
#include <cudf/strings/detail/utilities.hpp>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/table/table_device_view.cuh>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_scalar.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/advance.h>
#include <thrust/binary_search.h>
#include <thrust/execution_policy.h>
#include <thrust/functional.h>
#include <thrust/scan.h>
#include <thrust/transform.h>
#include <thrust/transform_scan.h>
namespace cudf {
namespace strings {
namespace detail {
// Benchmark data, shared at https://github.com/rapidsai/cudf/pull/4703, shows
// that the single kernel optimization generally performs better, but when the
// number of chars/col is beyond a certain threshold memcpy performs better.
// This heuristic estimates which strategy will give better performance by
// comparing the mean chars/col with values from the above table.
constexpr bool use_fused_kernel_heuristic(bool const has_nulls,
size_t const total_bytes,
size_t const num_columns)
{
return has_nulls ? total_bytes < num_columns * 1572864 // midpoint of 1048576 and 2097152
: total_bytes < num_columns * 393216; // midpoint of 262144 and 524288
}
// Using a functor instead of a lambda as a workaround for:
// error: The enclosing parent function ("create_strings_device_views") for an
// extended __device__ lambda must not have deduced return type
struct chars_size_transform {
__device__ size_t operator()(column_device_view const& col) const
{
if (col.size() > 0) {
constexpr auto offsets_index = strings_column_view::offsets_column_index;
auto d_offsets = col.child(offsets_index).data<int32_t>();
return d_offsets[col.size() + col.offset()] - d_offsets[col.offset()];
} else {
return 0;
}
}
};
auto create_strings_device_views(host_span<column_view const> views, rmm::cuda_stream_view stream)
{
CUDF_FUNC_RANGE();
// Assemble contiguous array of device views
auto [device_view_owners, device_views_ptr] =
contiguous_copy_column_device_views<column_device_view>(views, stream);
// Compute the partition offsets and size of offset column
// Note: Using 64-bit size_t so we can detect overflow of 32-bit size_type
auto input_offsets = std::vector<size_t>(views.size() + 1);
auto offset_it = std::next(input_offsets.begin());
thrust::transform(
thrust::host, views.begin(), views.end(), offset_it, [](auto const& col) -> size_t {
return static_cast<size_t>(col.size());
});
thrust::inclusive_scan(thrust::host, offset_it, input_offsets.end(), offset_it);
auto d_input_offsets = cudf::detail::make_device_uvector_async(
input_offsets, stream, rmm::mr::get_current_device_resource());
auto const output_size = input_offsets.back();
// Compute the partition offsets and size of chars column
// Note: Using 64-bit size_t so we can detect overflow of 32-bit size_type
auto d_partition_offsets = rmm::device_uvector<size_t>(views.size() + 1, stream);
d_partition_offsets.set_element_to_zero_async(0, stream); // zero first element
thrust::transform_inclusive_scan(rmm::exec_policy(stream),
device_views_ptr,
device_views_ptr + views.size(),
std::next(d_partition_offsets.begin()),
chars_size_transform{},
thrust::plus{});
auto const output_chars_size = d_partition_offsets.back_element(stream);
stream.synchronize(); // ensure copy of output_chars_size is complete before returning
return std::make_tuple(std::move(device_view_owners),
device_views_ptr,
std::move(d_input_offsets),
std::move(d_partition_offsets),
output_size,
output_chars_size);
}
template <size_type block_size, bool Nullable>
__global__ void fused_concatenate_string_offset_kernel(column_device_view const* input_views,
size_t const* input_offsets,
size_t const* partition_offsets,
size_type const num_input_views,
size_type const output_size,
int32_t* output_data,
bitmask_type* output_mask,
size_type* out_valid_count)
{
cudf::thread_index_type output_index = threadIdx.x + blockIdx.x * blockDim.x;
size_type warp_valid_count = 0;
unsigned active_mask;
if (Nullable) { active_mask = __ballot_sync(0xFFFF'FFFFu, output_index < output_size); }
while (output_index < output_size) {
// Lookup input index by searching for output index in offsets
auto const offset_it = thrust::prev(thrust::upper_bound(
thrust::seq, input_offsets, input_offsets + num_input_views, output_index));
size_type const partition_index = offset_it - input_offsets;
auto const offset_index = output_index - *offset_it;
auto const& input_view = input_views[partition_index];
constexpr auto offsets_child = strings_column_view::offsets_column_index;
auto const* input_data = input_view.child(offsets_child).data<int32_t>();
output_data[output_index] =
input_data[offset_index + input_view.offset()] // handle parent offset
- input_data[input_view.offset()] // subtract first offset if non-zero
+ partition_offsets[partition_index]; // add offset of source column
if (Nullable) {
bool const bit_is_set = input_view.is_valid(offset_index);
bitmask_type const new_word = __ballot_sync(active_mask, bit_is_set);
// First thread writes bitmask word
if (threadIdx.x % cudf::detail::warp_size == 0) {
output_mask[word_index(output_index)] = new_word;
}
warp_valid_count += __popc(new_word);
}
output_index += blockDim.x * gridDim.x;
if (Nullable) { active_mask = __ballot_sync(active_mask, output_index < output_size); }
}
// Fill final offsets index with total size of char data
if (output_index == output_size) {
output_data[output_size] = partition_offsets[num_input_views];
}
if (Nullable) {
using cudf::detail::single_lane_block_sum_reduce;
auto block_valid_count = single_lane_block_sum_reduce<block_size, 0>(warp_valid_count);
if (threadIdx.x == 0) { atomicAdd(out_valid_count, block_valid_count); }
}
}
__global__ void fused_concatenate_string_chars_kernel(column_device_view const* input_views,
size_t const* partition_offsets,
size_type const num_input_views,
size_type const output_size,
char* output_data)
{
cudf::thread_index_type output_index = threadIdx.x + blockIdx.x * blockDim.x;
while (output_index < output_size) {
// Lookup input index by searching for output index in offsets
auto const offset_it = thrust::prev(thrust::upper_bound(
thrust::seq, partition_offsets, partition_offsets + num_input_views, output_index));
size_type const partition_index = offset_it - partition_offsets;
auto const offset_index = output_index - *offset_it;
auto const& input_view = input_views[partition_index];
constexpr auto offsets_child = strings_column_view::offsets_column_index;
auto const* input_offsets_data = input_view.child(offsets_child).data<int32_t>();
constexpr auto chars_child = strings_column_view::chars_column_index;
auto const* input_chars_data = input_view.child(chars_child).data<char>();
auto const first_char = input_offsets_data[input_view.offset()];
output_data[output_index] = input_chars_data[offset_index + first_char];
output_index += blockDim.x * gridDim.x;
}
}
std::unique_ptr<column> concatenate(host_span<column_view const> columns,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
// Compute output sizes
auto const device_views = create_strings_device_views(columns, stream);
auto const& d_views = std::get<1>(device_views);
auto const& d_input_offsets = std::get<2>(device_views);
auto const& d_partition_offsets = std::get<3>(device_views);
auto const strings_count = std::get<4>(device_views);
auto const total_bytes = std::get<5>(device_views);
auto const offsets_count = strings_count + 1;
if (strings_count == 0) { return make_empty_column(type_id::STRING); }
CUDF_EXPECTS(offsets_count <= static_cast<std::size_t>(std::numeric_limits<size_type>::max()),
"total number of strings exceeds the column size limit",
std::overflow_error);
CUDF_EXPECTS(total_bytes <= static_cast<std::size_t>(std::numeric_limits<size_type>::max()),
"total size of strings exceeds the column size limit",
std::overflow_error);
bool const has_nulls =
std::any_of(columns.begin(), columns.end(), [](auto const& col) { return col.has_nulls(); });
// create chars column
auto chars_column = create_chars_child_column(total_bytes, stream, mr);
auto d_new_chars = chars_column->mutable_view().data<char>();
chars_column->set_null_count(0);
// create offsets column
auto offsets_column = make_numeric_column(
data_type{type_id::INT32}, offsets_count, mask_state::UNALLOCATED, stream, mr);
auto d_new_offsets = offsets_column->mutable_view().data<int32_t>();
offsets_column->set_null_count(0);
rmm::device_buffer null_mask{0, stream, mr};
size_type null_count{};
if (has_nulls) {
null_mask =
cudf::detail::create_null_mask(strings_count, mask_state::UNINITIALIZED, stream, mr);
}
{ // Copy offsets columns with single kernel launch
rmm::device_scalar<size_type> d_valid_count(0, stream);
constexpr size_type block_size{256};
cudf::detail::grid_1d config(offsets_count, block_size);
auto const kernel = has_nulls ? fused_concatenate_string_offset_kernel<block_size, true>
: fused_concatenate_string_offset_kernel<block_size, false>;
kernel<<<config.num_blocks, config.num_threads_per_block, 0, stream.value()>>>(
d_views,
d_input_offsets.data(),
d_partition_offsets.data(),
static_cast<size_type>(columns.size()),
strings_count,
d_new_offsets,
reinterpret_cast<bitmask_type*>(null_mask.data()),
d_valid_count.data());
if (has_nulls) { null_count = strings_count - d_valid_count.value(stream); }
}
if (total_bytes > 0) {
// Use a heuristic to guess when the fused kernel will be faster than memcpy
if (use_fused_kernel_heuristic(has_nulls, total_bytes, columns.size())) {
// Use single kernel launch to copy chars columns
constexpr size_type block_size{256};
cudf::detail::grid_1d config(total_bytes, block_size);
auto const kernel = fused_concatenate_string_chars_kernel;
kernel<<<config.num_blocks, config.num_threads_per_block, 0, stream.value()>>>(
d_views,
d_partition_offsets.data(),
static_cast<size_type>(columns.size()),
total_bytes,
d_new_chars);
} else {
// Memcpy each input chars column (more efficient for very large strings)
for (auto column = columns.begin(); column != columns.end(); ++column) {
size_type column_size = column->size();
if (column_size == 0) // nothing to do
continue; // empty column may not have children
size_type column_offset = column->offset();
column_view offsets_child = column->child(strings_column_view::offsets_column_index);
column_view chars_child = column->child(strings_column_view::chars_column_index);
auto bytes_offset =
cudf::detail::get_value<size_type>(offsets_child, column_offset, stream);
// copy the chars column data
auto d_chars = chars_child.data<char>() + bytes_offset;
auto const bytes =
cudf::detail::get_value<size_type>(offsets_child, column_size + column_offset, stream) -
bytes_offset;
CUDF_CUDA_TRY(
cudaMemcpyAsync(d_new_chars, d_chars, bytes, cudaMemcpyDefault, stream.value()));
// get ready for the next column
d_new_chars += bytes;
}
}
}
return make_strings_column(strings_count,
std::move(offsets_column),
std::move(chars_column),
null_count,
std::move(null_mask));
}
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/copying/shift.cu
|
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/copy.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/sizes_to_offsets_iterator.cuh>
#include <cudf/strings/detail/copying.hpp>
#include <cudf/strings/detail/utilities.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform.h>
namespace cudf::strings::detail {
namespace {
struct output_sizes_fn {
column_device_view const d_column; // input strings column
string_view const d_filler;
size_type const offset;
__device__ size_type get_string_size_at(size_type idx)
{
return d_column.is_null(idx) ? 0 : d_column.element<string_view>(idx).size_bytes();
}
__device__ size_type operator()(size_type idx)
{
auto const last_index = offset < 0 ? d_column.size() + offset : offset;
if (offset < 0) {
// shift left: a,b,c,d,e,f -> b,c,d,e,f,x
return (idx < last_index) ? get_string_size_at(idx - offset) : d_filler.size_bytes();
} else {
// shift right: a,b,c,d,e,f -> x,a,b,c,d,e
return (idx < last_index) ? d_filler.size_bytes() : get_string_size_at(idx - offset);
}
}
};
struct shift_chars_fn {
column_device_view const d_column; // input strings column
string_view const d_filler;
size_type const offset;
__device__ char operator()(size_type idx)
{
if (offset < 0) {
auto const last_index = -offset;
if (idx < last_index) {
auto const first_index =
offset + d_column.child(strings_column_view::offsets_column_index)
.element<size_type>(d_column.offset() + d_column.size());
return d_column.child(strings_column_view::chars_column_index)
.element<char>(idx + first_index);
} else {
auto const char_index = idx - last_index;
return d_filler.data()[char_index % d_filler.size_bytes()];
}
} else {
if (idx < offset) {
return d_filler.data()[idx % d_filler.size_bytes()];
} else {
return d_column.child(strings_column_view::chars_column_index)
.element<char>(idx - offset +
d_column.child(strings_column_view::offsets_column_index)
.element<size_type>(d_column.offset()));
}
}
}
};
} // namespace
std::unique_ptr<column> shift(strings_column_view const& input,
size_type offset,
scalar const& fill_value,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto d_fill_str = static_cast<string_scalar const&>(fill_value).value(stream);
// adjust offset when greater than the size of the input
if (std::abs(offset) > input.size()) { offset = input.size(); }
// build the output offsets by computing the sizes of each output row
auto const d_input = column_device_view::create(input.parent(), stream);
auto sizes_itr = cudf::detail::make_counting_transform_iterator(
0, output_sizes_fn{*d_input, d_fill_str, offset});
auto [offsets_column, total_bytes] =
cudf::detail::make_offsets_child_column(sizes_itr, sizes_itr + input.size(), stream, mr);
auto offsets_view = offsets_column->view();
// compute the shift-offset for the output characters child column
auto const shift_offset = [&] {
auto const index = (offset < 0) ? input.size() + offset : offset;
return (offset < 0 ? -1 : 1) * cudf::detail::get_value<size_type>(offsets_view, index, stream);
}();
// create output chars child column
auto chars_column = create_chars_child_column(static_cast<size_type>(total_bytes), stream, mr);
auto d_chars = mutable_column_device_view::create(chars_column->mutable_view(), stream);
// run kernel to shift all the characters
thrust::transform(rmm::exec_policy(stream),
thrust::counting_iterator<size_type>(0),
thrust::counting_iterator<size_type>(total_bytes),
d_chars->data<char>(),
shift_chars_fn{*d_input, d_fill_str, shift_offset});
// caller sets the null-mask
return make_strings_column(
input.size(), std::move(offsets_column), std::move(chars_column), 0, rmm::device_buffer{});
}
} // namespace cudf::strings::detail
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/copying/copying.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/copy.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/strings/detail/copying.hpp>
#include <cudf/strings/strings_column_view.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
std::unique_ptr<cudf::column> copy_slice(strings_column_view const& strings,
size_type start,
size_type end,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (strings.is_empty()) return make_empty_column(type_id::STRING);
if (end < 0 || end > strings.size()) end = strings.size();
CUDF_EXPECTS(((start >= 0) && (start < end)), "Invalid start parameter value.");
auto const strings_count = end - start;
auto const offsets_offset = start + strings.offset();
// slice the offsets child column
auto offsets_column = std::make_unique<cudf::column>(
cudf::detail::slice(
strings.offsets(), {offsets_offset, offsets_offset + strings_count + 1}, stream)
.front(),
stream,
mr);
auto const chars_offset =
offsets_offset == 0 ? 0 : cudf::detail::get_value<int32_t>(offsets_column->view(), 0, stream);
if (chars_offset > 0) {
// adjust the individual offset values only if needed
auto d_offsets = offsets_column->mutable_view();
thrust::transform(rmm::exec_policy(stream),
d_offsets.begin<int32_t>(),
d_offsets.end<int32_t>(),
d_offsets.begin<int32_t>(),
[chars_offset] __device__(auto offset) { return offset - chars_offset; });
}
// slice the chars child column
auto const data_size =
cudf::detail::get_value<int32_t>(offsets_column->view(), strings_count, stream);
auto chars_column = std::make_unique<cudf::column>(
cudf::detail::slice(strings.chars(), {chars_offset, chars_offset + data_size}, stream).front(),
stream,
mr);
// slice the null mask
auto null_mask = cudf::detail::copy_bitmask(
strings.null_mask(), offsets_offset, offsets_offset + strings_count, stream, mr);
auto null_count = cudf::detail::null_count(
static_cast<bitmask_type const*>(null_mask.data()), 0, strings_count, stream);
return make_strings_column(strings_count,
std::move(offsets_column),
std::move(chars_column),
null_count,
std::move(null_mask));
}
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/search/findall.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <strings/count_matches.hpp>
#include <strings/regex/regex_program_impl.h>
#include <strings/regex/utilities.cuh>
#include <cudf/column/column.hpp>
#include <cudf/column/column_device_view.cuh>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/strings_column_factories.cuh>
#include <cudf/strings/detail/utilities.hpp>
#include <cudf/strings/findall.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/pair.h>
#include <thrust/scan.h>
namespace cudf {
namespace strings {
namespace detail {
using string_index_pair = thrust::pair<char const*, size_type>;
namespace {
/**
* @brief This functor handles extracting matched strings by applying the compiled regex pattern
* and creating string_index_pairs for all the substrings.
*/
struct findall_fn {
column_device_view const d_strings;
size_type const* d_offsets;
string_index_pair* d_indices;
__device__ void operator()(size_type const idx, reprog_device const prog, int32_t const prog_idx)
{
if (d_strings.is_null(idx)) { return; }
auto const d_str = d_strings.element<string_view>(idx);
auto const nchars = d_str.length();
auto d_output = d_indices + d_offsets[idx];
size_type output_idx = 0;
auto itr = d_str.begin();
while (itr.position() < nchars) {
auto const match = prog.find(prog_idx, d_str, itr);
if (!match) { break; }
auto const d_result = string_from_match(*match, d_str, itr);
d_output[output_idx++] = string_index_pair{d_result.data(), d_result.size_bytes()};
itr += (match->second - itr.position());
}
}
};
std::unique_ptr<column> findall_util(column_device_view const& d_strings,
reprog_device& d_prog,
size_type total_matches,
size_type const* d_offsets,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
rmm::device_uvector<string_index_pair> indices(total_matches, stream);
launch_for_each_kernel(
findall_fn{d_strings, d_offsets, indices.data()}, d_prog, d_strings.size(), stream);
return make_strings_column(indices.begin(), indices.end(), stream, mr);
}
} // namespace
//
std::unique_ptr<column> findall(strings_column_view const& input,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto const strings_count = input.size();
auto const d_strings = column_device_view::create(input.parent(), stream);
// create device object from regex_program
auto d_prog = regex_device_builder::create_prog_device(prog, stream);
// Create lists offsets column
auto offsets = count_matches(*d_strings, *d_prog, strings_count + 1, stream, mr);
auto d_offsets = offsets->mutable_view().data<size_type>();
// Convert counts into offsets
thrust::exclusive_scan(
rmm::exec_policy(stream), d_offsets, d_offsets + strings_count + 1, d_offsets);
// Create indices vector with the total number of groups that will be extracted
auto const total_matches =
cudf::detail::get_value<size_type>(offsets->view(), strings_count, stream);
auto strings_output = findall_util(*d_strings, *d_prog, total_matches, d_offsets, stream, mr);
// Build the lists column from the offsets and the strings
return make_lists_column(strings_count,
std::move(offsets),
std::move(strings_output),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
stream,
mr);
}
} // namespace detail
// external API
std::unique_ptr<column> findall(strings_column_view const& input,
regex_program const& prog,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::findall(input, prog, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/search/find.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/cuda.cuh>
#include <cudf/scalar/scalar_factories.hpp>
#include <cudf/strings/detail/utilities.hpp>
#include <cudf/strings/find.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/binary_search.h>
#include <thrust/fill.h>
#include <thrust/for_each.h>
#include <thrust/iterator/constant_iterator.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform.h>
#include <cuda/atomic>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Threshold to decide on using string or warp parallel functions.
*
* If the average byte length of a string in a column exceeds this value then
* a warp-parallel function is used.
*
* Note that this value is shared by find, rfind, and contains functions.
*/
constexpr size_type AVG_CHAR_BYTES_THRESHOLD = 64;
/**
* @brief Find function handles a string per thread
*/
template <typename TargetIterator, bool forward = true>
struct finder_fn {
column_device_view const d_strings;
TargetIterator const d_targets;
size_type const start;
size_type const stop;
__device__ size_type operator()(size_type idx) const
{
if (d_strings.is_null(idx)) { return -1; }
auto const d_str = d_strings.element<string_view>(idx);
if (d_str.empty() && (start > 0)) { return -1; }
auto const d_target = d_targets[idx];
auto const length = d_str.length();
auto const begin = (start > length) ? length : start;
auto const end = (stop < 0) || (stop > length) ? length : stop;
return forward ? d_str.find(d_target, begin, end - begin)
: d_str.rfind(d_target, begin, end - begin);
}
};
/**
* @brief Special logic handles an empty target for find/rfind
*
* where length = number of characters in the input string
* if forward = true:
* return start iff (start <= length), otherwise return -1
* if forward = false:
* return stop iff (0 <= stop <= length), otherwise return length
*/
template <bool forward = true>
struct empty_target_fn {
column_device_view const d_strings;
size_type const start;
size_type const stop;
__device__ size_type operator()(size_type idx) const
{
if (d_strings.is_null(idx)) { return -1; }
auto d_str = d_strings.element<string_view>(idx);
// common case shortcut
if (forward && start == 0) { return 0; }
auto const length = d_str.length();
if (start > length) { return -1; }
if constexpr (forward) { return start; }
return (stop < 0) || (stop > length) ? length : stop;
}
};
/**
* @brief String per warp function for find/rfind
*/
template <typename TargetIterator, bool forward = true>
__global__ void finder_warp_parallel_fn(column_device_view const d_strings,
TargetIterator const d_targets,
size_type const start,
size_type const stop,
size_type* d_results)
{
size_type const idx = static_cast<size_type>(threadIdx.x + blockIdx.x * blockDim.x);
if (idx >= (d_strings.size() * cudf::detail::warp_size)) { return; }
auto const str_idx = idx / cudf::detail::warp_size;
auto const lane_idx = idx % cudf::detail::warp_size;
if (d_strings.is_null(str_idx)) { return; }
// initialize the output for the atomicMin/Max
if (lane_idx == 0) { d_results[str_idx] = forward ? std::numeric_limits<size_type>::max() : -1; }
__syncwarp();
auto const d_str = d_strings.element<string_view>(str_idx);
auto const d_target = d_targets[str_idx];
auto const [begin, left_over] = bytes_to_character_position(d_str, start);
auto const start_char_pos = start - left_over; // keep track of character position
auto const end = [d_str, start, stop, begin = begin] {
if (stop < 0) { return d_str.size_bytes(); }
if (stop <= start) { return begin; }
// we count from `begin` instead of recounting from the beginning of the string
return begin + std::get<0>(bytes_to_character_position(
string_view(d_str.data() + begin, d_str.size_bytes() - begin), stop - start));
}();
// each thread compares the target with the thread's individual starting byte
size_type position = forward ? std::numeric_limits<size_type>::max() : -1;
for (auto itr = begin + lane_idx; itr + d_target.size_bytes() <= end;
itr += cudf::detail::warp_size) {
if (d_target.compare(d_str.data() + itr, d_target.size_bytes()) == 0) {
position = itr;
if (forward) break;
}
}
// find stores the minimum position while rfind stores the maximum position
// note that this was slightly faster than using cub::WarpReduce
cuda::atomic_ref<size_type, cuda::thread_scope_block> ref{*(d_results + str_idx)};
forward ? ref.fetch_min(position, cuda::std::memory_order_relaxed)
: ref.fetch_max(position, cuda::std::memory_order_relaxed);
__syncwarp();
if (lane_idx == 0) {
// the final result needs to be fixed up convert max() to -1
// and a byte position to a character position
auto const result = d_results[str_idx];
d_results[str_idx] =
((result < std::numeric_limits<size_type>::max()) && (result >= begin))
? start_char_pos + characters_in_string(d_str.data() + begin, result - begin)
: -1;
}
}
template <typename TargetIterator, bool forward = true>
void find_utility(strings_column_view const& input,
TargetIterator const& target_itr,
column& output,
size_type start,
size_type stop,
rmm::cuda_stream_view stream)
{
auto d_strings = column_device_view::create(input.parent(), stream);
auto d_results = output.mutable_view().data<size_type>();
if ((input.chars_size() / (input.size() - input.null_count())) > AVG_CHAR_BYTES_THRESHOLD) {
// warp-per-string runs faster for longer strings (but not shorter ones)
constexpr int block_size = 256;
cudf::detail::grid_1d grid{input.size() * cudf::detail::warp_size, block_size};
finder_warp_parallel_fn<TargetIterator, forward>
<<<grid.num_blocks, grid.num_threads_per_block, 0, stream.value()>>>(
*d_strings, target_itr, start, stop, d_results);
} else {
// string-per-thread function
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(input.size()),
d_results,
finder_fn<TargetIterator, forward>{*d_strings, target_itr, start, stop});
}
}
template <bool forward = true>
std::unique_ptr<column> find_fn(strings_column_view const& input,
string_scalar const& target,
size_type start,
size_type stop,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(target.is_valid(stream), "Parameter target must be valid.");
CUDF_EXPECTS(start >= 0, "Parameter start must be positive integer or zero.");
if ((stop > 0) && (start > stop)) CUDF_FAIL("Parameter start must be less than stop.");
// create output column
auto results = make_numeric_column(data_type{type_to_id<size_type>()},
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
// if input is empty or all-null then we are done
if (input.size() == input.null_count()) { return results; }
auto d_target = string_view(target.data(), target.size());
// special logic for empty target results
if (d_target.empty()) {
auto d_strings = column_device_view::create(input.parent(), stream);
auto d_results = results->mutable_view().data<size_type>();
thrust::transform(rmm::exec_policy(stream),
thrust::counting_iterator<size_type>(0),
thrust::counting_iterator<size_type>(input.size()),
d_results,
empty_target_fn<forward>{*d_strings, start, stop});
return results;
}
// find-utility function fills in the results column
auto target_itr = thrust::make_constant_iterator(d_target);
using TargetIterator = decltype(target_itr);
find_utility<TargetIterator, forward>(input, target_itr, *results, start, stop, stream);
results->set_null_count(input.null_count());
return results;
}
} // namespace
std::unique_ptr<column> find(strings_column_view const& input,
string_scalar const& target,
size_type start,
size_type stop,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return find_fn<true>(input, target, start, stop, stream, mr);
}
std::unique_ptr<column> rfind(strings_column_view const& input,
string_scalar const& target,
size_type start,
size_type stop,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return find_fn<false>(input, target, start, stop, stream, mr);
}
template <bool forward = true>
std::unique_ptr<column> find(strings_column_view const& input,
strings_column_view const& target,
size_type start,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(start >= 0, "Parameter start must be positive integer or zero.");
CUDF_EXPECTS(input.size() == target.size(), "input and target columns must be the same size");
// create output column
auto results = make_numeric_column(
data_type{type_to_id<size_type>()}, input.size(), rmm::device_buffer{}, 0, stream, mr);
// if input is empty or all-null then we are done
if (input.size() == input.null_count()) { return results; }
// call find utility with target iterator
auto d_targets = column_device_view::create(target.parent(), stream);
auto target_itr = cudf::detail::make_null_replacement_iterator<string_view>(
*d_targets, string_view{}, target.has_nulls());
find_utility<decltype(target_itr), forward>(input, target_itr, *results, start, -1, stream);
// AND the bitmasks from input and target
auto [null_mask, null_count] =
cudf::detail::bitmask_and(table_view({input.parent(), target.parent()}), stream, mr);
results->set_null_mask(std::move(null_mask), null_count);
return results;
}
} // namespace detail
// external APIs
std::unique_ptr<column> find(strings_column_view const& strings,
string_scalar const& target,
size_type start,
size_type stop,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::find(strings, target, start, stop, stream, mr);
}
std::unique_ptr<column> rfind(strings_column_view const& strings,
string_scalar const& target,
size_type start,
size_type stop,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::rfind(strings, target, start, stop, stream, mr);
}
std::unique_ptr<column> find(strings_column_view const& input,
strings_column_view const& target,
size_type start,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::find<true>(input, target, start, stream, mr);
}
namespace detail {
namespace {
/**
* @brief Check if `d_target` appears in a row in `d_strings`.
*
* This executes as a warp per string/row and performs well for longer strings.
* @see AVG_CHAR_BYTES_THRESHOLD
*
* @param d_strings Column of input strings
* @param d_target String to search for in each row of `d_strings`
* @param d_results Indicates which rows contain `d_target`
*/
__global__ void contains_warp_parallel_fn(column_device_view const d_strings,
string_view const d_target,
bool* d_results)
{
size_type const idx = static_cast<size_type>(threadIdx.x + blockIdx.x * blockDim.x);
using warp_reduce = cub::WarpReduce<bool>;
__shared__ typename warp_reduce::TempStorage temp_storage;
if (idx >= (d_strings.size() * cudf::detail::warp_size)) { return; }
auto const str_idx = idx / cudf::detail::warp_size;
auto const lane_idx = idx % cudf::detail::warp_size;
if (d_strings.is_null(str_idx)) { return; }
// get the string for this warp
auto const d_str = d_strings.element<string_view>(str_idx);
// each thread of the warp will check just part of the string
auto found = false;
for (auto i = static_cast<size_type>(idx % cudf::detail::warp_size);
!found && (i + d_target.size_bytes()) < d_str.size_bytes();
i += cudf::detail::warp_size) {
// check the target matches this part of the d_str data
if (d_target.compare(d_str.data() + i, d_target.size_bytes()) == 0) { found = true; }
}
auto const result = warp_reduce(temp_storage).Reduce(found, cub::Max());
if (lane_idx == 0) { d_results[str_idx] = result; }
}
std::unique_ptr<column> contains_warp_parallel(strings_column_view const& input,
string_scalar const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(target.is_valid(stream), "Parameter target must be valid.");
auto d_target = string_view(target.data(), target.size());
// create output column
auto results = make_numeric_column(data_type{type_id::BOOL8},
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
// fill the output with `false` unless the `d_target` is empty
auto results_view = results->mutable_view();
thrust::fill(rmm::exec_policy(stream),
results_view.begin<bool>(),
results_view.end<bool>(),
d_target.empty());
if (!d_target.empty()) {
// launch warp per string
auto const d_strings = column_device_view::create(input.parent(), stream);
constexpr int block_size = 256;
cudf::detail::grid_1d grid{input.size() * cudf::detail::warp_size, block_size};
contains_warp_parallel_fn<<<grid.num_blocks, grid.num_threads_per_block, 0, stream.value()>>>(
*d_strings, d_target, results_view.data<bool>());
}
results->set_null_count(input.null_count());
return results;
}
/**
* @brief Utility to return a bool column indicating the presence of
* a given target string in a strings column.
*
* Null string entries return corresponding null output column entries.
*
* @tparam BoolFunction Return bool value given two strings.
*
* @param strings Column of strings to check for target.
* @param target UTF-8 encoded string to check in strings column.
* @param pfn Returns bool value if target is found in the given string.
* @param stream CUDA stream used for device memory operations and kernel launches.
* @param mr Device memory resource used to allocate the returned column's device memory.
* @return New BOOL column.
*/
template <typename BoolFunction>
std::unique_ptr<column> contains_fn(strings_column_view const& strings,
string_scalar const& target,
BoolFunction pfn,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto strings_count = strings.size();
if (strings_count == 0) return make_empty_column(type_id::BOOL8);
CUDF_EXPECTS(target.is_valid(stream), "Parameter target must be valid.");
if (target.size() == 0) // empty target string returns true
{
auto const true_scalar = make_fixed_width_scalar<bool>(true, stream);
auto results = make_column_from_scalar(*true_scalar, strings.size(), stream, mr);
results->set_null_mask(cudf::detail::copy_bitmask(strings.parent(), stream, mr),
strings.null_count());
return results;
}
auto d_target = string_view(target.data(), target.size());
auto strings_column = column_device_view::create(strings.parent(), stream);
auto d_strings = *strings_column;
// create output column
auto results = make_numeric_column(data_type{type_id::BOOL8},
strings_count,
cudf::detail::copy_bitmask(strings.parent(), stream, mr),
strings.null_count(),
stream,
mr);
auto results_view = results->mutable_view();
auto d_results = results_view.data<bool>();
// set the bool values by evaluating the passed function
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_count),
d_results,
[d_strings, pfn, d_target] __device__(size_type idx) {
if (!d_strings.is_null(idx))
return bool{pfn(d_strings.element<string_view>(idx), d_target)};
return false;
});
results->set_null_count(strings.null_count());
return results;
}
/**
* @brief Utility to return a bool column indicating the presence of
* a string targets[i] in strings[i].
*
* Null string entries return corresponding null output column entries.
*
* @tparam BoolFunction Return bool value given two strings.
*
* @param strings Column of strings to check for `targets[i]`.
* @param targets Column of strings to be checked in `strings[i]``.
* @param pfn Returns bool value if target is found in the given string.
* @param stream CUDA stream used for device memory operations and kernel launches.
* @param mr Device memory resource used to allocate the returned column's device memory.
* @return New BOOL column.
*/
template <typename BoolFunction>
std::unique_ptr<column> contains_fn(strings_column_view const& strings,
strings_column_view const& targets,
BoolFunction pfn,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (strings.is_empty()) return make_empty_column(type_id::BOOL8);
CUDF_EXPECTS(targets.size() == strings.size(),
"strings and targets column must be the same size");
auto targets_column = column_device_view::create(targets.parent(), stream);
auto d_targets = *targets_column;
auto strings_column = column_device_view::create(strings.parent(), stream);
auto d_strings = *strings_column;
// create output column
auto results = make_numeric_column(data_type{type_id::BOOL8},
strings.size(),
cudf::detail::copy_bitmask(strings.parent(), stream, mr),
strings.null_count(),
stream,
mr);
auto results_view = results->mutable_view();
auto d_results = results_view.data<bool>();
// set the bool values by evaluating the passed function
thrust::transform(
rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings.size()),
d_results,
[d_strings, pfn, d_targets] __device__(size_type idx) {
// empty target string returns true
if (d_targets.is_valid(idx) && d_targets.element<string_view>(idx).length() == 0) {
return true;
} else if (!d_strings.is_null(idx) && !d_targets.is_null(idx)) {
return bool{pfn(d_strings.element<string_view>(idx), d_targets.element<string_view>(idx))};
} else {
return false;
}
});
results->set_null_count(strings.null_count());
return results;
}
} // namespace
std::unique_ptr<column> contains(strings_column_view const& input,
string_scalar const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// use warp parallel when the average string width is greater than the threshold
if ((input.null_count() < input.size()) &&
((input.chars_size() / input.size()) > AVG_CHAR_BYTES_THRESHOLD)) {
return contains_warp_parallel(input, target, stream, mr);
}
// benchmark measurements showed this to be faster for smaller strings
auto pfn = [] __device__(string_view d_string, string_view d_target) {
return d_string.find(d_target) != string_view::npos;
};
return contains_fn(input, target, pfn, stream, mr);
}
std::unique_ptr<column> contains(strings_column_view const& strings,
strings_column_view const& targets,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto pfn = [] __device__(string_view d_string, string_view d_target) {
return d_string.find(d_target) != string_view::npos;
};
return contains_fn(strings, targets, pfn, stream, mr);
}
std::unique_ptr<column> starts_with(strings_column_view const& strings,
string_scalar const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto pfn = [] __device__(string_view d_string, string_view d_target) {
return (d_target.size_bytes() <= d_string.size_bytes()) &&
(d_target.compare(d_string.data(), d_target.size_bytes()) == 0);
};
return contains_fn(strings, target, pfn, stream, mr);
}
std::unique_ptr<column> starts_with(strings_column_view const& strings,
strings_column_view const& targets,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto pfn = [] __device__(string_view d_string, string_view d_target) {
return (d_target.size_bytes() <= d_string.size_bytes()) &&
(d_target.compare(d_string.data(), d_target.size_bytes()) == 0);
};
return contains_fn(strings, targets, pfn, stream, mr);
}
std::unique_ptr<column> ends_with(strings_column_view const& strings,
string_scalar const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto pfn = [] __device__(string_view d_string, string_view d_target) {
auto const str_size = d_string.size_bytes();
auto const tgt_size = d_target.size_bytes();
return (tgt_size <= str_size) &&
(d_target.compare(d_string.data() + str_size - tgt_size, tgt_size) == 0);
};
return contains_fn(strings, target, pfn, stream, mr);
}
std::unique_ptr<column> ends_with(strings_column_view const& strings,
strings_column_view const& targets,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto pfn = [] __device__(string_view d_string, string_view d_target) {
auto const str_size = d_string.size_bytes();
auto const tgt_size = d_target.size_bytes();
return (tgt_size <= str_size) &&
(d_target.compare(d_string.data() + str_size - tgt_size, tgt_size) == 0);
};
return contains_fn(strings, targets, pfn, stream, mr);
}
} // namespace detail
// external APIs
std::unique_ptr<column> contains(strings_column_view const& strings,
string_scalar const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::contains(strings, target, stream, mr);
}
std::unique_ptr<column> contains(strings_column_view const& strings,
strings_column_view const& targets,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::contains(strings, targets, stream, mr);
}
std::unique_ptr<column> starts_with(strings_column_view const& strings,
string_scalar const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::starts_with(strings, target, stream, mr);
}
std::unique_ptr<column> starts_with(strings_column_view const& strings,
strings_column_view const& targets,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::starts_with(strings, targets, stream, mr);
}
std::unique_ptr<column> ends_with(strings_column_view const& strings,
string_scalar const& target,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::ends_with(strings, target, stream, mr);
}
std::unique_ptr<column> ends_with(strings_column_view const& strings,
strings_column_view const& targets,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::ends_with(strings, targets, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/search/find_multiple.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/sequence.hpp>
#include <cudf/scalar/scalar.hpp>
#include <cudf/strings/find_multiple.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
std::unique_ptr<column> find_multiple(strings_column_view const& input,
strings_column_view const& targets,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto const strings_count = input.size();
auto const targets_count = targets.size();
CUDF_EXPECTS(targets_count > 0, "Must include at least one search target");
CUDF_EXPECTS(!targets.has_nulls(), "Search targets cannot contain null strings");
auto strings_column = column_device_view::create(input.parent(), stream);
auto d_strings = *strings_column;
auto targets_column = column_device_view::create(targets.parent(), stream);
auto d_targets = *targets_column;
auto const total_count = strings_count * targets_count;
// create output column
auto results = make_numeric_column(
data_type{type_id::INT32}, total_count, rmm::device_buffer{0, stream, mr}, 0, stream, mr);
// fill output column with position values
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(total_count),
results->mutable_view().begin<int32_t>(),
[d_strings, d_targets, targets_count] __device__(size_type idx) {
size_type str_idx = idx / targets_count;
if (d_strings.is_null(str_idx)) return -1;
string_view d_str = d_strings.element<string_view>(str_idx);
string_view d_tgt = d_targets.element<string_view>(idx % targets_count);
return d_str.find(d_tgt);
});
results->set_null_count(0);
auto offsets = cudf::detail::sequence(strings_count + 1,
numeric_scalar<size_type>(0, true, stream),
numeric_scalar<size_type>(targets_count, true, stream),
stream,
mr);
return make_lists_column(strings_count,
std::move(offsets),
std::move(results),
0,
rmm::device_buffer{0, stream, mr},
stream,
mr);
}
} // namespace detail
// external API
std::unique_ptr<column> find_multiple(strings_column_view const& input,
strings_column_view const& targets,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::find_multiple(input, targets, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/regex/regexec.cpp
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <strings/regex/regcomp.h>
#include <strings/regex/regex.cuh>
#include <cudf/detail/utilities/integer_utils.hpp>
#include <cudf/strings/detail/char_tables.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_buffer.hpp>
#include <algorithm>
#include <functional>
#include <numeric>
namespace cudf {
namespace strings {
namespace detail {
// Copy reprog primitive values
reprog_device::reprog_device(reprog const& prog)
: _startinst_id{prog.get_start_inst()},
_num_capturing_groups{prog.groups_count()},
_insts_count{prog.insts_count()},
_starts_count{prog.starts_count()},
_classes_count{prog.classes_count()},
_max_insts{prog.insts_count()},
_codepoint_flags{get_character_flags_table()}
{
}
std::unique_ptr<reprog_device, std::function<void(reprog_device*)>> reprog_device::create(
reprog const& h_prog, rmm::cuda_stream_view stream)
{
// compute size to hold all the member data
auto const insts_count = h_prog.insts_count();
auto const classes_count = h_prog.classes_count();
auto const starts_count = h_prog.starts_count();
// compute size of each section
auto insts_size = insts_count * sizeof(_insts[0]);
auto startids_size = starts_count * sizeof(_startinst_ids[0]);
auto classes_size = std::transform_reduce(
h_prog.classes_data(),
h_prog.classes_data() + h_prog.classes_count(),
classes_count * sizeof(_classes[0]),
std::plus<std::size_t>{},
[&h_prog](auto& cls) { return cls.literals.size() * sizeof(reclass_range); });
// make sure each section is aligned for the subsequent section's data type
auto const memsize = cudf::util::round_up_safe(insts_size, sizeof(_startinst_ids[0])) +
cudf::util::round_up_safe(startids_size, sizeof(_classes[0])) +
cudf::util::round_up_safe(classes_size, sizeof(char32_t));
// allocate memory to store all the prog data in a flat contiguous buffer
std::vector<u_char> h_buffer(memsize); // copy everything into here;
auto h_ptr = h_buffer.data(); // this is our running host ptr;
auto d_buffer = new rmm::device_buffer(memsize, stream); // output device memory;
auto d_ptr = reinterpret_cast<u_char*>(d_buffer->data()); // running device pointer
// create our device object; this is managed separately and returned to the caller
reprog_device* d_prog = new reprog_device(h_prog);
// copy the instructions array first (fixed-sized structs)
memcpy(h_ptr, h_prog.insts_data(), insts_size);
d_prog->_insts = reinterpret_cast<reinst*>(d_ptr);
// point to the end for the next section
insts_size = cudf::util::round_up_safe(insts_size, sizeof(_startinst_ids[0]));
h_ptr += insts_size;
d_ptr += insts_size;
// copy the startinst_ids next
memcpy(h_ptr, h_prog.starts_data(), startids_size);
d_prog->_startinst_ids = reinterpret_cast<int32_t*>(d_ptr);
// next section; align the size for next data type
startids_size = cudf::util::round_up_safe(startids_size, sizeof(_classes[0]));
h_ptr += startids_size;
d_ptr += startids_size;
// copy classes into flat memory: [class1,class2,...][char32 arrays]
auto classes = reinterpret_cast<reclass_device*>(h_ptr);
d_prog->_classes = reinterpret_cast<reclass_device*>(d_ptr);
// get pointer to the end to handle variable length data
auto h_end = h_ptr + (classes_count * sizeof(reclass_device));
auto d_end = d_ptr + (classes_count * sizeof(reclass_device));
// place each class and append the variable length data
for (int32_t idx = 0; idx < classes_count; ++idx) {
auto const& h_class = h_prog.class_at(idx);
reclass_device d_class{h_class.builtins,
static_cast<int32_t>(h_class.literals.size()),
reinterpret_cast<reclass_range*>(d_end)};
*classes++ = d_class;
memcpy(h_end, h_class.literals.data(), h_class.literals.size() * sizeof(reclass_range));
h_end += h_class.literals.size() * sizeof(reclass_range);
d_end += h_class.literals.size() * sizeof(reclass_range);
}
// initialize the rest of the elements
d_prog->_max_insts = insts_count;
d_prog->_prog_size = memsize + sizeof(reprog_device);
// copy flat prog to device memory
CUDF_CUDA_TRY(
cudaMemcpyAsync(d_buffer->data(), h_buffer.data(), memsize, cudaMemcpyDefault, stream.value()));
// build deleter to cleanup device memory
auto deleter = [d_buffer](reprog_device* t) {
t->destroy();
delete d_buffer;
};
return std::unique_ptr<reprog_device, std::function<void(reprog_device*)>>(d_prog, deleter);
}
void reprog_device::destroy() { delete this; }
std::size_t reprog_device::working_memory_size(int32_t num_threads) const
{
return compute_working_memory_size(num_threads, insts_counts());
}
std::pair<std::size_t, int32_t> reprog_device::compute_strided_working_memory(
int32_t rows, int32_t min_rows, std::size_t requested_max_size) const
{
auto thread_count = rows;
auto buffer_size = working_memory_size(thread_count);
while ((buffer_size > requested_max_size) && (thread_count > min_rows)) {
thread_count = thread_count / 2;
buffer_size = working_memory_size(thread_count);
}
// clamp to min_rows but only if rows is greater than min_rows
if (rows > min_rows && thread_count < min_rows) {
thread_count = min_rows;
buffer_size = working_memory_size(thread_count);
}
return std::make_pair(buffer_size, thread_count);
}
void reprog_device::set_working_memory(void* buffer, int32_t thread_count, int32_t max_insts)
{
_buffer = buffer;
_thread_count = thread_count;
_max_insts = _max_insts > 0 ? _max_insts : _insts_count;
}
int32_t reprog_device::compute_shared_memory_size() const
{
return _prog_size < MAX_SHARED_MEM ? static_cast<int32_t>(_prog_size) : 0;
}
std::size_t compute_working_memory_size(int32_t num_threads, int32_t insts_count)
{
return relist::alloc_size(insts_count, num_threads) * 2;
}
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/regex/utilities.cuh
|
/*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <strings/regex/regex.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/sizes_to_offsets_iterator.cuh>
#include <cudf/detail/utilities/cuda.cuh>
#include <cudf/strings/detail/utilities.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/scan.h>
#include <stdexcept>
namespace cudf {
namespace strings {
namespace detail {
constexpr auto regex_launch_kernel_block_size = 256;
template <typename ForEachFunction>
__global__ void for_each_kernel(ForEachFunction fn, reprog_device const d_prog, size_type size)
{
extern __shared__ u_char shmem[];
if (threadIdx.x == 0) { d_prog.store(shmem); }
__syncthreads();
auto const s_prog = reprog_device::load(d_prog, shmem);
auto const thread_idx = threadIdx.x + blockIdx.x * blockDim.x;
auto const stride = s_prog.thread_count();
if (thread_idx < stride) {
for (auto idx = thread_idx; idx < size; idx += stride) {
fn(idx, s_prog, thread_idx);
}
}
}
template <typename ForEachFunction>
void launch_for_each_kernel(ForEachFunction fn,
reprog_device& d_prog,
size_type size,
rmm::cuda_stream_view stream)
{
auto [buffer_size, thread_count] = d_prog.compute_strided_working_memory(size);
auto d_buffer = rmm::device_buffer(buffer_size, stream);
d_prog.set_working_memory(d_buffer.data(), thread_count);
auto const shmem_size = d_prog.compute_shared_memory_size();
cudf::detail::grid_1d grid{thread_count, regex_launch_kernel_block_size};
for_each_kernel<<<grid.num_blocks, grid.num_threads_per_block, shmem_size, stream.value()>>>(
fn, d_prog, size);
}
template <typename TransformFunction, typename OutputType>
__global__ void transform_kernel(TransformFunction fn,
reprog_device const d_prog,
OutputType* d_output,
size_type size)
{
extern __shared__ u_char shmem[];
if (threadIdx.x == 0) { d_prog.store(shmem); }
__syncthreads();
auto const s_prog = reprog_device::load(d_prog, shmem);
auto const thread_idx = threadIdx.x + blockIdx.x * blockDim.x;
auto const stride = s_prog.thread_count();
if (thread_idx < stride) {
for (auto idx = thread_idx; idx < size; idx += stride) {
d_output[idx] = fn(idx, s_prog, thread_idx);
}
}
}
template <typename TransformFunction, typename OutputType>
void launch_transform_kernel(TransformFunction fn,
reprog_device& d_prog,
OutputType* d_output,
size_type size,
rmm::cuda_stream_view stream)
{
auto [buffer_size, thread_count] = d_prog.compute_strided_working_memory(size);
auto d_buffer = rmm::device_buffer(buffer_size, stream);
d_prog.set_working_memory(d_buffer.data(), thread_count);
auto const shmem_size = d_prog.compute_shared_memory_size();
cudf::detail::grid_1d grid{thread_count, regex_launch_kernel_block_size};
transform_kernel<<<grid.num_blocks, grid.num_threads_per_block, shmem_size, stream.value()>>>(
fn, d_prog, d_output, size);
}
template <typename SizeAndExecuteFunction>
auto make_strings_children(SizeAndExecuteFunction size_and_exec_fn,
reprog_device& d_prog,
size_type strings_count,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto offsets = make_numeric_column(
data_type{type_id::INT32}, strings_count + 1, mask_state::UNALLOCATED, stream, mr);
auto d_offsets = offsets->mutable_view().template data<int32_t>();
size_and_exec_fn.d_offsets = d_offsets;
auto [buffer_size, thread_count] = d_prog.compute_strided_working_memory(strings_count);
auto d_buffer = rmm::device_buffer(buffer_size, stream);
d_prog.set_working_memory(d_buffer.data(), thread_count);
auto const shmem_size = d_prog.compute_shared_memory_size();
cudf::detail::grid_1d grid{thread_count, 256};
// Compute the output size for each row
if (strings_count > 0) {
for_each_kernel<<<grid.num_blocks, grid.num_threads_per_block, shmem_size, stream.value()>>>(
size_and_exec_fn, d_prog, strings_count);
}
auto const char_bytes =
cudf::detail::sizes_to_offsets(d_offsets, d_offsets + strings_count + 1, d_offsets, stream);
CUDF_EXPECTS(char_bytes <= std::numeric_limits<size_type>::max(),
"Size of output exceeds the column size limit",
std::overflow_error);
// Now build the chars column
std::unique_ptr<column> chars =
create_chars_child_column(static_cast<size_type>(char_bytes), stream, mr);
if (char_bytes > 0) {
size_and_exec_fn.d_chars = chars->mutable_view().template data<char>();
for_each_kernel<<<grid.num_blocks, grid.num_threads_per_block, shmem_size, stream.value()>>>(
size_and_exec_fn, d_prog, strings_count);
}
return std::make_pair(std::move(offsets), std::move(chars));
}
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/regex/regcomp.cpp
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <strings/regex/regcomp.h>
#include <cudf/strings/detail/utf8.hpp>
#include <cudf/utilities/error.hpp>
#include <thrust/iterator/counting_iterator.h>
#include <algorithm>
#include <array>
#include <cctype>
#include <numeric>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
namespace cudf {
namespace strings {
namespace detail {
namespace {
// Bitmask of all operators
#define OPERATOR_MASK 0200
enum OperatorType : int32_t {
START = 0200, // Start, used for marker on stack
LBRA_NC = 0203, // non-capturing group
CAT = 0205, // Concatenation, implicit operator
STAR = 0206, // Closure, *
STAR_LAZY = 0207,
PLUS = 0210, // a+ == aa*
PLUS_LAZY = 0211,
QUEST = 0212, // a? == a|nothing, i.e. 0 or 1 a's
QUEST_LAZY = 0213,
COUNTED = 0214, // counted repeat a{2} a{3,5}
COUNTED_LAZY = 0215,
NOP = 0302, // No operation, internal use only
};
#define ITEM_MASK 0300
static reclass cclass_w(CCLASS_W); // \w
static reclass cclass_s(CCLASS_S); // \s
static reclass cclass_d(CCLASS_D); // \d
static reclass cclass_W(NCCLASS_W); // \W
static reclass cclass_S(NCCLASS_S); // \S
static reclass cclass_D(NCCLASS_D); // \D
// Tables for analyzing quantifiers
std::array<int, 5> const valid_preceding_inst_types{{CHAR, CCLASS, NCCLASS, ANY, ANYNL}};
std::array<char, 5> const quantifiers{{'*', '?', '+', '{', '|'}};
// Valid regex characters that can be escaped and used as literals
std::array<char, 33> const escapable_chars{
{'.', '-', '+', '*', '\\', '?', '^', '$', '|', '{', '}', '(', ')', '[', ']', '<', '>',
'"', '~', '\'', '`', '_', '@', '=', ';', ':', '!', '#', '%', '&', ',', '/', ' '}};
/**
* @brief Converts UTF-8 string into fixed-width 32-bit character vector.
*
* No character conversion occurs.
* Each UTF-8 character is promoted into a 32-bit value.
* The last entry in the returned vector will be a 0 value.
* The fixed-width vector makes it easier to compile and faster to execute.
*
* @param pattern Regular expression encoded with UTF-8.
* @return Fixed-width 32-bit character vector.
*/
std::vector<char32_t> string_to_char32_vector(std::string_view pattern)
{
size_type size = static_cast<size_type>(pattern.size());
size_type count = std::count_if(pattern.cbegin(), pattern.cend(), [](char ch) {
return is_begin_utf8_char(static_cast<uint8_t>(ch));
});
std::vector<char32_t> result(count + 1);
char32_t* output_ptr = result.data();
char const* input_ptr = pattern.data();
for (size_type idx = 0; idx < size; ++idx) {
char_utf8 output_character = 0;
size_type ch_width = to_char_utf8(input_ptr, output_character);
input_ptr += ch_width;
idx += ch_width - 1;
*output_ptr++ = output_character;
}
result[count] = 0; // last entry set to 0
return result;
}
} // namespace
int32_t reprog::add_inst(int32_t t)
{
reinst inst;
inst.type = t;
inst.u2.left_id = 0;
inst.u1.right_id = 0;
return add_inst(inst);
}
int32_t reprog::add_inst(reinst const& inst)
{
_insts.push_back(inst);
return static_cast<int32_t>(_insts.size() - 1);
}
int32_t reprog::add_class(reclass const& cls)
{
_classes.push_back(cls);
return static_cast<int32_t>(_classes.size() - 1);
}
reinst& reprog::inst_at(int32_t id) { return _insts[id]; }
reclass const& reprog::class_at(int32_t id) const { return _classes[id]; }
void reprog::set_start_inst(int32_t id) { _startinst_id = id; }
int32_t reprog::get_start_inst() const { return _startinst_id; }
int32_t reprog::insts_count() const { return static_cast<int>(_insts.size()); }
int32_t reprog::classes_count() const { return static_cast<int>(_classes.size()); }
void reprog::set_groups_count(int32_t groups) { _num_capturing_groups = groups; }
int32_t reprog::groups_count() const { return _num_capturing_groups; }
reinst const* reprog::insts_data() const { return _insts.data(); }
reclass const* reprog::classes_data() const { return _classes.data(); }
int32_t const* reprog::starts_data() const { return _startinst_ids.data(); }
int32_t reprog::starts_count() const { return static_cast<int>(_startinst_ids.size()); }
static constexpr auto MAX_REGEX_CHAR = std::numeric_limits<char32_t>::max();
/**
* @brief Converts pattern into regex classes
*/
class regex_parser {
public:
/**
* @brief Single parsed pattern element.
*/
struct Item {
int32_t type;
union {
char32_t chr;
int32_t cclass_id;
struct {
int16_t n;
int16_t m;
} count;
} d;
Item(int32_t type, char32_t chr) : type{type}, d{chr} {}
Item(int32_t type, int32_t id) : type{type}, d{.cclass_id{id}} {}
Item(int32_t type, int16_t n, int16_t m) : type{type}, d{.count{n, m}} {}
};
private:
reprog& _prog;
char32_t const* const _pattern_begin;
char32_t const* _expr_ptr;
bool _lex_done{false};
regex_flags const _flags;
capture_groups const _capture;
int32_t _id_cclass_w{-1}; // alphanumeric [a-zA-Z0-9_]
int32_t _id_cclass_W{-1}; // not alphanumeric plus '\n'
int32_t _id_cclass_s{-1}; // whitespace including '\t', '\n', '\r'
int32_t _id_cclass_d{-1}; // digits [0-9]
int32_t _id_cclass_D{-1}; // not digits
char32_t _chr{}; // last lex'd char
int32_t _cclass_id{}; // last lex'd class
int16_t _min_count{}; // data for counted operators
int16_t _max_count{};
std::vector<Item> _items;
bool _has_counted{false};
/**
* @brief Parses octal characters at the current expression position
* to return the represented character
*
* Reads up to 3 octal digits. The first digit should be passed
* in `in_chr`.
*
* @param in_chr The first character of the octal pattern
* @return The resulting character
*/
char32_t handle_octal(char32_t in_chr)
{
auto out_chr = in_chr - '0';
auto c = *_expr_ptr;
auto digits = 1;
while ((c >= '0') && (c <= '7') && (digits < 3)) {
out_chr = (out_chr * 8) | (c - '0');
c = *(++_expr_ptr);
++digits;
}
return out_chr;
}
/**
* @brief Parses 2 hex characters at the current expression position
* to return the represented character
*
* @return The resulting character
*/
char32_t handle_hex()
{
std::string hex(1, static_cast<char>(*_expr_ptr++));
hex.append(1, static_cast<char>(*_expr_ptr++));
return static_cast<char32_t>(std::stol(hex, nullptr, 16)); // 16 = hex
}
/**
* @brief Returns the next character in the expression
*
* Handles quoted (escaped) special characters and detecting the end of the expression.
*
* @return is-backslash-escape and character
*/
std::pair<bool, char32_t> next_char()
{
if (_lex_done) { return {true, 0}; }
auto c = *_expr_ptr++;
if (c == '\\') {
c = *_expr_ptr++;
return {true, c};
}
if (c == 0) { _lex_done = true; }
return {false, c};
}
// for \d and \D
void add_ascii_digit_class(std::vector<reclass_range>& ranges, bool negated = false)
{
if (!negated) {
ranges.push_back({'0', '9'});
} else {
ranges.push_back({0, '0' - 1});
ranges.push_back({'9' + 1, MAX_REGEX_CHAR});
}
}
// for \s and \S
void add_ascii_space_class(std::vector<reclass_range>& ranges, bool negated = false)
{
if (!negated) {
ranges.push_back({'\t', ' '});
} else {
ranges.push_back({0, '\t' - 1});
ranges.push_back({' ' + 1, MAX_REGEX_CHAR});
}
}
// for \w and \W
void add_ascii_word_class(std::vector<reclass_range>& ranges, bool negated = false)
{
add_ascii_digit_class(ranges, negated);
if (!negated) {
ranges.push_back({'a', 'z'});
ranges.push_back({'A', 'Z'});
ranges.push_back({'_', '_'});
} else {
ranges.back().last = 'A' - 1;
ranges.push_back({'Z' + 1, 'a' - 1}); // {'_'-1, '_' + 1}
ranges.push_back({'z' + 1, MAX_REGEX_CHAR});
}
}
int32_t build_cclass()
{
int32_t type = CCLASS;
std::vector<char32_t> literals;
int32_t builtins = 0;
std::vector<reclass_range> ranges;
auto [is_quoted, chr] = next_char();
// check for negation
if (!is_quoted && chr == '^') {
type = NCCLASS;
std::tie(is_quoted, chr) = next_char();
}
// parse class into a set of spans
auto count_char = 0;
while (true) {
count_char++;
if (chr == 0) { return 0; } // malformed '[]'
if (is_quoted) {
switch (chr) {
case 'n': chr = '\n'; break;
case 'r': chr = '\r'; break;
case 't': chr = '\t'; break;
case 'a': chr = 0x07; break;
case 'b': chr = 0x08; break;
case 'f': chr = 0x0C; break;
case '0' ... '7': {
chr = handle_octal(chr);
break;
}
case 'x': {
chr = handle_hex();
break;
}
case 'w':
case 'W':
if (is_ascii(_flags)) {
add_ascii_word_class(ranges, chr == 'W');
} else {
builtins |= (chr == 'w' ? cclass_w.builtins : cclass_W.builtins);
}
std::tie(is_quoted, chr) = next_char();
continue;
case 's':
case 'S':
if (is_ascii(_flags)) {
add_ascii_space_class(ranges, chr == 'S');
} else {
builtins |= (chr == 's' ? cclass_s.builtins : cclass_S.builtins);
}
std::tie(is_quoted, chr) = next_char();
continue;
case 'd':
case 'D':
if (is_ascii(_flags)) {
add_ascii_digit_class(ranges, chr == 'D');
} else {
builtins |= (chr == 'd' ? cclass_d.builtins : cclass_D.builtins);
}
std::tie(is_quoted, chr) = next_char();
continue;
}
}
if (!is_quoted && chr == ']' && count_char > 1) { break; } // done
// A hyphen '-' here signifies a range of characters in a '[]' class definition.
// The logic here also gracefully handles a dangling '-' appearing unquoted
// at the beginning '[-x]' or at the end '[x-]' or by itself '[-]'
// and treats the '-' as a literal value in this cclass in this case.
if (!is_quoted && chr == '-' && !literals.empty()) {
auto [q, n_chr] = next_char();
if (n_chr == 0) { return 0; } // malformed: '[x-'
if (!q && n_chr == ']') { // handles: '[x-]'
literals.push_back(chr);
literals.push_back(chr); // add '-' as literal
break;
}
// normal case: '[a-z]'
// update end-range character
literals.back() = n_chr;
} else {
// add single literal
literals.push_back(chr);
literals.push_back(chr);
}
std::tie(is_quoted, chr) = next_char();
}
// transform pairs of literals to ranges
auto const counter = thrust::make_counting_iterator(0);
std::transform(
counter, counter + (literals.size() / 2), std::back_inserter(ranges), [&literals](auto idx) {
return reclass_range{literals[idx * 2], literals[idx * 2 + 1]};
});
// sort the ranges to help with detecting overlapping entries
std::sort(ranges.begin(), ranges.end(), [](auto l, auto r) {
return l.first == r.first ? l.last < r.last : l.first < r.first;
});
// combine overlapping entries: [a-f][c-g] => [a-g]
if (ranges.size() > 1) {
for (auto itr = ranges.begin() + 1; itr < ranges.end(); ++itr) {
auto const prev = *(itr - 1);
if (itr->first <= prev.last + 1) {
// if these 2 ranges intersect, expand the current one
*itr = reclass_range{prev.first, std::max(prev.last, itr->last)};
}
}
}
// remove any duplicates
auto const end = std::unique(
ranges.rbegin(), ranges.rend(), [](auto l, auto r) { return l.first == r.first; });
ranges.erase(ranges.begin(), ranges.begin() + std::distance(end, ranges.rend()));
_cclass_id = _prog.add_class(reclass{builtins, std::move(ranges)});
return type;
}
int32_t lex(int32_t dot_type)
{
_chr = 0;
auto [is_quoted, chr] = next_char();
if (is_quoted) {
switch (chr) {
case 't': chr = '\t'; break;
case 'n': chr = '\n'; break;
case 'r': chr = '\r'; break;
case 'a': chr = 0x07; break;
case 'f': chr = 0x0C; break;
case '0' ... '7': {
chr = handle_octal(chr);
break;
}
case 'x': {
chr = handle_hex();
break;
}
case 'w': {
if (is_ascii(_flags)) {
reclass cls;
add_ascii_word_class(cls.literals);
_cclass_id = _prog.add_class(cls);
} else {
if (_id_cclass_w < 0) { _id_cclass_w = _prog.add_class(cclass_w); }
_cclass_id = _id_cclass_w;
}
return CCLASS;
}
case 'W': {
if (is_ascii(_flags)) {
reclass cls;
add_ascii_word_class(cls.literals);
_cclass_id = _prog.add_class(cls);
} else {
if (_id_cclass_W < 0) {
reclass cls = cclass_w;
cls.literals.push_back({'\n', '\n'});
_id_cclass_W = _prog.add_class(cls);
}
_cclass_id = _id_cclass_W;
}
return NCCLASS;
}
case 's': {
if (is_ascii(_flags)) {
reclass cls;
add_ascii_space_class(cls.literals);
_cclass_id = _prog.add_class(cls);
} else {
if (_id_cclass_s < 0) { _id_cclass_s = _prog.add_class(cclass_s); }
_cclass_id = _id_cclass_s;
}
return CCLASS;
}
case 'S': {
if (is_ascii(_flags)) {
reclass cls;
add_ascii_space_class(cls.literals);
_cclass_id = _prog.add_class(cls);
} else {
if (_id_cclass_s < 0) { _id_cclass_s = _prog.add_class(cclass_s); }
_cclass_id = _id_cclass_s;
return NCCLASS;
}
}
case 'd': {
if (is_ascii(_flags)) {
reclass cls;
add_ascii_digit_class(cls.literals);
_cclass_id = _prog.add_class(cls);
} else {
if (_id_cclass_d < 0) { _id_cclass_d = _prog.add_class(cclass_d); }
_cclass_id = _id_cclass_d;
}
return CCLASS;
}
case 'D': {
if (is_ascii(_flags)) {
reclass cls;
add_ascii_digit_class(cls.literals);
_cclass_id = _prog.add_class(cls);
} else {
if (_id_cclass_D < 0) {
reclass cls = cclass_d;
cls.literals.push_back({'\n', '\n'});
_id_cclass_D = _prog.add_class(cls);
}
_cclass_id = _id_cclass_D;
}
return NCCLASS;
}
case 'b': return BOW;
case 'B': return NBOW;
case 'A': {
_chr = chr;
return BOL;
}
case 'Z': {
_chr = chr;
return EOL;
}
default: {
// let valid escapable chars fall through as literal CHAR
if (chr &&
(std::find(escapable_chars.begin(), escapable_chars.end(), static_cast<char>(chr)) !=
escapable_chars.end())) {
break;
}
// anything else is a bad escape so throw an error
CUDF_FAIL("invalid regex pattern: bad escape character at position " +
std::to_string(_expr_ptr - _pattern_begin - 1));
}
} // end-switch
_chr = chr;
return CHAR;
}
// handle regex characters
switch (chr) {
case 0: return END;
case '(':
if (*_expr_ptr == '?' && *(_expr_ptr + 1) == ':') // non-capturing group
{
_expr_ptr += 2;
return LBRA_NC;
}
return (_capture == capture_groups::NON_CAPTURE) ? static_cast<int32_t>(LBRA_NC)
: static_cast<int32_t>(LBRA);
case ')': return RBRA;
case '^': {
_chr = is_multiline(_flags) ? chr : '\n';
return BOL;
}
case '$': {
_chr = is_multiline(_flags) ? chr : '\n';
return EOL;
}
case '[': return build_cclass();
case '.': return dot_type;
}
if (std::find(quantifiers.begin(), quantifiers.end(), static_cast<char>(chr)) ==
quantifiers.end()) {
_chr = chr;
return CHAR;
}
// The quantifiers require at least one "real" previous item.
// We are throwing errors for invalid quantifiers.
// Another option is to just return CHAR silently here which effectively
// treats the chr character as a literal instead as a quantifier.
// This could lead to confusion where sometimes unescaped quantifier characters
// are treated as regex expressions and sometimes they are not.
if (_items.empty()) { CUDF_FAIL("invalid regex pattern: nothing to repeat at position 0"); }
// handle alternation instruction
if (chr == '|') return OR;
// Check that the previous item can be used with quantifiers.
// If the previous item is a capture group, we need to check items inside the
// capture group can be used with quantifiers too.
// (Note that capture groups can be nested).
auto previous_type = _items.back().type;
if (previous_type == RBRA) { // previous item is a capture group
// look for matching LBRA
auto nested_count = 1;
auto lbra_itr =
std::find_if(_items.rbegin(), _items.rend(), [nested_count](auto const& item) mutable {
auto const is_closing = (item.type == RBRA);
auto const is_opening = (item.type == LBRA || item.type == LBRA_NC);
nested_count += is_closing - is_opening;
return is_opening && (nested_count == 0);
});
// search for the first valid item within the LBRA-RBRA range
auto first_valid = std::find_first_of(
_items.rbegin() + 1,
lbra_itr,
valid_preceding_inst_types.begin(),
valid_preceding_inst_types.end(),
[](auto const item, auto const valid_type) { return item.type == valid_type; });
// set previous_type to be checked in next if-statement
previous_type = (first_valid == lbra_itr) ? (--lbra_itr)->type : first_valid->type;
}
if (std::find(valid_preceding_inst_types.begin(),
valid_preceding_inst_types.end(),
previous_type) == valid_preceding_inst_types.end()) {
CUDF_FAIL("invalid regex pattern: nothing to repeat at position " +
std::to_string(_expr_ptr - _pattern_begin - 1));
}
// handle quantifiers
switch (chr) {
case '*':
if (*_expr_ptr == '?') {
_expr_ptr++;
return STAR_LAZY;
}
return STAR;
case '?':
if (*_expr_ptr == '?') {
_expr_ptr++;
return QUEST_LAZY;
}
return QUEST;
case '+':
if (*_expr_ptr == '?') {
_expr_ptr++;
return PLUS_LAZY;
}
return PLUS;
case '{': // counted repetition: {n,m}
{
if (!std::isdigit(*_expr_ptr)) { break; }
// transform char32 to char until null, delimiter, non-digit or end is reached;
// returns the number of chars read/transformed
auto transform_until = [](char32_t const* input,
char32_t const* end,
char* output,
std::string_view const delimiters) -> int32_t {
int32_t count = 0;
while (*input != 0 && input < end) {
auto const ch = static_cast<char>(*input++);
// if ch not a digit or ch is a delimiter, we are done
if (!std::isdigit(ch) || delimiters.find(ch) != delimiters.npos) { break; }
output[count] = ch;
++count;
}
output[count] = 0; // null-terminate (for the atoi call)
return count;
};
constexpr auto max_read = 4; // 3 digits plus the delimiter
constexpr auto max_value = 999; // support only 3 digits
std::array<char, max_read + 1> buffer = {0}; //(max_read + 1);
// get left-side (n) value => min_count
auto bytes_read = transform_until(_expr_ptr, _expr_ptr + max_read, buffer.data(), "},");
if (_expr_ptr[bytes_read] != '}' && _expr_ptr[bytes_read] != ',') {
break; // re-interpret as CHAR
}
auto count = std::atoi(buffer.data());
CUDF_EXPECTS(
count <= max_value,
"unsupported repeat value at " + std::to_string(_expr_ptr - _pattern_begin - 1));
_min_count = static_cast<int16_t>(count);
auto const expr_ptr_save = _expr_ptr; // save in case ending '}' is not found
_expr_ptr += bytes_read;
// get optional right-side (m) value => max_count
_max_count = _min_count;
if (*_expr_ptr++ == ',') {
bytes_read = transform_until(_expr_ptr, _expr_ptr + max_read, buffer.data(), "}");
if (_expr_ptr[bytes_read] != '}') {
_expr_ptr = expr_ptr_save; // abort, rollback and
break; // re-interpret as CHAR
}
count = std::atoi(buffer.data());
CUDF_EXPECTS(
count <= max_value,
"unsupported repeat value at " + std::to_string(_expr_ptr - _pattern_begin - 1));
// {n,m} and {n,} are both valid
_max_count = buffer[0] == 0 ? -1 : static_cast<int16_t>(count);
_expr_ptr += bytes_read + 1;
}
// {n,m}? pattern is lazy counted quantifier
if (*_expr_ptr == '?') {
_expr_ptr++;
return COUNTED_LAZY;
}
// otherwise, fixed counted quantifier
return COUNTED;
}
}
_chr = chr;
return CHAR;
}
std::vector<regex_parser::Item> expand_counted_items() const
{
std::vector<regex_parser::Item> const& in = _items;
std::vector<regex_parser::Item> out;
std::stack<int> lbra_stack;
auto repeat_start_index = -1;
for (std::size_t index = 0; index < in.size(); index++) {
auto const item = in[index];
if (item.type != COUNTED && item.type != COUNTED_LAZY) {
out.push_back(item);
if (item.type == LBRA || item.type == LBRA_NC) {
lbra_stack.push(index);
repeat_start_index = -1;
} else if (item.type == RBRA) {
repeat_start_index = lbra_stack.top();
lbra_stack.pop();
} else if ((item.type & ITEM_MASK) != OPERATOR_MASK) {
repeat_start_index = index;
}
} else {
// item is of type COUNTED or COUNTED_LAZY
// here we repeat the previous item(s) based on the count range in item
CUDF_EXPECTS(repeat_start_index >= 0, "regex: invalid counted quantifier location");
// range of affected item(s) to repeat
auto const begin = in.begin() + repeat_start_index;
auto const end = in.begin() + index;
// count range values
auto const n = item.d.count.n; // minimum count
auto const m = item.d.count.m; // maximum count
assert(n >= 0 && "invalid repeat count value n");
// zero-repeat edge-case: need to erase the previous items
if (n == 0) { out.erase(out.end() - (index - repeat_start_index), out.end()); }
// minimum repeats (n)
for (int j = 1; j < n; j++) {
out.insert(out.end(), begin, end);
}
// optional maximum repeats (m)
if (m >= 0) {
for (int j = n; j < m; j++) {
out.push_back(regex_parser::Item{LBRA_NC, 0});
out.insert(out.end(), begin, end);
}
for (int j = n; j < m; j++) {
out.push_back(regex_parser::Item{RBRA, 0});
out.push_back(regex_parser::Item{item.type == COUNTED ? QUEST : QUEST_LAZY, 0});
}
} else {
// infinite repeats
if (n > 0) { // append '+' after last repetition
out.push_back(regex_parser::Item{item.type == COUNTED ? PLUS : PLUS_LAZY, 0});
} else { // copy it once then append '*'
out.insert(out.end(), begin, end);
out.push_back(regex_parser::Item{item.type == COUNTED ? STAR : STAR_LAZY, 0});
}
}
}
}
return out;
}
public:
regex_parser(char32_t const* pattern,
regex_flags const flags,
capture_groups const capture,
reprog& prog)
: _prog(prog), _pattern_begin(pattern), _expr_ptr(pattern), _flags(flags), _capture(capture)
{
auto const dot_type = is_dotall(_flags) ? ANYNL : ANY;
int32_t type = 0;
while ((type = lex(dot_type)) != END) {
auto const item = [type, chr = _chr, cid = _cclass_id, n = _min_count, m = _max_count] {
if (type == CCLASS || type == NCCLASS) return Item{type, cid};
if (type == COUNTED || type == COUNTED_LAZY) return Item{type, n, m};
return Item{type, chr};
}();
_items.push_back(item);
if (type == COUNTED || type == COUNTED_LAZY) _has_counted = true;
}
}
std::vector<regex_parser::Item> get_items() const
{
return _has_counted ? expand_counted_items() : _items;
}
};
/**
* @brief The compiler converts class list into instructions.
*/
class regex_compiler {
struct and_node {
int id_first;
int id_last;
};
struct re_operator {
int t;
int subid;
};
reprog& _prog;
std::stack<and_node> _and_stack;
std::stack<re_operator> _operator_stack;
bool _last_was_and;
int _bracket_count;
regex_flags _flags;
inline void push_and(int first, int last) { _and_stack.push({first, last}); }
inline and_node pop_and()
{
if (_and_stack.empty()) {
auto const inst_id = _prog.add_inst(NOP);
push_and(inst_id, inst_id);
}
auto const node = _and_stack.top();
_and_stack.pop();
return node;
}
inline void push_operator(int token, int subid = 0)
{
_operator_stack.push(re_operator{token, subid});
}
inline re_operator const pop_operator()
{
auto const op = _operator_stack.top();
_operator_stack.pop();
return op;
}
void eval_until(int min_token)
{
while (min_token == RBRA || _operator_stack.top().t >= min_token) {
auto const op = pop_operator();
switch (op.t) {
default:
// unknown operator
break;
case LBRA: // expects matching RBRA
{
auto const operand = pop_and();
auto const id_inst2 = _prog.add_inst(RBRA);
_prog.inst_at(id_inst2).u1.subid = op.subid;
_prog.inst_at(operand.id_last).u2.next_id = id_inst2;
auto const id_inst1 = _prog.add_inst(LBRA);
_prog.inst_at(id_inst1).u1.subid = op.subid;
_prog.inst_at(id_inst1).u2.next_id = operand.id_first;
push_and(id_inst1, id_inst2);
return;
}
case OR: {
auto const operand2 = pop_and();
auto const operand1 = pop_and();
auto const id_inst2 = _prog.add_inst(NOP);
_prog.inst_at(operand2.id_last).u2.next_id = id_inst2;
_prog.inst_at(operand1.id_last).u2.next_id = id_inst2;
auto const id_inst1 = _prog.add_inst(OR);
_prog.inst_at(id_inst1).u1.right_id = operand1.id_first;
_prog.inst_at(id_inst1).u2.left_id = operand2.id_first;
push_and(id_inst1, id_inst2);
break;
}
case CAT: {
auto const operand2 = pop_and();
auto const operand1 = pop_and();
_prog.inst_at(operand1.id_last).u2.next_id = operand2.id_first;
push_and(operand1.id_first, operand2.id_last);
break;
}
case STAR: {
auto const operand = pop_and();
auto const id_inst1 = _prog.add_inst(OR);
_prog.inst_at(operand.id_last).u2.next_id = id_inst1;
_prog.inst_at(id_inst1).u1.right_id = operand.id_first;
push_and(id_inst1, id_inst1);
break;
}
case STAR_LAZY: {
auto const operand = pop_and();
auto const id_inst1 = _prog.add_inst(OR);
auto const id_inst2 = _prog.add_inst(NOP);
_prog.inst_at(operand.id_last).u2.next_id = id_inst1;
_prog.inst_at(id_inst1).u2.left_id = operand.id_first;
_prog.inst_at(id_inst1).u1.right_id = id_inst2;
push_and(id_inst1, id_inst2);
break;
}
case PLUS: {
auto const operand = pop_and();
auto const id_inst1 = _prog.add_inst(OR);
_prog.inst_at(operand.id_last).u2.next_id = id_inst1;
_prog.inst_at(id_inst1).u1.right_id = operand.id_first;
push_and(operand.id_first, id_inst1);
break;
}
case PLUS_LAZY: {
auto const operand = pop_and();
auto const id_inst1 = _prog.add_inst(OR);
auto const id_inst2 = _prog.add_inst(NOP);
_prog.inst_at(operand.id_last).u2.next_id = id_inst1;
_prog.inst_at(id_inst1).u2.left_id = operand.id_first;
_prog.inst_at(id_inst1).u1.right_id = id_inst2;
push_and(operand.id_first, id_inst2);
break;
}
case QUEST: {
auto const operand = pop_and();
auto const id_inst1 = _prog.add_inst(OR);
auto const id_inst2 = _prog.add_inst(NOP);
_prog.inst_at(id_inst1).u2.left_id = id_inst2;
_prog.inst_at(id_inst1).u1.right_id = operand.id_first;
_prog.inst_at(operand.id_last).u2.next_id = id_inst2;
push_and(id_inst1, id_inst2);
break;
}
case QUEST_LAZY: {
auto const operand = pop_and();
auto const id_inst1 = _prog.add_inst(OR);
auto const id_inst2 = _prog.add_inst(NOP);
_prog.inst_at(id_inst1).u2.left_id = operand.id_first;
_prog.inst_at(id_inst1).u1.right_id = id_inst2;
_prog.inst_at(operand.id_last).u2.next_id = id_inst2;
push_and(id_inst1, id_inst2);
break;
}
}
}
}
void handle_operator(int token, int subid = 0)
{
if (token == RBRA && --_bracket_count < 0) {
// unmatched right paren
return;
}
if (token == LBRA) {
_bracket_count++;
if (_last_was_and) { handle_operator(CAT, subid); }
} else {
eval_until(token);
}
if (token != RBRA) { push_operator(token, subid); }
static std::vector<int> tokens{STAR, STAR_LAZY, QUEST, QUEST_LAZY, PLUS, PLUS_LAZY, RBRA};
_last_was_and =
std::any_of(tokens.cbegin(), tokens.cend(), [token](auto t) { return t == token; });
}
void handle_operand(int token, int subid = 0, char32_t yy = 0, int class_id = 0)
{
if (_last_was_and) { handle_operator(CAT, subid); } // catenate is implicit
auto const inst_id = _prog.add_inst(token);
if (token == CCLASS || token == NCCLASS) {
_prog.inst_at(inst_id).u1.cls_id = class_id;
} else if (token == CHAR) {
_prog.inst_at(inst_id).u1.c = yy;
} else if (token == BOL || token == EOL) {
_prog.inst_at(inst_id).u1.c = yy;
}
push_and(inst_id, inst_id);
_last_was_and = true;
}
public:
regex_compiler(char32_t const* pattern,
regex_flags const flags,
capture_groups const capture,
reprog& prog)
: _prog(prog), _last_was_and(false), _bracket_count(0), _flags(flags)
{
// Parse pattern into items
auto const items = regex_parser(pattern, _flags, capture, _prog).get_items();
int cur_subid{};
int push_subid{};
// Start with a low priority operator
push_operator(START - 1);
for (auto const item : items) {
auto token = item.type;
if (token == LBRA) {
++cur_subid;
push_subid = cur_subid;
} else if (token == LBRA_NC) {
push_subid = 0;
token = LBRA;
}
if ((token & ITEM_MASK) == OPERATOR_MASK) {
handle_operator(token, push_subid);
} else {
handle_operand(token, push_subid, item.d.chr, item.d.cclass_id);
}
}
// Close with a low priority operator
eval_until(START);
// Force END
handle_operand(END, push_subid);
eval_until(START);
CUDF_EXPECTS(_bracket_count == 0, "unmatched left parenthesis");
_prog.set_start_inst(_and_stack.top().id_first);
_prog.optimize();
_prog.check_for_errors();
_prog.finalize();
_prog.set_groups_count(cur_subid);
}
};
// Convert pattern into program
reprog reprog::create_from(std::string_view pattern,
regex_flags const flags,
capture_groups const capture)
{
reprog rtn;
auto pattern32 = string_to_char32_vector(pattern);
regex_compiler compiler(pattern32.data(), flags, capture, rtn);
// for debugging, it can be helpful to call rtn.print(flags) here to dump
// out the instructions that have been created from the given pattern
return rtn;
}
void reprog::optimize() { collapse_nops(); }
void reprog::finalize() { build_start_ids(); }
void reprog::collapse_nops()
{
// treat non-capturing LBRAs/RBRAs as NOP
std::transform(_insts.begin(), _insts.end(), _insts.begin(), [](auto inst) {
if ((inst.type == LBRA || inst.type == RBRA) && (inst.u1.subid < 1)) { inst.type = NOP; }
return inst;
});
// functor for finding the next valid op
auto find_next_op = [insts = _insts](int id) {
while (insts[id].type == NOP) {
id = insts[id].u2.next_id;
}
return id;
};
// create new routes around NOP chains
std::transform(_insts.begin(), _insts.end(), _insts.begin(), [find_next_op](auto inst) {
if (inst.type != NOP) {
inst.u2.next_id = find_next_op(inst.u2.next_id);
if (inst.type == OR) { inst.u1.right_id = find_next_op(inst.u1.right_id); }
}
return inst;
});
// find starting op
_startinst_id = find_next_op(_startinst_id);
// build a map of op ids
// these are used to fix up the ids after the NOPs are removed
std::vector<int> id_map(insts_count());
std::transform_exclusive_scan(
_insts.begin(), _insts.end(), id_map.begin(), 0, std::plus<int>{}, [](auto inst) {
return static_cast<int>(inst.type != NOP);
});
// remove the NOP instructions
auto end = std::remove_if(_insts.begin(), _insts.end(), [](auto i) { return i.type == NOP; });
_insts.resize(std::distance(_insts.begin(), end));
// fix up the ids on the remaining instructions using the id_map
std::transform(_insts.begin(), _insts.end(), _insts.begin(), [id_map](auto inst) {
inst.u2.next_id = id_map[inst.u2.next_id];
if (inst.type == OR) { inst.u1.right_id = id_map[inst.u1.right_id]; }
return inst;
});
// fix up the start instruction id too
_startinst_id = id_map[_startinst_id];
}
// expand leading ORs to multiple startinst_ids
void reprog::build_start_ids()
{
_startinst_ids.clear();
std::stack<int> ids;
ids.push(_startinst_id);
while (!ids.empty()) {
int id = ids.top();
ids.pop();
reinst const& inst = _insts[id];
if (inst.type == OR) {
if (inst.u2.left_id != id) // prevents infinite while-loop here
ids.push(inst.u2.left_id);
if (inst.u1.right_id != id) // prevents infinite while-loop here
ids.push(inst.u1.right_id);
} else {
_startinst_ids.push_back(id);
}
}
_startinst_ids.push_back(-1); // terminator mark
}
/**
* @brief Check a specific instruction for errors.
*
* Currently this is checking for an infinite-loop condition as documented in this issue:
* https://github.com/rapidsai/cudf/issues/10006
*
* Example instructions list created from pattern `(A?)+`
* ```
* 0: CHAR c='A', next=2
* 1: OR right=0, left=2, next=2
* 2: RBRA id=1, next=4
* 3: LBRA id=1, next=1
* 4: OR right=3, left=5, next=5
* 5: END
* ```
*
* Following the example above, the instruction at `id==1` (OR)
* is being checked. If the instruction path returns to `id==1`
* without including the `0==CHAR` or `5==END` as in this example,
* then this would cause the runtime to go into an infinite-loop.
*
* It appears this example pattern is not valid. But Python interprets
* its behavior similarly to pattern `(A*)`. Handling this in the same
* way does not look feasible with the current implementation.
*
* @throw cudf::logic_error if instruction logic error is found
*
* @param id Instruction to check if repeated.
* @param next_id Next instruction to process.
*/
void reprog::check_for_errors(int32_t id, int32_t next_id)
{
auto inst = inst_at(next_id);
while (inst.type == LBRA || inst.type == RBRA) {
next_id = inst.u2.next_id;
inst = inst_at(next_id);
}
if (inst.type == OR) {
CUDF_EXPECTS(next_id != id, "Unsupported regex pattern");
check_for_errors(id, inst.u2.left_id);
check_for_errors(id, inst.u1.right_id);
}
}
/**
* @brief Check regex instruction set for any errors.
*
* Currently, this checks for OR instructions that eventually point back to themselves with only
* intervening capture group instructions between causing an infinite-loop during runtime
* evaluation.
*/
void reprog::check_for_errors()
{
for (auto id = 0; id < insts_count(); ++id) {
auto const inst = inst_at(id);
if (inst.type == OR) {
check_for_errors(id, inst.u2.left_id);
check_for_errors(id, inst.u1.right_id);
}
}
}
#ifndef NDEBUG
void reprog::print(regex_flags const flags)
{
printf("Flags = 0x%08x\n", static_cast<uint32_t>(flags));
printf("Instructions:\n");
for (std::size_t i = 0; i < _insts.size(); i++) {
reinst const& inst = _insts[i];
printf("%3zu: ", i);
switch (inst.type) {
default: printf("Unknown instruction: %d, next=%d", inst.type, inst.u2.next_id); break;
case CHAR:
if (inst.u1.c <= 32 || inst.u1.c >= 127) {
printf(" CHAR c='0x%02x', next=%d", static_cast<unsigned>(inst.u1.c), inst.u2.next_id);
} else {
printf(" CHAR c='%c', next=%d", inst.u1.c, inst.u2.next_id);
}
break;
case RBRA: printf(" RBRA id=%d, next=%d", inst.u1.subid, inst.u2.next_id); break;
case LBRA: printf(" LBRA id=%d, next=%d", inst.u1.subid, inst.u2.next_id); break;
case OR:
printf(
" OR right=%d, left=%d, next=%d", inst.u1.right_id, inst.u2.left_id, inst.u2.next_id);
break;
case STAR: printf(" STAR next=%d", inst.u2.next_id); break;
case PLUS: printf(" PLUS next=%d", inst.u2.next_id); break;
case QUEST: printf(" QUEST next=%d", inst.u2.next_id); break;
case ANY: printf(" ANY next=%d", inst.u2.next_id); break;
case ANYNL: printf(" ANYNL next=%d", inst.u2.next_id); break;
case NOP: printf(" NOP next=%d", inst.u2.next_id); break;
case BOL: {
printf(" BOL c=");
if (inst.u1.c == '\n') {
printf("'\\n'");
} else {
printf("'%c'", inst.u1.c);
}
printf(", next=%d", inst.u2.next_id);
break;
}
case EOL: {
printf(" EOL c=");
if (inst.u1.c == '\n') {
printf("'\\n'");
} else {
printf("'%c'", inst.u1.c);
}
printf(", next=%d", inst.u2.next_id);
break;
}
case CCLASS: printf(" CCLASS cls=%d , next=%d", inst.u1.cls_id, inst.u2.next_id); break;
case NCCLASS: printf("NCCLASS cls=%d, next=%d", inst.u1.cls_id, inst.u2.next_id); break;
case BOW: printf(" BOW next=%d", inst.u2.next_id); break;
case NBOW: printf(" NBOW next=%d", inst.u2.next_id); break;
case END: printf(" END"); break;
}
printf("\n");
}
printf("startinst_id=%d\n", _startinst_id);
if (_startinst_ids.size() > 0) {
printf("startinst_ids: [");
for (size_t i = 0; i < _startinst_ids.size(); i++) {
printf(" %d", _startinst_ids[i]);
}
printf("]\n");
}
int count = static_cast<int>(_classes.size());
printf("\nClasses %d\n", count);
for (int i = 0; i < count; i++) {
reclass const& cls = _classes[i];
auto const size = static_cast<int>(cls.literals.size());
printf("%2d: ", i);
for (int j = 0; j < size; ++j) {
auto const l = cls.literals[j];
char32_t c1 = l.first;
char32_t c2 = l.last;
if (c1 <= 32 || c1 >= 127 || c2 <= 32 || c2 >= 127) {
printf("0x%02x-0x%02x", static_cast<unsigned>(c1), static_cast<unsigned>(c2));
} else {
printf("%c-%c", static_cast<char>(c1), static_cast<char>(c2));
}
if ((j + 1) < size) { printf(", "); }
}
printf("\n");
if (cls.builtins) {
int mask = cls.builtins;
printf(" builtins(x%02X):", static_cast<unsigned>(mask));
if (mask & CCLASS_W) printf(" \\w");
if (mask & CCLASS_S) printf(" \\s");
if (mask & CCLASS_D) printf(" \\d");
if (mask & NCCLASS_W) printf(" \\W");
if (mask & NCCLASS_S) printf(" \\S");
if (mask & NCCLASS_D) printf(" \\D");
}
printf("\n");
}
if (_num_capturing_groups) { printf("Number of capturing groups: %d\n", _num_capturing_groups); }
}
#endif
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/regex/regex.cuh
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <strings/regex/regcomp.h>
#include <cudf/strings/regex/flags.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/types.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/optional.h>
#include <thrust/pair.h>
#include <cuda_runtime.h>
#include <memory>
namespace cudf {
namespace strings {
namespace detail {
struct relist;
using match_pair = thrust::pair<cudf::size_type, cudf::size_type>;
using match_result = thrust::optional<match_pair>;
constexpr int32_t MAX_SHARED_MEM = 2048; ///< Memory size for storing prog instruction data
constexpr std::size_t MAX_WORKING_MEM = 0x01'FFFF'FFFF; ///< Memory size for state data
constexpr int32_t MINIMUM_THREADS = 256; // Minimum threads for computing working memory
/**
* @brief Regex class stored on the device and executed by reprog_device.
*
* This class holds the unique data for any regex CCLASS instruction.
*/
struct alignas(16) reclass_device {
int32_t builtins{};
int32_t count{};
reclass_range const* literals{};
__device__ inline bool is_match(char32_t const ch, uint8_t const* flags) const;
};
class reprog;
/**
* @brief Regex program of instructions/data for a specific regex pattern.
*
* Once created, the find/extract methods are used to evaluate the regex instructions
* against a single string.
*
* An instance of the class requires working memory for evaluating the regex
* instructions for the string. Determine the size of the required memory by
* calling either `working_memory_size()` or `compute_strided_working_memory()`.
* Once the buffer is allocated, pass the device pointer to the `set_working_memory()`
* member function.
*/
class reprog_device {
public:
reprog_device() = delete;
~reprog_device() = default;
reprog_device(reprog_device const&) = default;
reprog_device(reprog_device&&) = default;
reprog_device& operator=(reprog_device const&) = default;
reprog_device& operator=(reprog_device&&) = default;
/**
* @brief Create device program instance from a regex program
*
* @param prog The regex program to create from
* @param stream CUDA stream used for device memory operations and kernel launches
* @return The program device object
*/
static std::unique_ptr<reprog_device, std::function<void(reprog_device*)>> create(
reprog const& prog, rmm::cuda_stream_view stream);
/**
* @brief Called automatically by the unique_ptr returned from create().
*/
void destroy();
/**
* @brief Returns the number of regex instructions.
*/
[[nodiscard]] CUDF_HOST_DEVICE int32_t insts_counts() const { return _insts_count; }
/**
* @brief Returns the number of regex groups found in the expression.
*/
[[nodiscard]] CUDF_HOST_DEVICE inline int32_t group_counts() const
{
return _num_capturing_groups;
}
/**
* @brief Returns true if this is an empty program.
*/
[[nodiscard]] __device__ inline bool is_empty() const;
/**
* @brief Returns the size needed for working memory for the given thread count.
*
* @param num_threads Number of threads to be executed in parallel
* @return Size of working memory in bytes
*/
[[nodiscard]] std::size_t working_memory_size(int32_t num_threads) const;
/**
* @brief Compute working memory for the given thread count with a maximum size.
*
* The `min_rows` overrules the `requested_max_size`.
* That is, the `requested_max_size` may be
* exceeded to keep the number of rows greater than `min_rows`.
* Also, if `rows < min_rows` then `min_rows` is not enforced.
*
* @param rows Number of rows to execute in parallel
* @param min_rows The least number of rows to meet `max_size`
* @param requested_max_size Requested maximum bytes for the working memory
* @return The size of the working memory and the number of parallel rows it will support
*/
[[nodiscard]] std::pair<std::size_t, int32_t> compute_strided_working_memory(
int32_t rows,
int32_t min_rows = MINIMUM_THREADS,
std::size_t requested_max_size = MAX_WORKING_MEM) const;
/**
* @brief Set the device working memory buffer to use for the regex execution.
*
* @param buffer Device memory pointer.
* @param thread_count Number of threads the memory buffer will support.
* @param max_insts Set to the maximum instruction count if reusing the
* memory buffer for other regex calls.
*/
void set_working_memory(void* buffer, int32_t thread_count, int32_t max_insts = 0);
/**
* @brief Returns the size of shared memory required to hold this instance.
*
* This can be called on the CPU for specifying the shared-memory size in the
* kernel launch parameters.
* This may return 0 if the MAX_SHARED_MEM value is exceeded.
*/
[[nodiscard]] int32_t compute_shared_memory_size() const;
/**
* @brief Returns the thread count passed on `set_working_memory`.
*/
[[nodiscard]] __device__ inline int32_t thread_count() const { return _thread_count; }
/**
* @brief Store this object into the given device pointer (e.g. shared memory).
*
* No data is stored if MAX_SHARED_MEM is exceeded for this object.
*/
__device__ inline void store(void* buffer) const;
/**
* @brief Load an instance of this class from a device buffer (e.g. shared memory).
*
* Data is loaded from the given buffer if MAX_SHARED_MEM is not exceeded for the given object.
* Otherwise, a copy of the object is returned.
*/
[[nodiscard]] __device__ static inline reprog_device load(reprog_device const prog, void* buffer);
/**
* @brief Does a find evaluation using the compiled expression on the given string.
*
* @param thread_idx The index used for mapping the state memory for this string in global memory.
* @param d_str The string to search.
* @param begin Position to begin the search within `d_str`.
* @param end Character position index to end the search within `d_str`.
* Specify -1 to match any virtual positions past the end of the string.
* @return If match found, returns character positions of the matches.
*/
__device__ inline match_result find(int32_t const thread_idx,
string_view const d_str,
string_view::const_iterator begin,
cudf::size_type end = -1) const;
/**
* @brief Does an extract evaluation using the compiled expression on the given string.
*
* This will find a specific capture group within the string.
* The find() function should be called first to locate the begin/end bounds of the
* the matched section.
*
* @param thread_idx The index used for mapping the state memory for this string in global memory.
* @param d_str The string to search.
* @param begin Position to begin the search within `d_str`.
* @param end Character position index to end the search within `d_str`.
* @param group_id The specific group to return its matching position values.
* @return If valid, returns the character position of the matched group in the given string,
*/
__device__ inline match_result extract(int32_t const thread_idx,
string_view const d_str,
string_view::const_iterator begin,
cudf::size_type end,
cudf::size_type const group_id) const;
private:
struct reljunk {
relist* __restrict__ list1;
relist* __restrict__ list2;
int32_t starttype{};
char32_t startchar{};
__device__ inline reljunk(relist* list1, relist* list2, reinst const inst);
__device__ inline void swaplist();
};
/**
* @brief Returns the regex instruction object for a given id.
*/
__device__ inline reinst get_inst(int32_t id) const;
/**
* @brief Returns the regex class object for a given id.
*/
__device__ inline reclass_device get_class(int32_t id) const;
/**
* @brief Executes the regex pattern on the given string.
*/
__device__ inline match_result regexec(string_view const d_str,
reljunk jnk,
string_view::const_iterator begin,
cudf::size_type end,
cudf::size_type const group_id = 0) const;
/**
* @brief Utility wrapper to setup state memory structures for calling regexec
*/
__device__ inline match_result call_regexec(int32_t const thread_idx,
string_view const d_str,
string_view::const_iterator begin,
cudf::size_type end,
cudf::size_type const group_id = 0) const;
reprog_device(reprog const&);
int32_t _startinst_id; // first instruction id
int32_t _num_capturing_groups; // instruction groups
int32_t _insts_count; // number of instructions
int32_t _starts_count; // number of start-insts ids
int32_t _classes_count; // number of classes
int32_t _max_insts; // for partitioning working memory
uint8_t const* _codepoint_flags{}; // table of character types
reinst const* _insts{}; // array of regex instructions
int32_t const* _startinst_ids{}; // array of start instruction ids
reclass_device const* _classes{}; // array of regex classes
std::size_t _prog_size{}; // total size of this instance
void* _buffer{}; // working memory buffer
int32_t _thread_count{}; // threads available in working memory
};
/**
* @brief Return the size in bytes needed for working memory to
* execute insts_count instructions in parallel over num_threads threads.
*
* @param num_threads Number of parallel threads (usually one per string in a strings column)
* @param insts_count Number of instructions from a compiled regex pattern
* @return Number of bytes needed for working memory
*/
std::size_t compute_working_memory_size(int32_t num_threads, int32_t insts_count);
/**
* @brief Converts a match_pair from character positions to byte positions
*/
__device__ __forceinline__ match_pair match_positions_to_bytes(match_pair const result,
string_view d_str,
string_view::const_iterator last)
{
if (d_str.length() == d_str.size_bytes()) { return result; }
auto const begin = (last + (result.first - last.position())).byte_offset();
auto const end = (last + (result.second - last.position())).byte_offset();
return {begin, end};
}
/**
* @brief Creates a string_view from a match result
*/
__device__ __forceinline__ string_view string_from_match(match_pair const result,
string_view d_str,
string_view::const_iterator last)
{
auto const [begin, end] = match_positions_to_bytes(result, d_str, last);
return string_view(d_str.data() + begin, end - begin);
}
} // namespace detail
} // namespace strings
} // namespace cudf
#include "./regex.inl"
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/regex/regex_program_impl.h
|
/*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "regcomp.h"
#include "regex.cuh"
#include <cudf/strings/regex/regex_program.hpp>
#include <rmm/cuda_stream_view.hpp>
namespace cudf {
namespace strings {
/**
* @brief Implementation object for regex_program
*
* It encapsulates internal reprog object used for building its device equivalent
*/
struct regex_program::regex_program_impl {
detail::reprog prog;
regex_program_impl(detail::reprog const& p) : prog(p) {}
regex_program_impl(detail::reprog&& p) : prog(p) {}
// TODO: There will be other options added here in the future to handle issues
// 10852 and possibly others like 11979
};
struct regex_device_builder {
static auto create_prog_device(regex_program const& p, rmm::cuda_stream_view stream)
{
return detail::reprog_device::create(p._impl->prog, stream);
}
};
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/regex/regex_program.cpp
|
/*
* Copyright (c) 2022-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "regex_program_impl.h"
#include <cudf/strings/regex/regex_program.hpp>
#include <memory>
#include <string>
namespace cudf {
namespace strings {
std::unique_ptr<regex_program> regex_program::create(std::string_view pattern,
regex_flags flags,
capture_groups capture)
{
auto p = new regex_program(pattern, flags, capture);
return std::unique_ptr<regex_program>(p);
}
regex_program::~regex_program() = default;
regex_program::regex_program(regex_program&& other) = default;
regex_program& regex_program::operator=(regex_program&& other) = default;
regex_program::regex_program(std::string_view pattern, regex_flags flags, capture_groups capture)
: _pattern(pattern),
_flags(flags),
_impl(
std::make_unique<regex_program_impl>(detail::reprog::create_from(pattern, flags, capture)))
{
}
std::string regex_program::pattern() const { return _pattern; }
regex_flags regex_program::flags() const { return _flags; }
capture_groups regex_program::capture() const { return _capture; }
int32_t regex_program::instructions_count() const { return _impl->prog.insts_count(); }
int32_t regex_program::groups_count() const { return _impl->prog.groups_count(); }
std::size_t regex_program::compute_working_memory_size(int32_t num_strings) const
{
return detail::compute_working_memory_size(num_strings, instructions_count());
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/regex/regcomp.h
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cudf/strings/regex/flags.hpp>
#include <string>
#include <vector>
namespace cudf {
namespace strings {
namespace detail {
/**
* @brief Actions and Tokens (regex instruction types)
*
* ```
* 02xx are operators, value == precedence
* 03xx are tokens, i.e. operands for operators
* ```
*/
enum InstType : int32_t {
CHAR = 0177, // Literal character
RBRA = 0201, // Right bracket, )
LBRA = 0202, // Left bracket, (
OR = 0204, // Alternation, |
ANY = 0300, // Any character except newline, .
ANYNL = 0301, // Any character including newline, .
BOL = 0303, // Beginning of line, ^
EOL = 0304, // End of line, $
CCLASS = 0305, // Character class, []
NCCLASS = 0306, // Negated character class, [^ ]
BOW = 0307, // Boundary of word, \b
NBOW = 0310, // Not boundary of word, \B
END = 0377 // Terminate: match found
};
/**
* @brief Range used for literals in reclass classes.
*/
struct reclass_range {
char32_t first{}; /// first character in span
char32_t last{}; /// last character in span (inclusive)
};
/**
* @brief Class type for regex compiler instruction.
*/
struct reclass {
int32_t builtins{0}; // bit mask identifying builtin classes
std::vector<reclass_range> literals;
reclass() {}
reclass(int m) : builtins(m) {}
reclass(int m, std::vector<reclass_range>&& l) : builtins(m), literals(std::move(l)) {}
};
constexpr int32_t CCLASS_W{1 << 0}; // [a-z], [A-Z], [0-9], and '_'
constexpr int32_t CCLASS_S{1 << 1}; // all spaces or ctrl characters
constexpr int32_t CCLASS_D{1 << 2}; // digits [0-9]
constexpr int32_t NCCLASS_W{1 << 3}; // not CCLASS_W or '\n'
constexpr int32_t NCCLASS_S{1 << 4}; // not CCLASS_S
constexpr int32_t NCCLASS_D{1 << 5}; // not CCLASS_D or '\n'
/**
* @brief Structure of an encoded regex instruction
*/
struct reinst {
int32_t type; /* operator type or instruction type */
union {
int32_t cls_id; /* class pointer */
char32_t c; /* character */
int32_t subid; /* sub-expression id for RBRA and LBRA */
int32_t right_id; /* right child of OR */
} u1;
union { /* regexec relies on these two being in the same union */
int32_t left_id; /* left child of OR */
int32_t next_id; /* next instruction for CAT & LBRA */
} u2;
int32_t reserved4;
};
/**
* @brief Regex program handles parsing a pattern into a vector
* of chained instructions.
*/
class reprog {
public:
reprog(reprog const&) = default;
reprog(reprog&&) = default;
~reprog() = default;
reprog& operator=(reprog const&) = default;
reprog& operator=(reprog&&) = default;
/**
* @brief Parses the given regex pattern and produces an instance
* of this object
*
* @param pattern Regex pattern encoded as UTF-8
* @param flags For interpreting certain `pattern` characters
* @param capture For controlling how capture groups are processed
* @return Instance of reprog
*/
static reprog create_from(std::string_view pattern,
regex_flags const flags,
capture_groups const capture = capture_groups::EXTRACT);
int32_t add_inst(int32_t type);
int32_t add_inst(reinst const& inst);
int32_t add_class(reclass const& cls);
void set_groups_count(int32_t groups);
[[nodiscard]] int32_t groups_count() const;
[[nodiscard]] int32_t insts_count() const;
[[nodiscard]] reinst& inst_at(int32_t id);
[[nodiscard]] reinst const* insts_data() const;
[[nodiscard]] int32_t classes_count() const;
[[nodiscard]] reclass const& class_at(int32_t id) const;
[[nodiscard]] reclass const* classes_data() const;
[[nodiscard]] int32_t const* starts_data() const;
[[nodiscard]] int32_t starts_count() const;
void set_start_inst(int32_t id);
[[nodiscard]] int32_t get_start_inst() const;
void optimize();
void finalize();
void check_for_errors();
#ifndef NDEBUG
void print(regex_flags const flags);
#endif
private:
std::vector<reinst> _insts; // instructions
std::vector<reclass> _classes; // data for CCLASS instructions
int32_t _startinst_id{}; // id of first instruction
std::vector<int32_t> _startinst_ids; // short-cut to speed-up ORs
int32_t _num_capturing_groups{};
reprog() = default;
void collapse_nops();
void build_start_ids();
void check_for_errors(int32_t id, int32_t next_id);
};
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/regex/regex.inl
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/detail/utilities/integer_utils.hpp>
#include <cudf/strings/detail/char_tables.hpp>
namespace cudf {
namespace strings {
namespace detail {
/**
* @brief This holds the state information when evaluating a string
* against a regex pattern.
*
* There are 2 instances of this per string managed in the reljunk class.
* As each regex instruction is evaluated for a string, the result is
* reflected here. The regexec function updates and manages this state data.
*/
struct alignas(8) relist {
/**
* @brief Compute the memory size for the state data.
*/
constexpr inline static std::size_t data_size_for(int32_t insts)
{
return ((sizeof(ranges[0]) + sizeof(inst_ids[0])) * insts) +
cudf::util::div_rounding_up_unsafe(insts, 8);
}
/**
* @brief Compute the aligned memory allocation size.
*/
constexpr inline static std::size_t alloc_size(int32_t insts, int32_t num_threads)
{
return cudf::util::round_up_unsafe<size_t>(data_size_for(insts) * num_threads, sizeof(restate));
}
struct alignas(16) restate {
int2 range;
int32_t inst_id;
int32_t reserved;
};
__device__ __forceinline__
relist(int16_t insts, int32_t num_threads, u_char* gp_ptr, int32_t index)
: masksize(cudf::util::div_rounding_up_unsafe(insts, 8)), stride(num_threads)
{
auto const rdata_size = sizeof(ranges[0]);
auto const idata_size = sizeof(inst_ids[0]);
ranges = reinterpret_cast<decltype(ranges)>(gp_ptr + (index * rdata_size));
inst_ids =
reinterpret_cast<int16_t*>(gp_ptr + (rdata_size * stride * insts) + (index * idata_size));
mask = gp_ptr + ((rdata_size + idata_size) * stride * insts) + (index * masksize);
}
__device__ __forceinline__ void reset()
{
memset(mask, 0, masksize);
size = 0;
}
__device__ __forceinline__ bool activate(int32_t id, int32_t begin, int32_t end)
{
if (readMask(id)) { return false; }
writeMask(id);
inst_ids[size * stride] = static_cast<int16_t>(id);
ranges[size * stride] = int2{begin, end};
++size;
return true;
}
__device__ __forceinline__ restate get_state(int16_t idx) const
{
return restate{ranges[idx * stride], inst_ids[idx * stride]};
}
__device__ __forceinline__ int16_t get_size() const { return size; }
private:
int16_t size{};
int16_t const masksize;
int32_t const stride;
int2* __restrict__ ranges; // pair per instruction
int16_t* __restrict__ inst_ids; // one per instruction
u_char* __restrict__ mask; // bit per instruction
__device__ __forceinline__ void writeMask(int32_t pos) const
{
u_char const uc = 1 << (pos & 7);
mask[pos >> 3] |= uc;
}
__device__ __forceinline__ bool readMask(int32_t pos) const
{
u_char const uc = mask[pos >> 3];
return static_cast<bool>((uc >> (pos & 7)) & 1);
}
};
__device__ __forceinline__ reprog_device::reljunk::reljunk(relist* list1,
relist* list2,
reinst const inst)
: list1(list1), list2(list2)
{
if (inst.type == CHAR || inst.type == BOL) {
starttype = inst.type;
startchar = inst.u1.c;
}
}
__device__ __forceinline__ void reprog_device::reljunk::swaplist()
{
auto tmp = list1;
list1 = list2;
list2 = tmp;
}
/**
* @brief Utility to check a specific character against this class instance.
*
* @param ch A 4-byte UTF-8 character.
* @param codepoint_flags Used for mapping a character to type for builtin classes.
* @return true if the character matches
*/
__device__ __forceinline__ bool reclass_device::is_match(char32_t const ch,
uint8_t const* codepoint_flags) const
{
for (int i = 0; i < count; ++i) {
auto const literal = literals[i];
if ((ch >= literal.first) && (ch <= literal.last)) { return true; }
}
if (!builtins) return false;
uint32_t codept = utf8_to_codepoint(ch);
if (codept > 0x00'FFFF) return false;
int8_t fl = codepoint_flags[codept];
if ((builtins & CCLASS_W) && ((ch == '_') || IS_ALPHANUM(fl))) // \w
return true;
if ((builtins & CCLASS_S) && IS_SPACE(fl)) // \s
return true;
if ((builtins & CCLASS_D) && IS_DIGIT(fl)) // \d
return true;
if ((builtins & NCCLASS_W) && ((ch != '\n') && (ch != '_') && !IS_ALPHANUM(fl))) // \W
return true;
if ((builtins & NCCLASS_S) && !IS_SPACE(fl)) // \S
return true;
if ((builtins & NCCLASS_D) && ((ch != '\n') && !IS_DIGIT(fl))) // \D
return true;
//
return false;
}
__device__ __forceinline__ reinst reprog_device::get_inst(int32_t id) const { return _insts[id]; }
__device__ __forceinline__ reclass_device reprog_device::get_class(int32_t id) const
{
return _classes[id];
}
__device__ __forceinline__ bool reprog_device::is_empty() const
{
return insts_counts() == 0 || get_inst(0).type == END;
}
__device__ __forceinline__ void reprog_device::store(void* buffer) const
{
if (_prog_size > MAX_SHARED_MEM) { return; }
auto ptr = static_cast<u_char*>(buffer);
// create instance inside the given buffer
auto result = new (ptr) reprog_device(*this);
// add the insts array
ptr += sizeof(reprog_device);
auto insts = reinterpret_cast<reinst*>(ptr);
result->_insts = insts;
for (int idx = 0; idx < _insts_count; ++idx)
*insts++ = _insts[idx];
// add the startinst_ids array
ptr += cudf::util::round_up_unsafe(_insts_count * sizeof(_insts[0]), sizeof(_startinst_ids[0]));
auto ids = reinterpret_cast<int32_t*>(ptr);
result->_startinst_ids = ids;
for (int idx = 0; idx < _starts_count; ++idx)
*ids++ = _startinst_ids[idx];
// add the classes array
ptr += cudf::util::round_up_unsafe(_starts_count * sizeof(int32_t), sizeof(_classes[0]));
auto classes = reinterpret_cast<reclass_device*>(ptr);
result->_classes = classes;
// fill in each class
auto d_ptr = reinterpret_cast<reclass_range*>(classes + _classes_count);
for (int idx = 0; idx < _classes_count; ++idx) {
classes[idx] = _classes[idx];
classes[idx].literals = d_ptr;
for (int jdx = 0; jdx < _classes[idx].count; ++jdx)
*d_ptr++ = _classes[idx].literals[jdx];
}
}
__device__ __forceinline__ reprog_device reprog_device::load(reprog_device const prog, void* buffer)
{
return (prog._prog_size > MAX_SHARED_MEM) ? reprog_device(prog)
: reinterpret_cast<reprog_device*>(buffer)[0];
}
/**
* @brief Evaluate a specific string against regex pattern compiled to this instance.
*
* This is the main function for executing the regex against an individual string.
*
* @param dstr String used for matching.
* @param jnk State data object for this string.
* @param[in,out] begin Character position to start evaluation. On return, it is the position of the
* match.
* @param[in,out] end Character position to stop evaluation. On return, it is the end of the matched
* substring.
* @param group_id Index of the group to match in a multi-group regex pattern.
* @return >0 if match found
*/
__device__ __forceinline__ match_result reprog_device::regexec(string_view const dstr,
reljunk jnk,
string_view::const_iterator itr,
cudf::size_type end,
cudf::size_type const group_id) const
{
int32_t match = 0;
auto begin = itr.position();
auto pos = begin;
auto eos = end;
auto checkstart = jnk.starttype != 0;
auto last_character = false;
jnk.list1->reset();
do {
// fast check for first CHAR or BOL
if (checkstart) {
auto startchar = static_cast<char_utf8>(jnk.startchar);
switch (jnk.starttype) {
case BOL:
if (pos == 0) break;
if (jnk.startchar != '^') { return thrust::nullopt; }
--pos;
startchar = static_cast<char_utf8>('\n');
case CHAR: {
auto const fidx = dstr.find(startchar, pos);
if (fidx == string_view::npos) { return thrust::nullopt; }
pos = fidx + (jnk.starttype == BOL);
break;
}
}
itr += (pos - itr.position()); // faster to increment position
}
if (((eos < 0) || (pos < eos)) && match == 0) {
auto ids = _startinst_ids;
while (*ids >= 0)
jnk.list1->activate(*ids++, (group_id == 0 ? pos : -1), -1);
}
last_character = itr.byte_offset() >= dstr.size_bytes();
char_utf8 const c = last_character ? 0 : *itr;
// expand the non-character types like: LBRA, RBRA, BOL, EOL, BOW, NBOW, and OR
bool expanded = false;
do {
jnk.list2->reset();
expanded = false;
for (int16_t i = 0; i < jnk.list1->get_size(); i++) {
auto state = jnk.list1->get_state(i);
auto range = state.range;
auto const inst = get_inst(state.inst_id);
int32_t id_activate = -1;
switch (inst.type) {
case CHAR:
case ANY:
case ANYNL:
case CCLASS:
case NCCLASS:
case END: id_activate = state.inst_id; break;
case LBRA:
if (inst.u1.subid == group_id) range.x = pos;
id_activate = inst.u2.next_id;
expanded = true;
break;
case RBRA:
if (inst.u1.subid == group_id) range.y = pos;
id_activate = inst.u2.next_id;
expanded = true;
break;
case BOL:
if ((pos == 0) || ((inst.u1.c == '^') && (dstr[pos - 1] == '\n'))) {
id_activate = inst.u2.next_id;
expanded = true;
}
break;
case EOL:
// after the last character OR:
// - for MULTILINE, if current character is new-line
// - for non-MULTILINE, the very last character of the string can also be a new-line
if (last_character ||
((c == '\n') && (inst.u1.c != 'Z') &&
((inst.u1.c == '$') || (itr.byte_offset() + 1 == dstr.size_bytes())))) {
id_activate = inst.u2.next_id;
expanded = true;
}
break;
case BOW:
case NBOW: {
auto const prev_c = pos > 0 ? dstr[pos - 1] : 0;
auto const word_class = reclass_device{CCLASS_W};
bool const curr_is_word = word_class.is_match(c, _codepoint_flags);
bool const prev_is_word = word_class.is_match(prev_c, _codepoint_flags);
if ((curr_is_word == prev_is_word) != (inst.type == BOW)) {
id_activate = inst.u2.next_id;
expanded = true;
}
break;
}
case OR:
jnk.list2->activate(inst.u1.right_id, range.x, range.y);
id_activate = inst.u2.left_id;
expanded = true;
break;
}
if (id_activate >= 0) jnk.list2->activate(id_activate, range.x, range.y);
}
jnk.swaplist();
} while (expanded);
// execute instructions
bool continue_execute = true;
jnk.list2->reset();
for (int16_t i = 0; continue_execute && i < jnk.list1->get_size(); i++) {
auto const state = jnk.list1->get_state(i);
auto const range = state.range;
auto const inst = get_inst(state.inst_id);
int32_t id_activate = -1;
switch (inst.type) {
case CHAR:
if (inst.u1.c == c) id_activate = inst.u2.next_id;
break;
case ANY:
if (c != '\n') id_activate = inst.u2.next_id;
break;
case ANYNL: id_activate = inst.u2.next_id; break;
case NCCLASS:
case CCLASS: {
auto const cls = get_class(inst.u1.cls_id);
if (cls.is_match(static_cast<char32_t>(c), _codepoint_flags) == (inst.type == CCLASS)) {
id_activate = inst.u2.next_id;
}
break;
}
case END:
match = 1;
begin = range.x;
end = group_id == 0 ? pos : range.y;
// done with execute
continue_execute = false;
break;
}
if (continue_execute && (id_activate >= 0))
jnk.list2->activate(id_activate, range.x, range.y);
}
++pos;
++itr;
jnk.swaplist();
checkstart = jnk.list1->get_size() == 0;
} while (!last_character && (!checkstart || !match));
return match ? match_result({begin, end}) : thrust::nullopt;
}
__device__ __forceinline__ match_result reprog_device::find(int32_t const thread_idx,
string_view const dstr,
string_view::const_iterator begin,
cudf::size_type end) const
{
return call_regexec(thread_idx, dstr, begin, end);
}
__device__ __forceinline__ match_result reprog_device::extract(int32_t const thread_idx,
string_view const dstr,
string_view::const_iterator begin,
cudf::size_type end,
cudf::size_type const group_id) const
{
end = begin.position() + 1;
return call_regexec(thread_idx, dstr, begin, end, group_id + 1);
}
__device__ __forceinline__ match_result
reprog_device::call_regexec(int32_t const thread_idx,
string_view const dstr,
string_view::const_iterator begin,
cudf::size_type end,
cudf::size_type const group_id) const
{
auto gp_ptr = reinterpret_cast<u_char*>(_buffer);
relist list1(static_cast<int16_t>(_max_insts), _thread_count, gp_ptr, thread_idx);
gp_ptr += relist::alloc_size(_max_insts, _thread_count);
relist list2(static_cast<int16_t>(_max_insts), _thread_count, gp_ptr, thread_idx);
reljunk jnk(&list1, &list2, get_inst(_startinst_id));
return regexec(dstr, jnk, begin, end, group_id);
}
} // namespace detail
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/combine/join.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/scalar/scalar_device_view.cuh>
#include <cudf/strings/combine.hpp>
#include <cudf/strings/detail/combine.hpp>
#include <cudf/strings/detail/strings_column_factories.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Threshold to decide on using string-per-thread vs the string-gather
* approaches.
*
* If the average byte length of a string in a column exceeds this value then
* the string-gather function is used.
* Otherwise, a regular string-parallel function is used.
*
* This value was found using the strings_join benchmark results.
*/
constexpr size_type AVG_CHAR_BYTES_THRESHOLD = 32;
struct join_base_fn {
column_device_view const d_strings;
string_view d_separator;
string_scalar_device_view d_narep;
__device__ thrust::pair<string_view, string_view> process_string(size_type idx) const
{
string_view d_str{};
string_view d_sep = (idx + 1 < d_strings.size()) ? d_separator : d_str;
if (d_strings.is_null(idx)) {
if (d_narep.is_valid()) {
d_str = d_narep.value();
} else {
// if null and no narep, don't output a separator either
d_sep = d_str;
}
} else {
d_str = d_strings.element<string_view>(idx);
}
return {d_str, d_sep};
}
};
/**
* @brief Compute output sizes and write output bytes
*
* This functor is suitable for make_strings_children
*/
struct join_fn : public join_base_fn {
size_type* d_offsets{};
char* d_chars{};
join_fn(column_device_view const d_strings,
string_view d_separator,
string_scalar_device_view d_narep)
: join_base_fn{d_strings, d_separator, d_narep}
{
}
__device__ void operator()(size_type idx) const
{
auto const [d_str, d_sep] = process_string(idx);
char* d_buffer = d_chars ? d_chars + d_offsets[idx] : nullptr;
size_type bytes = 0;
if (d_buffer) {
d_buffer = detail::copy_string(d_buffer, d_str);
d_buffer = detail::copy_string(d_buffer, d_sep);
} else {
bytes += d_str.size_bytes() + d_sep.size_bytes();
}
if (!d_chars) { d_offsets[idx] = bytes; }
}
};
struct join_gather_fn : public join_base_fn {
join_gather_fn(column_device_view const d_strings,
string_view d_separator,
string_scalar_device_view d_narep)
: join_base_fn{d_strings, d_separator, d_narep}
{
}
__device__ string_index_pair operator()(size_type idx) const
{
auto const [d_str, d_sep] = process_string(idx / 2);
// every other string is the separator
return idx % 2 ? string_index_pair{d_sep.data(), d_sep.size_bytes()}
: string_index_pair{d_str.data(), d_str.size_bytes()};
}
};
} // namespace
std::unique_ptr<column> join_strings(strings_column_view const& input,
string_scalar const& separator,
string_scalar const& narep,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) { return make_empty_column(type_id::STRING); }
CUDF_EXPECTS(separator.is_valid(stream), "Parameter separator must be a valid string_scalar");
string_view d_separator(separator.data(), separator.size());
auto d_narep = get_scalar_device_view(const_cast<string_scalar&>(narep));
auto d_strings = column_device_view::create(input.parent(), stream);
auto chars_column = [&] {
// build the strings column and commandeer the chars column
if ((input.size() == input.null_count()) ||
((input.chars_size() / (input.size() - input.null_count())) <= AVG_CHAR_BYTES_THRESHOLD)) {
return std::get<1>(
make_strings_children(join_fn{*d_strings, d_separator, d_narep}, input.size(), stream, mr));
}
// dynamically feeds index pairs to build the output
auto indices = cudf::detail::make_counting_transform_iterator(
0, join_gather_fn{*d_strings, d_separator, d_narep});
auto joined_col = make_strings_column(indices, indices + (input.size() * 2), stream, mr);
return std::move(joined_col->release().children.back());
}();
// build the offsets: single string output has offsets [0,chars-size]
auto offsets = cudf::detail::make_device_uvector_async(
std::vector<size_type>({0, chars_column->size()}), stream, mr);
auto offsets_column = std::make_unique<column>(std::move(offsets), rmm::device_buffer{}, 0);
// build the null mask: only one output row so it is either all-valid or all-null
auto const null_count =
static_cast<size_type>(input.null_count() == input.size() && !narep.is_valid(stream));
auto null_mask = null_count
? cudf::detail::create_null_mask(1, cudf::mask_state::ALL_NULL, stream, mr)
: rmm::device_buffer{0, stream, mr};
// perhaps this return a string_scalar instead of a single-row column
return make_strings_column(
1, std::move(offsets_column), std::move(chars_column), null_count, std::move(null_mask));
}
} // namespace detail
// external API
std::unique_ptr<column> join_strings(strings_column_view const& strings,
string_scalar const& separator,
string_scalar const& narep,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::join_strings(strings, separator, narep, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/combine/concatenate.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/valid_if.cuh>
#include <cudf/scalar/scalar_device_view.cuh>
#include <cudf/strings/combine.hpp>
#include <cudf/strings/detail/combine.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/table/table_device_view.cuh>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/execution_policy.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/logical.h>
#include <algorithm>
namespace cudf {
namespace strings {
namespace detail {
namespace {
struct concat_strings_base {
table_device_view const d_table;
string_scalar_device_view const d_narep;
separator_on_nulls separate_nulls;
size_type* d_offsets{};
char* d_chars{};
/**
* @brief Concatenate each table row to a single output string.
*
* This will concatenate the strings from each row of the given table
* and apply the separator. The null-replacement string `d_narep` is
* used in place of any string in a row that contains a null entry.
*
* @param idx The current row to process
* @param d_separator String to place in between each column's row
*/
__device__ void process_row(size_type idx, string_view const d_separator)
{
if (!d_narep.is_valid() &&
thrust::any_of(thrust::seq, d_table.begin(), d_table.end(), [idx](auto const& col) {
return col.is_null(idx);
})) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
char* d_buffer = d_chars ? d_chars + d_offsets[idx] : nullptr;
size_type bytes = 0;
bool write_separator = false;
for (auto itr = d_table.begin(); itr < d_table.end(); ++itr) {
auto const d_column = *itr;
bool const null_element = d_column.is_null(idx);
if (write_separator && (separate_nulls == separator_on_nulls::YES || !null_element)) {
if (d_buffer) d_buffer = detail::copy_string(d_buffer, d_separator);
bytes += d_separator.size_bytes();
write_separator = false;
}
// write out column's row data (or narep if the row is null)
auto const d_str = null_element ? d_narep.value() : d_column.element<string_view>(idx);
if (d_buffer) d_buffer = detail::copy_string(d_buffer, d_str);
bytes += d_str.size_bytes();
write_separator =
write_separator || (separate_nulls == separator_on_nulls::YES) || !null_element;
}
if (!d_chars) d_offsets[idx] = bytes;
}
};
/**
* @brief Single separator concatenate functor
*/
struct concat_strings_fn : concat_strings_base {
string_view const d_separator;
concat_strings_fn(table_device_view const& d_table,
string_view const& d_separator,
string_scalar_device_view const& d_narep,
separator_on_nulls separate_nulls)
: concat_strings_base{d_table, d_narep, separate_nulls}, d_separator(d_separator)
{
}
__device__ void operator()(size_type idx) { process_row(idx, d_separator); }
};
} // namespace
std::unique_ptr<column> concatenate(table_view const& strings_columns,
string_scalar const& separator,
string_scalar const& narep,
separator_on_nulls separate_nulls,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto const num_columns = strings_columns.num_columns();
CUDF_EXPECTS(num_columns > 1, "At least two columns must be specified");
// check all columns are of type string
CUDF_EXPECTS(std::all_of(strings_columns.begin(),
strings_columns.end(),
[](auto c) { return c.type().id() == type_id::STRING; }),
"All columns must be of type string");
auto const strings_count = strings_columns.num_rows();
if (strings_count == 0) // empty begets empty
return make_empty_column(type_id::STRING);
CUDF_EXPECTS(separator.is_valid(stream), "Parameter separator must be a valid string_scalar");
string_view d_separator(separator.data(), separator.size());
auto d_narep = get_scalar_device_view(const_cast<string_scalar&>(narep));
// Create device views from the strings columns.
auto d_table = table_device_view::create(strings_columns, stream);
concat_strings_fn fn{*d_table, d_separator, d_narep, separate_nulls};
auto children = make_strings_children(fn, strings_count, stream, mr);
// create resulting null mask
auto [null_mask, null_count] = cudf::detail::valid_if(
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_count),
[d_table = *d_table, d_narep] __device__(size_type idx) {
if (d_narep.is_valid()) return true;
return !thrust::any_of(
thrust::seq, d_table.begin(), d_table.end(), [idx](auto col) { return col.is_null(idx); });
},
stream,
mr);
return make_strings_column(strings_count,
std::move(children.first),
std::move(children.second),
null_count,
std::move(null_mask));
}
namespace {
/**
* @brief Concatenate strings functor using multiple separators.
*
* A unique separator is provided for each row along with a string to use
* when a separator row is null `d_separator_narep`. The `d_narep` is
* used in place of a null entry in the strings columns.
*/
struct multi_separator_concat_fn : concat_strings_base {
column_device_view const d_separators;
string_scalar_device_view const d_separator_narep;
multi_separator_concat_fn(table_device_view const& d_table,
column_device_view const& d_separators,
string_scalar_device_view const& d_separator_narep,
string_scalar_device_view const& d_narep,
separator_on_nulls separate_nulls)
: concat_strings_base{d_table, d_narep, separate_nulls},
d_separators(d_separators),
d_separator_narep(d_separator_narep)
{
}
__device__ void operator()(size_type idx)
{
if (d_separators.is_null(idx) && !d_separator_narep.is_valid()) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto const d_separator = d_separators.is_valid(idx) ? d_separators.element<string_view>(idx)
: d_separator_narep.value();
// base class utility function handles the rest
process_row(idx, d_separator);
}
};
} // namespace
std::unique_ptr<column> concatenate(table_view const& strings_columns,
strings_column_view const& separators,
string_scalar const& separator_narep,
string_scalar const& col_narep,
separator_on_nulls separate_nulls,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto const num_columns = strings_columns.num_columns();
CUDF_EXPECTS(num_columns > 0, "At least one column must be specified");
// Check if all columns are of type string
CUDF_EXPECTS(std::all_of(strings_columns.begin(),
strings_columns.end(),
[](auto c) { return c.type().id() == type_id::STRING; }),
"All columns must be of type string");
auto const strings_count = strings_columns.num_rows();
CUDF_EXPECTS(strings_count == separators.size(),
"Separators column should be the same size as the strings columns");
if (strings_count == 0) // Empty begets empty
return make_empty_column(type_id::STRING);
// Invalid output column strings - null rows
string_view const invalid_str{nullptr, 0};
auto const separator_rep = get_scalar_device_view(const_cast<string_scalar&>(separator_narep));
auto const col_rep = get_scalar_device_view(const_cast<string_scalar&>(col_narep));
auto const separator_col_view_ptr = column_device_view::create(separators.parent(), stream);
auto const separator_col_view = *separator_col_view_ptr;
// Create device views from the strings columns.
auto d_table = table_device_view::create(strings_columns, stream);
multi_separator_concat_fn mscf{
*d_table, separator_col_view, separator_rep, col_rep, separate_nulls};
auto children = make_strings_children(mscf, strings_count, stream, mr);
// Create resulting null mask
auto [null_mask, null_count] = cudf::detail::valid_if(
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_count),
[d_table = *d_table, separator_col_view, separator_rep, col_rep] __device__(size_type idx) {
if (!separator_col_view.is_valid(idx) && !separator_rep.is_valid()) return false;
if (col_rep.is_valid()) return true;
return !thrust::any_of(
thrust::seq, d_table.begin(), d_table.end(), [idx](auto col) { return col.is_null(idx); });
},
stream,
mr);
return make_strings_column(strings_count,
std::move(children.first),
std::move(children.second),
null_count,
std::move(null_mask));
}
} // namespace detail
// APIs
std::unique_ptr<column> concatenate(table_view const& strings_columns,
string_scalar const& separator,
string_scalar const& narep,
separator_on_nulls separate_nulls,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::concatenate(strings_columns, separator, narep, separate_nulls, stream, mr);
}
std::unique_ptr<column> concatenate(table_view const& strings_columns,
strings_column_view const& separators,
string_scalar const& separator_narep,
string_scalar const& col_narep,
separator_on_nulls separate_nulls,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::concatenate(
strings_columns, separators, separator_narep, col_narep, separate_nulls, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/combine/join_list_elements.cu
|
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/valid_if.cuh>
#include <cudf/lists/lists_column_view.hpp>
#include <cudf/scalar/scalar_device_view.cuh>
#include <cudf/strings/combine.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <thrust/iterator/counting_iterator.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Compute string sizes, string validities, and concatenate strings functor.
*
* This functor is executed twice. In the first pass, the sizes and validities of the output strings
* will be computed. In the second pass, this will concatenate the strings within each list element
* of the given lists column and apply the separator. The null-replacement string scalar
* `string_narep_dv` (if valid) is used in place of any null string.
*
* @tparam Functor The functor which can check for validity of the input list at a given list index
* as well as access to the separator corresponding to the list index.
*/
template <class Functor>
struct compute_size_and_concatenate_fn {
Functor const func;
column_device_view const lists_dv;
size_type const* const list_offsets;
column_device_view const strings_dv;
string_scalar_device_view const string_narep_dv;
separator_on_nulls const separate_nulls;
output_if_empty_list const empty_list_policy;
size_type* d_offsets{nullptr};
// If d_chars == nullptr: only compute sizes and validities of the output strings.
// If d_chars != nullptr: only concatenate strings.
char* d_chars{nullptr};
[[nodiscard]] __device__ bool output_is_null(size_type const idx,
size_type const start_idx,
size_type const end_idx) const noexcept
{
if (func.is_null_list(lists_dv, idx)) { return true; }
return empty_list_policy == output_if_empty_list::NULL_ELEMENT && start_idx == end_idx;
}
__device__ void operator()(size_type const idx) const noexcept
{
// If this is the second pass, and the row `idx` is known to be a null or empty string
if (d_chars && (d_offsets[idx] == d_offsets[idx + 1])) { return; }
// Indices of the strings within the list row
auto const start_idx = list_offsets[idx];
auto const end_idx = list_offsets[idx + 1];
if (!d_chars && output_is_null(idx, start_idx, end_idx)) {
d_offsets[idx] = 0;
return;
}
auto const separator = func.separator(idx);
char* output_ptr = d_chars ? d_chars + d_offsets[idx] : nullptr;
bool write_separator = false;
auto size_bytes = size_type{0};
bool has_valid_element = false;
for (size_type str_idx = start_idx; str_idx < end_idx; ++str_idx) {
bool null_element = strings_dv.is_null(str_idx);
has_valid_element = has_valid_element || !null_element;
if (!d_chars && (null_element && !string_narep_dv.is_valid())) {
size_bytes = 0;
break;
}
if (write_separator && (separate_nulls == separator_on_nulls::YES || !null_element)) {
if (output_ptr) output_ptr = detail::copy_string(output_ptr, separator);
size_bytes += separator.size_bytes();
write_separator = false;
}
auto const d_str =
null_element ? string_narep_dv.value() : strings_dv.element<string_view>(str_idx);
if (output_ptr) output_ptr = detail::copy_string(output_ptr, d_str);
size_bytes += d_str.size_bytes();
write_separator =
write_separator || (separate_nulls == separator_on_nulls::YES) || !null_element;
}
// If there are all null elements, the output should be the same as having an empty list input:
// a null or an empty string
if (!d_chars) { d_offsets[idx] = has_valid_element ? size_bytes : 0; }
}
};
/**
* @brief Functor accompanying with `compute_size_and_concatenate_fn` for computing output string
* sizes, output string validities, and concatenating strings within list elements; used when the
* separator is a string scalar.
*/
struct scalar_separator_fn {
string_scalar_device_view const d_separator;
[[nodiscard]] __device__ bool is_null_list(column_device_view const& lists_dv,
size_type const idx) const noexcept
{
return lists_dv.is_null(idx);
}
[[nodiscard]] __device__ string_view separator(size_type const) const noexcept
{
return d_separator.value();
}
};
template <typename CompFn>
struct validities_fn {
CompFn comp_fn;
validities_fn(CompFn comp_fn) : comp_fn(comp_fn) {}
__device__ bool operator()(size_type idx)
{
auto const start_idx = comp_fn.list_offsets[idx];
auto const end_idx = comp_fn.list_offsets[idx + 1];
bool valid_output = !comp_fn.output_is_null(idx, start_idx, end_idx);
if (valid_output) {
bool check_elements = false;
for (size_type str_idx = start_idx; str_idx < end_idx; ++str_idx) {
bool const valid_element = comp_fn.strings_dv.is_valid(str_idx);
check_elements = check_elements || valid_element;
// if an element is null and narep is invalid, the output row is null
if (!valid_element && !comp_fn.string_narep_dv.is_valid()) { return false; }
}
// handle empty-list-as-null output policy setting
valid_output =
check_elements || comp_fn.empty_list_policy == output_if_empty_list::EMPTY_STRING;
}
return valid_output;
}
};
} // namespace
std::unique_ptr<column> join_list_elements(lists_column_view const& lists_strings_column,
string_scalar const& separator,
string_scalar const& narep,
separator_on_nulls separate_nulls,
output_if_empty_list empty_list_policy,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(lists_strings_column.child().type().id() == type_id::STRING,
"The input column must be a column of lists of strings");
CUDF_EXPECTS(separator.is_valid(stream), "Parameter separator must be a valid string_scalar");
auto const num_rows = lists_strings_column.size();
if (num_rows == 0) { return make_empty_column(type_id::STRING); }
// Accessing the child strings column of the lists column must be done by calling `child()` on the
// lists column, not `get_sliced_child()`. This is because calling to `offsets_begin()` on the
// lists column returns a pointer to the offsets of the original lists column, which may not start
// from `0`.
auto const strings_col = strings_column_view(lists_strings_column.child());
auto const lists_dv_ptr = column_device_view::create(lists_strings_column.parent(), stream);
auto const strings_dv_ptr = column_device_view::create(strings_col.parent(), stream);
auto const sep_dv = get_scalar_device_view(const_cast<string_scalar&>(separator));
auto const string_narep_dv = get_scalar_device_view(const_cast<string_scalar&>(narep));
auto const func = scalar_separator_fn{sep_dv};
auto const comp_fn =
compute_size_and_concatenate_fn<decltype(func)>{func,
*lists_dv_ptr,
lists_strings_column.offsets_begin(),
*strings_dv_ptr,
string_narep_dv,
separate_nulls,
empty_list_policy};
auto [offsets_column, chars_column] = make_strings_children(comp_fn, num_rows, stream, mr);
auto [null_mask, null_count] =
cudf::detail::valid_if(thrust::counting_iterator<size_type>(0),
thrust::counting_iterator<size_type>(num_rows),
validities_fn{comp_fn},
stream,
mr);
return make_strings_column(
num_rows, std::move(offsets_column), std::move(chars_column), null_count, std::move(null_mask));
}
namespace {
/**
* @brief Functor accompanying with `compute_size_and_concatenate_fn` for computing output string
* sizes, output string validities, and concatenating strings within list elements; used when the
* separators are given as a strings column.
*/
struct column_separators_fn {
column_device_view const separators_dv;
string_scalar_device_view const sep_narep_dv;
[[nodiscard]] __device__ bool is_null_list(column_device_view const& lists_dv,
size_type const idx) const noexcept
{
return lists_dv.is_null(idx) || (separators_dv.is_null(idx) && !sep_narep_dv.is_valid());
}
[[nodiscard]] __device__ string_view separator(size_type const idx) const noexcept
{
return separators_dv.is_valid(idx) ? separators_dv.element<string_view>(idx)
: sep_narep_dv.value();
}
};
} // namespace
std::unique_ptr<column> join_list_elements(lists_column_view const& lists_strings_column,
strings_column_view const& separators,
string_scalar const& separator_narep,
string_scalar const& string_narep,
separator_on_nulls separate_nulls,
output_if_empty_list empty_list_policy,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(lists_strings_column.child().type().id() == type_id::STRING,
"The input column must be a column of lists of strings");
CUDF_EXPECTS(lists_strings_column.size() == separators.size(),
"Separators column should be the same size as the lists columns");
auto const num_rows = lists_strings_column.size();
if (num_rows == 0) { return make_empty_column(type_id::STRING); }
// Accessing the child strings column of the lists column must be done by calling `child()` on the
// lists column, not `get_sliced_child()`. This is because calling to `offsets_begin()` on the
// lists column returns a pointer to the offsets of the original lists column, which may not start
// from `0`.
auto const strings_col = strings_column_view(lists_strings_column.child());
auto const lists_dv_ptr = column_device_view::create(lists_strings_column.parent(), stream);
auto const strings_dv_ptr = column_device_view::create(strings_col.parent(), stream);
auto const string_narep_dv = get_scalar_device_view(const_cast<string_scalar&>(string_narep));
auto const sep_dv_ptr = column_device_view::create(separators.parent(), stream);
auto const sep_narep_dv = get_scalar_device_view(const_cast<string_scalar&>(separator_narep));
auto const func = column_separators_fn{*sep_dv_ptr, sep_narep_dv};
auto const comp_fn =
compute_size_and_concatenate_fn<decltype(func)>{func,
*lists_dv_ptr,
lists_strings_column.offsets_begin(),
*strings_dv_ptr,
string_narep_dv,
separate_nulls,
empty_list_policy};
auto [offsets_column, chars_column] = make_strings_children(comp_fn, num_rows, stream, mr);
auto [null_mask, null_count] =
cudf::detail::valid_if(thrust::counting_iterator<size_type>(0),
thrust::counting_iterator<size_type>(num_rows),
validities_fn{comp_fn},
stream,
mr);
return make_strings_column(
num_rows, std::move(offsets_column), std::move(chars_column), null_count, std::move(null_mask));
}
} // namespace detail
std::unique_ptr<column> join_list_elements(lists_column_view const& lists_strings_column,
string_scalar const& separator,
string_scalar const& narep,
separator_on_nulls separate_nulls,
output_if_empty_list empty_list_policy,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::join_list_elements(
lists_strings_column, separator, narep, separate_nulls, empty_list_policy, stream, mr);
}
std::unique_ptr<column> join_list_elements(lists_column_view const& lists_strings_column,
strings_column_view const& separators,
string_scalar const& separator_narep,
string_scalar const& string_narep,
separator_on_nulls separate_nulls,
output_if_empty_list empty_list_policy,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::join_list_elements(lists_strings_column,
separators,
separator_narep,
string_narep,
separate_nulls,
empty_list_policy,
stream,
mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/convert/convert_integers.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/integer_utils.hpp>
#include <cudf/strings/convert/convert_integers.hpp>
#include <cudf/strings/detail/convert/int_to_string.cuh>
#include <cudf/strings/detail/convert/string_to_int.cuh>
#include <cudf/strings/detail/converters.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/logical.h>
#include <thrust/pair.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief This only checks if a string is a valid integer within the bounds of its storage type.
*/
template <typename IntegerType>
struct string_to_integer_check_fn {
__device__ bool operator()(thrust::pair<string_view, bool> const& p) const
{
if (!p.second || p.first.empty()) { return false; }
auto const d_str = p.first.data();
if (d_str[0] == '-' && std::is_unsigned_v<IntegerType>) { return false; }
auto iter = d_str + static_cast<int>((d_str[0] == '-' || d_str[0] == '+'));
auto const iter_end = d_str + p.first.size_bytes();
if (iter == iter_end) { return false; }
auto const sign = d_str[0] == '-' ? IntegerType{-1} : IntegerType{1};
auto const bound_val =
sign > 0 ? std::numeric_limits<IntegerType>::max() : std::numeric_limits<IntegerType>::min();
IntegerType value = 0; // parse the string to integer and check for overflow along the way
while (iter != iter_end) { // check all bytes for valid characters
auto const chr = *iter++;
// Check for valid character
if (chr < '0' || chr > '9') { return false; }
// Check for underflow and overflow:
auto const digit = static_cast<IntegerType>(chr - '0');
auto const bound_check = (bound_val - sign * digit) / IntegerType{10} * sign;
if (value > bound_check) return false;
value = value * IntegerType{10} + digit;
}
return true;
}
};
/**
* @brief Returns `true` if all characters in the string
* are valid for conversion to an integer.
*
* Valid characters are in [-+0-9]. The sign character (+/-)
* is optional but if present must be the first character.
* An empty string returns `false`.
* No bounds checking is performed to verify if the integer will fit
* within a specific integer type.
*
* @param d_str String to check.
* @return true if string has valid integer characters
*/
inline __device__ bool is_integer(string_view const& d_str)
{
if (d_str.empty()) return false;
auto const end = d_str.end();
auto begin = d_str.begin();
if (*begin == '+' || *begin == '-') ++begin;
return (begin < end) && thrust::all_of(thrust::seq, begin, end, [] __device__(auto chr) {
return chr >= '0' && chr <= '9';
});
}
/**
* @brief The dispatch functions for checking if strings are valid integers.
*/
struct dispatch_is_integer_fn {
template <typename T, std::enable_if_t<cudf::is_integral_not_bool<T>()>* = nullptr>
std::unique_ptr<column> operator()(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr) const
{
auto const d_column = column_device_view::create(input.parent(), stream);
auto results = make_numeric_column(data_type{type_id::BOOL8},
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto d_results = results->mutable_view().data<bool>();
if (input.has_nulls()) {
thrust::transform(rmm::exec_policy(stream),
d_column->pair_begin<string_view, true>(),
d_column->pair_end<string_view, true>(),
d_results,
string_to_integer_check_fn<T>{});
} else {
thrust::transform(rmm::exec_policy(stream),
d_column->pair_begin<string_view, false>(),
d_column->pair_end<string_view, false>(),
d_results,
string_to_integer_check_fn<T>{});
}
// Calling mutable_view() on a column invalidates it's null count so we need to set it back
results->set_null_count(input.null_count());
return results;
}
template <typename T, std::enable_if_t<not cudf::is_integral_not_bool<T>()>* = nullptr>
std::unique_ptr<column> operator()(strings_column_view const&,
rmm::cuda_stream_view,
rmm::mr::device_memory_resource*) const
{
CUDF_FAIL("is_integer is expecting an integer type");
}
};
} // namespace
std::unique_ptr<column> is_integer(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto const d_column = column_device_view::create(input.parent(), stream);
auto results = make_numeric_column(data_type{type_id::BOOL8},
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto d_results = results->mutable_view().data<bool>();
if (input.has_nulls()) {
thrust::transform(
rmm::exec_policy(stream),
d_column->pair_begin<string_view, true>(),
d_column->pair_end<string_view, true>(),
d_results,
[] __device__(auto const& p) { return p.second ? is_integer(p.first) : false; });
} else {
thrust::transform(rmm::exec_policy(stream),
d_column->pair_begin<string_view, false>(),
d_column->pair_end<string_view, false>(),
d_results,
[] __device__(auto const& p) { return is_integer(p.first); });
}
// Calling mutable_view() on a column invalidates it's null count so we need to set it back
results->set_null_count(input.null_count());
return results;
}
std::unique_ptr<column> is_integer(strings_column_view const& input,
data_type int_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) { return cudf::make_empty_column(type_id::BOOL8); }
return type_dispatcher(int_type, dispatch_is_integer_fn{}, input, stream, mr);
}
} // namespace detail
// external APIs
std::unique_ptr<column> is_integer(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::is_integer(input, stream, mr);
}
std::unique_ptr<column> is_integer(strings_column_view const& input,
data_type int_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::is_integer(input, int_type, stream, mr);
}
namespace detail {
namespace {
/**
* @brief Converts strings into an integers.
*
* Used by the dispatch method to convert to different integer types.
*/
template <typename IntegerType>
struct string_to_integer_fn {
column_device_view const strings_column; // strings to convert
__device__ IntegerType operator()(size_type idx)
{
if (strings_column.is_null(idx)) return static_cast<IntegerType>(0);
// the cast to IntegerType will create predictable results
// for integers that are larger than the IntegerType can hold
return static_cast<IntegerType>(string_to_integer(strings_column.element<string_view>(idx)));
}
};
/**
* @brief The dispatch functions for converting strings to integers.
*
* The output_column is expected to be one of the integer types only.
*/
struct dispatch_to_integers_fn {
template <typename IntegerType,
std::enable_if_t<cudf::is_integral_not_bool<IntegerType>()>* = nullptr>
void operator()(column_device_view const& strings_column,
mutable_column_view& output_column,
rmm::cuda_stream_view stream) const
{
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_column.size()),
output_column.data<IntegerType>(),
string_to_integer_fn<IntegerType>{strings_column});
}
// non-integer types throw an exception
template <typename T, std::enable_if_t<not cudf::is_integral_not_bool<T>()>* = nullptr>
void operator()(column_device_view const&, mutable_column_view&, rmm::cuda_stream_view) const
{
CUDF_FAIL("Output for to_integers must be an integer type.");
}
};
} // namespace
// This will convert a strings column into any integer column type.
std::unique_ptr<column> to_integers(strings_column_view const& input,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = input.size();
if (strings_count == 0) return make_numeric_column(output_type, 0);
// Create integer output column copying the strings null-mask
auto results = make_numeric_column(output_type,
strings_count,
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
// Fill output column with integers
auto const strings_dev_view = column_device_view::create(input.parent(), stream);
auto results_view = results->mutable_view();
type_dispatcher(output_type, dispatch_to_integers_fn{}, *strings_dev_view, results_view, stream);
// Calling mutable_view() on a column invalidates it's null count so we need to set it back
results->set_null_count(input.null_count());
return results;
}
} // namespace detail
// external API
std::unique_ptr<column> to_integers(strings_column_view const& input,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::to_integers(input, output_type, stream, mr);
}
namespace detail {
namespace {
template <typename IntegerType>
struct from_integers_fn {
column_device_view d_integers;
size_type* d_offsets;
char* d_chars;
/**
* @brief Converts an integer element into a string.
*
* The integer is converted into base-10 using only characters [0-9].
* No formatting is done for the string other than prepending the '-'
* character for negative values.
*/
__device__ void integer_element_to_string(size_type idx)
{
IntegerType value = d_integers.element<IntegerType>(idx);
char* d_buffer = d_chars + d_offsets[idx];
integer_to_string(value, d_buffer);
}
__device__ void operator()(size_type idx)
{
if (d_integers.is_null(idx)) {
if (d_chars == nullptr) { d_offsets[idx] = 0; }
return;
}
if (d_chars != nullptr) {
integer_element_to_string(idx);
} else {
d_offsets[idx] = count_digits(d_integers.element<IntegerType>(idx));
}
}
};
/**
* @brief This dispatch method is for converting integers into strings.
* The template function declaration ensures only integer types are used.
*/
struct dispatch_from_integers_fn {
template <typename IntegerType,
std::enable_if_t<cudf::is_integral_not_bool<IntegerType>()>* = nullptr>
std::unique_ptr<column> operator()(column_view const& integers,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr) const
{
size_type strings_count = integers.size();
auto column = column_device_view::create(integers, stream);
auto d_column = *column;
// copy the null mask
rmm::device_buffer null_mask = cudf::detail::copy_bitmask(integers, stream, mr);
auto [offsets, chars] =
make_strings_children(from_integers_fn<IntegerType>{d_column}, strings_count, stream, mr);
return make_strings_column(strings_count,
std::move(offsets),
std::move(chars),
integers.null_count(),
std::move(null_mask));
}
// non-integer types throw an exception
template <typename T, std::enable_if_t<not cudf::is_integral_not_bool<T>()>* = nullptr>
std::unique_ptr<column> operator()(column_view const&,
rmm::cuda_stream_view,
rmm::mr::device_memory_resource*) const
{
CUDF_FAIL("Values for from_integers function must be an integer type.");
}
};
} // namespace
// This will convert all integer column types into a strings column.
std::unique_ptr<column> from_integers(column_view const& integers,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = integers.size();
if (strings_count == 0) return make_empty_column(type_id::STRING);
return type_dispatcher(integers.type(), dispatch_from_integers_fn{}, integers, stream, mr);
}
} // namespace detail
// external API
std::unique_ptr<column> from_integers(column_view const& integers,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::from_integers(integers, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/convert/convert_lists.cu
|
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/convert/convert_lists.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
namespace cudf {
namespace strings {
namespace detail {
namespace {
// position of the element separator string (e.g. comma ',') within the separators column
constexpr size_type separator_index = 0;
// position of the enclosure strings (e.g. []) within the separators column
constexpr size_type left_brace_index = 1;
constexpr size_type right_brace_index = 2;
/**
* @brief Pending separator type for `stack_item`
*/
enum class item_separator : int8_t { NONE, ELEMENT, LIST };
/**
* @brief Stack item used to manage nested lists.
*
* Each item includes the current range and the pending separator.
*/
struct alignas(8) stack_item {
size_type left_idx;
size_type right_idx;
item_separator separator{item_separator::NONE};
};
/**
* @brief Formatting lists functor.
*
* This formats the input list column into individual strings using the
* specified separators and null-representation (na_rep) string.
*
* Recursion is simulated by using stack allocating per output string.
*/
struct format_lists_fn {
column_device_view const d_input;
column_device_view const d_separators;
string_view const d_na_rep;
stack_item* d_stack;
size_type const max_depth;
size_type* d_offsets{};
char* d_chars{};
__device__ column_device_view get_nested_child(size_type idx)
{
auto current = d_input;
while (idx > 0) {
current = current.child(cudf::lists_column_view::child_column_index);
--idx;
}
return current;
}
__device__ size_type write_separator(char*& d_output, size_type sep_idx = separator_index)
{
auto d_str = [&] {
if (d_separators.size() > sep_idx) return d_separators.element<string_view>(sep_idx);
if (sep_idx == left_brace_index) return string_view("[", 1);
if (sep_idx == right_brace_index) return string_view("]", 1);
return string_view(",", 1);
}();
if (d_output) d_output = copy_string(d_output, d_str);
return d_str.size_bytes();
}
__device__ size_type write_na_rep(char*& d_output)
{
if (d_output) d_output = copy_string(d_output, d_na_rep);
return d_na_rep.size_bytes();
}
__device__ size_type write_strings(column_device_view const& col,
size_type left_idx,
size_type right_idx,
char* d_output)
{
size_type bytes = 0;
for (size_type idx = left_idx; idx < right_idx; ++idx) {
if (col.is_null(idx)) {
bytes += write_na_rep(d_output); // e.g. 'NULL'
} else {
auto d_str = col.element<string_view>(idx);
if (d_output) d_output = copy_string(d_output, d_str);
bytes += d_str.size_bytes();
}
if (idx + 1 < right_idx) {
bytes += write_separator(d_output); // e.g. comma ','
}
}
return bytes;
}
__device__ void operator()(size_type idx)
{
size_type bytes = 0;
char* d_output = d_chars ? d_chars + d_offsets[idx] : nullptr;
// push first item to the stack
auto item_stack = d_stack + idx * max_depth;
auto stack_idx = size_type{0};
item_stack[stack_idx++] = stack_item{idx, idx + 1};
// process until stack is empty
while (stack_idx > 0) {
--stack_idx; // pop from stack
auto const item = item_stack[stack_idx];
auto const view = get_nested_child(stack_idx);
auto offsets = view.child(cudf::lists_column_view::offsets_column_index);
auto d_offsets = offsets.data<size_type>() + view.offset();
// add pending separator
if (item.separator == item_separator::LIST) {
bytes += write_separator(d_output, right_brace_index);
} else if (item.separator == item_separator::ELEMENT) {
bytes += write_separator(d_output, separator_index);
}
// loop through the child elements for the current view
for (auto jdx = item.left_idx; jdx < item.right_idx; ++jdx) {
auto const lhs = d_offsets[jdx];
auto const rhs = d_offsets[jdx + 1];
if (view.is_null(jdx)) {
bytes += write_na_rep(d_output); // e.g. 'NULL'
} else if (lhs == rhs) { // e.g. '[]'
bytes += write_separator(d_output, left_brace_index);
bytes += write_separator(d_output, right_brace_index);
} else {
auto child = view.child(cudf::lists_column_view::child_column_index);
bytes += write_separator(d_output, left_brace_index);
// if child is a list type, then recurse into it
if (child.type().id() == type_id::LIST) {
// push current state to the stack
item_stack[stack_idx++] =
stack_item{jdx + 1,
item.right_idx,
jdx + 1 < item.right_idx ? item_separator::ELEMENT : item_separator::LIST};
// push child to the stack
item_stack[stack_idx++] = stack_item{lhs, rhs};
break; // back to the stack (while-loop)
}
// otherwise, the child is a strings column;
// write out the string elements
auto const size = write_strings(child, lhs, rhs, d_output);
bytes += size;
if (d_output) d_output += size;
bytes += write_separator(d_output, right_brace_index);
}
// write element separator (e.g. comma ',') if not at the end
if (jdx + 1 < item.right_idx) { bytes += write_separator(d_output); }
}
}
if (!d_chars) d_offsets[idx] = bytes;
}
};
} // namespace
std::unique_ptr<column> format_list_column(lists_column_view const& input,
string_scalar const& na_rep,
strings_column_view const& separators,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) return make_empty_column(data_type{type_id::STRING});
size_type depth = 1; // count the depth to the strings column
auto child_col = input.child();
while (child_col.type().id() == type_id::LIST) {
child_col = cudf::lists_column_view(child_col).child();
++depth;
}
CUDF_EXPECTS(child_col.type().id() == type_id::STRING, "lists child must be a STRING column");
CUDF_EXPECTS(separators.size() == 0 || separators.size() == 3,
"Invalid number of separator strings");
CUDF_EXPECTS(na_rep.is_valid(stream), "Null replacement string must be valid");
// create stack memory for processing nested lists
auto stack_buffer = rmm::device_uvector<stack_item>(input.size() * depth, stream);
auto const d_input = column_device_view::create(input.parent(), stream);
auto const d_separators = column_device_view::create(separators.parent(), stream);
auto const d_na_rep = na_rep.value(stream);
auto children = cudf::strings::detail::make_strings_children(
format_lists_fn{*d_input, *d_separators, d_na_rep, stack_buffer.data(), depth},
input.size(),
stream,
mr);
return make_strings_column(
input.size(), std::move(children.first), std::move(children.second), 0, rmm::device_buffer{});
}
} // namespace detail
// external API
std::unique_ptr<column> format_list_column(lists_column_view const& input,
string_scalar const& na_rep,
strings_column_view const& separators,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::format_list_column(input, na_rep, separators, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/convert/convert_fixed_point.cu
|
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/convert/convert_fixed_point.hpp>
#include <cudf/strings/detail/convert/fixed_point.cuh>
#include <cudf/strings/detail/convert/fixed_point_to_string.cuh>
#include <cudf/strings/detail/converters.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/generate.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/optional.h>
#include <thrust/transform.h>
#include <cuda/std/climits>
#include <cuda/std/limits>
#include <cuda/std/type_traits>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Converts strings into an integers and records decimal places.
*
* The conversion uses the provided scale to build the resulting
* integer. This can prevent overflow for strings with many digits.
*/
template <typename DecimalType>
struct string_to_decimal_fn {
column_device_view const d_strings;
int32_t const scale;
string_to_decimal_fn(column_device_view const& d_strings, int32_t scale)
: d_strings(d_strings), scale(scale)
{
}
__device__ DecimalType operator()(size_type idx) const
{
if (d_strings.is_null(idx)) { return 0; }
auto const d_str = d_strings.element<string_view>(idx);
if (d_str.empty()) { return 0; }
auto iter = d_str.data();
auto const iter_end = d_str.data() + d_str.size_bytes();
return parse_decimal<DecimalType>(iter, iter_end, scale);
}
};
/**
* @brief This only checks the string format for valid decimal characters.
*
* This follows closely the logic above but just ensures there are valid
* characters for conversion and the integer component does not overflow.
*/
template <typename DecimalType>
struct string_to_decimal_check_fn {
column_device_view const d_strings;
int32_t const scale;
string_to_decimal_check_fn(column_device_view const& d_strings, int32_t scale)
: d_strings{d_strings}, scale{scale}
{
}
__device__ bool operator()(size_type idx) const
{
if (d_strings.is_null(idx)) { return false; }
auto const d_str = d_strings.element<string_view>(idx);
if (d_str.empty()) { return false; }
auto iter = d_str.data() + static_cast<int>((d_str.data()[0] == '-' || d_str.data()[0] == '+'));
auto const iter_end = d_str.data() + d_str.size_bytes();
using UnsignedDecimalType = cuda::std::make_unsigned_t<DecimalType>;
auto [value, exp_offset] = parse_integer<UnsignedDecimalType>(iter, iter_end);
// only exponent notation is expected here
if ((iter < iter_end) && (*iter != 'e' && *iter != 'E')) { return false; }
++iter;
int32_t exp_ten = 0; // check exponent overflow
if (iter < iter_end) {
auto exp_result = parse_exponent<true>(iter, iter_end);
if (!exp_result) { return false; }
exp_ten = exp_result.value();
}
exp_ten += exp_offset;
// finally, check for overflow based on the exp_ten and scale values
return (exp_ten < scale) or
value <= static_cast<UnsignedDecimalType>(
cuda::std::numeric_limits<DecimalType>::max() /
static_cast<DecimalType>(exp10(static_cast<double>(exp_ten - scale))));
}
};
/**
* @brief The dispatch function for converting strings column to fixed-point column.
*/
struct dispatch_to_fixed_point_fn {
template <typename T, std::enable_if_t<cudf::is_fixed_point<T>()>* = nullptr>
std::unique_ptr<column> operator()(strings_column_view const& input,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr) const
{
using DecimalType = device_storage_type_t<T>;
auto const d_column = column_device_view::create(input.parent(), stream);
// create output column
auto results = make_fixed_point_column(output_type,
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto d_results = results->mutable_view().data<DecimalType>();
// convert strings into decimal values
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(input.size()),
d_results,
string_to_decimal_fn<DecimalType>{*d_column, output_type.scale()});
results->set_null_count(input.null_count());
return results;
}
template <typename T, std::enable_if_t<not cudf::is_fixed_point<T>()>* = nullptr>
std::unique_ptr<column> operator()(strings_column_view const&,
data_type,
rmm::cuda_stream_view,
rmm::mr::device_memory_resource*) const
{
CUDF_FAIL("Output for to_fixed_point must be a decimal type.");
}
};
} // namespace
// This will convert a strings column into any integer column type.
std::unique_ptr<column> to_fixed_point(strings_column_view const& input,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) return make_empty_column(output_type);
return type_dispatcher(output_type, dispatch_to_fixed_point_fn{}, input, output_type, stream, mr);
}
} // namespace detail
// external API
std::unique_ptr<column> to_fixed_point(strings_column_view const& input,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::to_fixed_point(input, output_type, stream, mr);
}
namespace detail {
namespace {
template <typename DecimalType>
struct from_fixed_point_fn {
column_device_view d_decimals;
size_type* d_offsets{};
char* d_chars{};
/**
* @brief Converts a decimal element into a string.
*
* The value is converted into base-10 digits [0-9]
* plus the decimal point and a negative sign prefix.
*/
__device__ void fixed_point_element_to_string(size_type idx)
{
auto const value = d_decimals.element<DecimalType>(idx);
auto const scale = d_decimals.type().scale();
char* d_buffer = d_chars + d_offsets[idx];
fixed_point_to_string(value, scale, d_buffer);
}
__device__ void operator()(size_type idx)
{
if (d_decimals.is_null(idx)) {
if (d_chars == nullptr) { d_offsets[idx] = 0; }
return;
}
if (d_chars != nullptr) {
fixed_point_element_to_string(idx);
} else {
d_offsets[idx] =
fixed_point_string_size(d_decimals.element<DecimalType>(idx), d_decimals.type().scale());
}
}
};
/**
* @brief The dispatcher functor for converting fixed-point values into strings.
*/
struct dispatch_from_fixed_point_fn {
template <typename T, std::enable_if_t<cudf::is_fixed_point<T>()>* = nullptr>
std::unique_ptr<column> operator()(column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr) const
{
using DecimalType = device_storage_type_t<T>; // underlying value type
auto const d_column = column_device_view::create(input, stream);
auto [offsets, chars] =
make_strings_children(from_fixed_point_fn<DecimalType>{*d_column}, input.size(), stream, mr);
return make_strings_column(input.size(),
std::move(offsets),
std::move(chars),
input.null_count(),
cudf::detail::copy_bitmask(input, stream, mr));
}
template <typename T, std::enable_if_t<not cudf::is_fixed_point<T>()>* = nullptr>
std::unique_ptr<column> operator()(column_view const&,
rmm::cuda_stream_view,
rmm::mr::device_memory_resource*) const
{
CUDF_FAIL("Values for from_fixed_point function must be a decimal type.");
}
};
} // namespace
std::unique_ptr<column> from_fixed_point(column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) return make_empty_column(type_id::STRING);
return type_dispatcher(input.type(), dispatch_from_fixed_point_fn{}, input, stream, mr);
}
} // namespace detail
// external API
std::unique_ptr<column> from_fixed_point(column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::from_fixed_point(input, stream, mr);
}
namespace detail {
namespace {
struct dispatch_is_fixed_point_fn {
template <typename T, std::enable_if_t<cudf::is_fixed_point<T>()>* = nullptr>
std::unique_ptr<column> operator()(strings_column_view const& input,
data_type decimal_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr) const
{
using DecimalType = device_storage_type_t<T>;
auto const d_column = column_device_view::create(input.parent(), stream);
// create output column
auto results = make_numeric_column(data_type{type_id::BOOL8},
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto d_results = results->mutable_view().data<bool>();
// check strings for valid fixed-point chars
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(input.size()),
d_results,
string_to_decimal_check_fn<DecimalType>{*d_column, decimal_type.scale()});
results->set_null_count(input.null_count());
return results;
}
template <typename T, std::enable_if_t<not cudf::is_fixed_point<T>()>* = nullptr>
std::unique_ptr<column> operator()(strings_column_view const&,
data_type,
rmm::cuda_stream_view,
rmm::mr::device_memory_resource*) const
{
CUDF_FAIL("is_fixed_point is expecting a decimal type");
}
};
} // namespace
std::unique_ptr<column> is_fixed_point(strings_column_view const& input,
data_type decimal_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) return cudf::make_empty_column(type_id::BOOL8);
return type_dispatcher(
decimal_type, dispatch_is_fixed_point_fn{}, input, decimal_type, stream, mr);
}
} // namespace detail
std::unique_ptr<column> is_fixed_point(strings_column_view const& input,
data_type decimal_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::is_fixed_point(input, decimal_type, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/convert/convert_hex.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/convert/convert_integers.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/traits.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/distance.h>
#include <thrust/execution_policy.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/logical.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Converts hex strings into an integers.
*
* Used by the dispatch method to convert to different integer types.
*/
template <typename IntegerType>
struct hex_to_integer_fn {
column_device_view const strings_column;
/**
* @brief Converts a single hex string into an integer.
*
* Non-hexadecimal characters are ignored.
* This means it can handle "0x01A23" and "1a23".
*
* Overflow of the int64 type is not detected.
*/
__device__ int64_t string_to_integer(string_view const& d_str)
{
int64_t result = 0, base = 1;
char const* str = d_str.data();
size_type index = d_str.size_bytes();
while (index-- > 0) {
char ch = str[index];
if (ch >= '0' && ch <= '9') {
result += static_cast<int64_t>(ch - 48) * base;
base *= 16;
} else if (ch >= 'A' && ch <= 'F') {
result += static_cast<int64_t>(ch - 55) * base;
base *= 16;
} else if (ch >= 'a' && ch <= 'f') {
result += static_cast<int64_t>(ch - 87) * base;
base *= 16;
}
}
return result;
}
__device__ IntegerType operator()(size_type idx)
{
if (strings_column.is_null(idx)) return static_cast<IntegerType>(0);
// the cast to IntegerType will create predictable results
// for integers that are larger than the IntegerType can hold
return static_cast<IntegerType>(string_to_integer(strings_column.element<string_view>(idx)));
}
};
/**
* @brief The dispatch functions for converting strings to integers.
*
* The output_column is expected to be one of the integer types only.
*/
struct dispatch_hex_to_integers_fn {
template <typename IntegerType,
std::enable_if_t<cudf::is_integral_not_bool<IntegerType>()>* = nullptr>
void operator()(column_device_view const& strings_column,
mutable_column_view& output_column,
rmm::cuda_stream_view stream) const
{
auto d_results = output_column.data<IntegerType>();
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_column.size()),
d_results,
hex_to_integer_fn<IntegerType>{strings_column});
}
// non-integer types throw an exception
template <typename T, typename... Args>
std::enable_if_t<not cudf::is_integral_not_bool<T>(), void> operator()(Args&&...) const
{
CUDF_FAIL("Output for hex_to_integers must be an integer type.");
}
};
/**
* @brief Functor to convert integers to hexadecimal strings
*
* @tparam IntegerType The specific integer type to convert from.
*/
template <typename IntegerType>
struct integer_to_hex_fn {
column_device_view const d_column;
size_type* d_offsets{};
char* d_chars{};
__device__ void byte_to_hex(uint8_t byte, char* hex)
{
hex[0] = [&] {
if (byte < 16) { return '0'; }
uint8_t const nibble = byte / 16;
byte = byte - (nibble * 16);
return static_cast<char>(nibble < 10 ? '0' + nibble : 'A' + (nibble - 10));
}();
hex[1] = byte < 10 ? '0' + byte : 'A' + (byte - 10);
}
__device__ void operator()(size_type idx)
{
if (d_column.is_null(idx)) {
if (!d_chars) { d_offsets[idx] = 0; }
return;
}
// Reinterpret an integer value as a little-endian byte sequence.
// For example, 123456 becomes 0x40E2'0100
auto const value = d_column.element<IntegerType>(idx);
auto value_bytes = reinterpret_cast<uint8_t const*>(&value);
// compute the number of output bytes
int bytes = sizeof(IntegerType);
int byte_index = sizeof(IntegerType);
while ((--byte_index > 0) && (value_bytes[byte_index] & 0xFF) == 0) {
--bytes;
}
// create output
byte_index = bytes - 1;
if (d_chars) {
auto d_buffer = d_chars + d_offsets[idx];
while (byte_index >= 0) {
byte_to_hex(value_bytes[byte_index], d_buffer);
d_buffer += 2;
--byte_index;
}
} else {
d_offsets[idx] = static_cast<size_type>(bytes) * 2; // 2 hex characters per byte
}
}
};
struct dispatch_integers_to_hex_fn {
template <typename IntegerType,
std::enable_if_t<cudf::is_integral_not_bool<IntegerType>()>* = nullptr>
std::unique_ptr<column> operator()(column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr) const
{
auto const d_column = column_device_view::create(input, stream);
auto children = cudf::strings::detail::make_strings_children(
integer_to_hex_fn<IntegerType>{*d_column}, input.size(), stream, mr);
return make_strings_column(input.size(),
std::move(children.first),
std::move(children.second),
input.null_count(),
cudf::detail::copy_bitmask(input, stream, mr));
}
// non-integer types throw an exception
template <typename T, typename... Args>
std::enable_if_t<not cudf::is_integral_not_bool<T>(), std::unique_ptr<column>> operator()(
Args...) const
{
CUDF_FAIL("integers_to_hex only supports integer type columns");
}
};
} // namespace
// This will convert a strings column into any integer column type.
std::unique_ptr<column> hex_to_integers(strings_column_view const& strings,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = strings.size();
if (strings_count == 0) return make_empty_column(output_type);
auto strings_column = column_device_view::create(strings.parent(), stream);
auto d_strings = *strings_column;
// create integer output column copying the strings null-mask
auto results = make_numeric_column(output_type,
strings_count,
cudf::detail::copy_bitmask(strings.parent(), stream, mr),
strings.null_count(),
stream,
mr);
auto results_view = results->mutable_view();
// fill output column with integers
type_dispatcher(output_type, dispatch_hex_to_integers_fn{}, d_strings, results_view, stream);
results->set_null_count(strings.null_count());
return results;
}
std::unique_ptr<column> is_hex(strings_column_view const& strings,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto strings_column = column_device_view::create(strings.parent(), stream);
auto d_column = *strings_column;
// create output column
auto results = make_numeric_column(data_type{type_id::BOOL8},
strings.size(),
cudf::detail::copy_bitmask(strings.parent(), stream, mr),
strings.null_count(),
stream,
mr);
auto d_results = results->mutable_view().data<bool>();
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings.size()),
d_results,
[d_column] __device__(size_type idx) {
if (d_column.is_null(idx)) return false;
auto const d_str = d_column.element<string_view>(idx);
if (d_str.empty()) return false;
auto const starts_with_0x = [](auto const& sv) {
return sv.length() > 1 && (sv.substr(0, 2) == string_view("0x", 2) ||
sv.substr(0, 2) == string_view("0X", 2));
};
auto begin = d_str.begin() + (starts_with_0x(d_str) ? 2 : 0);
auto end = d_str.end();
return (thrust::distance(begin, end) > 0) &&
thrust::all_of(thrust::seq, begin, end, [] __device__(auto chr) {
return (chr >= '0' && chr <= '9') || (chr >= 'A' && chr <= 'F') ||
(chr >= 'a' && chr <= 'f');
});
});
results->set_null_count(strings.null_count());
return results;
}
std::unique_ptr<column> integers_to_hex(column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) { return cudf::make_empty_column(type_id::STRING); }
return type_dispatcher(input.type(), dispatch_integers_to_hex_fn{}, input, stream, mr);
}
} // namespace detail
// external API
std::unique_ptr<column> hex_to_integers(strings_column_view const& strings,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::hex_to_integers(strings, output_type, stream, mr);
}
std::unique_ptr<column> is_hex(strings_column_view const& strings,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::is_hex(strings, stream, mr);
}
std::unique_ptr<column> integers_to_hex(column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::integers_to_hex(input, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/convert/convert_durations.cu
|
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/convert/int_to_string.cuh>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/functional.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/transform.h>
#include <thrust/transform_reduce.h>
#include <map>
#include <vector>
namespace cudf {
namespace strings {
namespace detail {
namespace {
// duration components timeparts structure
struct alignas(4) duration_component {
int32_t day; //-2,147,483,648 to 2,147,483,647
int32_t subsecond; // 000000000 to 999999999
int8_t hour; // 00 to 23
int8_t minute; // 00 to 59
int8_t second; // 00 to 59
bool is_negative; // true/false
};
enum class format_char_type : int8_t {
literal, // literal char type passed through
specifier // duration format specifier
};
/**
* @brief Represents a format specifier or literal from a duration format string.
*
* Created by the format_compiler when parsing a format string.
*/
struct alignas(4) format_item {
format_char_type item_type; // specifier or literal indicator
char value; // specifier or literal value
int8_t length; // item length in bytes
static format_item new_specifier(char format_char, int8_t length)
{
return format_item{format_char_type::specifier, format_char, length};
}
static format_item new_delimiter(char literal)
{
return format_item{format_char_type::literal, literal, 1};
}
};
/**
* @brief The format_compiler parses a duration format string into a vector of
* format_items.
*
* The vector of format_items are used when parsing a string into duration
* components and when formatting a string from duration components.
*/
struct format_compiler {
std::string_view const format;
rmm::device_uvector<format_item> d_items;
format_compiler(std::string_view format, rmm::cuda_stream_view stream)
: format(format), d_items(0, stream)
{
static std::map<char, int8_t> const specifier_lengths = {
{'-', -1}, // '-' if negative
{'D', -1}, // 1 to 11 (not in std::format)
{'H', 2}, // HH
{'I', 2}, // HH
{'M', 2}, // MM
{'S', -1}, // 2 to 13 SS[.mmm][uuu][nnn] (uuu,nnn are not in std::format)
{'p', 2}, // AM/PM
{'R', 5}, // 5 HH:MM
{'T', 8}, // 8 HH:MM:SS"
{'r', 11} // HH:MM:SS AM/PM
};
std::vector<format_item> items;
auto str = format.data();
auto length = format.length();
bool negative_sign{true};
while (length > 0) {
char ch = *str++;
length--;
if (ch != '%') {
items.push_back(format_item::new_delimiter(ch));
continue;
}
CUDF_EXPECTS(length > 0, "Unfinished specifier in duration format");
ch = *str++;
length--;
if (ch == '%') // escaped % char
{
items.push_back(format_item::new_delimiter(ch));
continue;
} else if (ch == 'n') {
items.push_back(format_item::new_delimiter('\n'));
continue;
} else if (ch == 't') {
items.push_back(format_item::new_delimiter('\t'));
continue;
}
if (ch == 'O') {
CUDF_EXPECTS(*str == 'H' || *str == 'I' || *str == 'M' || *str == 'S',
"locale's alternative representation not supported for specifier: " +
std::string(1, *str));
ch = *str++;
length--;
items.push_back(format_item::new_specifier(ch, 2)); // without sign
continue;
}
CUDF_EXPECTS(specifier_lengths.find(ch) != specifier_lengths.end(),
"invalid format specifier: " + std::string(1, ch));
// negative sign should be present only once.
if (negative_sign) {
if (std::string("DHIMSRT").find_first_of(ch) != std::string::npos) {
items.push_back(format_item::new_specifier('-', specifier_lengths.at('-')));
negative_sign = false;
}
}
int8_t spec_length = specifier_lengths.at(ch);
items.push_back(format_item::new_specifier(ch, spec_length));
}
// create program in device memory
d_items.resize(items.size(), stream);
CUDF_CUDA_TRY(cudaMemcpyAsync(d_items.data(),
items.data(),
items.size() * sizeof(items[0]),
cudaMemcpyDefault,
stream.value()));
}
format_item const* compiled_format_items() { return d_items.data(); }
[[nodiscard]] size_type items_count() const { return static_cast<size_type>(d_items.size()); }
};
template <typename T>
__device__ void dissect_duration(T duration, duration_component* timeparts)
{
timeparts->is_negative = (duration < T{0});
timeparts->day = cuda::std::chrono::duration_cast<duration_D>(duration).count();
if (cuda::std::is_same_v<T, duration_D>) return;
duration_s seconds = cuda::std::chrono::duration_cast<duration_s>(duration);
timeparts->hour =
(cuda::std::chrono::duration_cast<cuda::std::chrono::hours>(seconds) % duration_D(1)).count();
timeparts->minute = (cuda::std::chrono::duration_cast<cuda::std::chrono::minutes>(seconds) %
cuda::std::chrono::hours(1))
.count();
timeparts->second = (seconds % cuda::std::chrono::minutes(1)).count();
if (not cuda::std::is_same_v<T, duration_s>) {
timeparts->subsecond = (duration % duration_s(1)).count();
}
}
namespace {
template <typename T>
struct from_durations_fn {
column_device_view d_durations;
format_item const* d_format_items;
size_type items_count;
size_type* d_offsets{};
char* d_chars{};
__device__ int8_t format_length(char format_char, duration_component const* const timeparts) const
{
switch (format_char) {
case '-': return timeparts->is_negative; break;
case 'D': return count_digits(timeparts->day) - (timeparts->day < 0); break;
case 'S':
return 2 + (timeparts->subsecond == 0 ? 0 : [] {
if (cuda::std::is_same_v<T, duration_ms>) return 3 + 1; // +1 is for dot
if (cuda::std::is_same_v<T, duration_us>) return 6 + 1; // +1 is for dot
if (cuda::std::is_same_v<T, duration_ns>) return 9 + 1; // +1 is for dot
return 0;
}());
break;
default: return 2;
}
}
// utility to create (optionally) 0-padded integers (up to 10 chars) without negative sign.
// min_digits==-1 indicates no 0-padding.
__device__ char* int2str(char* str, int min_digits, int32_t value)
{
constexpr int MAX_DIGITS = 10; // largest 32-bit integer is 10 digits
assert(min_digits <= MAX_DIGITS);
if (value == 0) {
do {
*str++ = '0';
} while (--min_digits > 0);
return str;
}
char digits[MAX_DIGITS] = {'0', '0', '0', '0', '0', '0', '0', '0', '0', '0'};
int digits_idx = 0;
while (value != 0) {
assert(digits_idx < MAX_DIGITS);
digits[digits_idx++] = '0' + std::abs(value % 10);
// next digit
value = value / 10;
}
digits_idx = std::max(digits_idx, min_digits);
// digits are backwards, reverse the string into the output
while (digits_idx-- > 0)
*str++ = digits[digits_idx];
return str;
}
__device__ char* int_to_2digitstr(char* str, int8_t value)
{
assert(value >= -99 && value <= 99);
value = std::abs(value);
str[0] = '0' + value / 10;
str[1] = '0' + value % 10;
return str + 2;
}
inline __device__ char* day(char* ptr, duration_component const* timeparts)
{
return int2str(ptr, -1, timeparts->day);
}
inline __device__ char* hour_12(char* ptr, duration_component const* timeparts)
{
return int_to_2digitstr(ptr, timeparts->hour % 12);
}
inline __device__ char* hour_24(char* ptr, duration_component const* timeparts)
{
return int_to_2digitstr(ptr, timeparts->hour);
}
inline __device__ char* am_or_pm(char* ptr, duration_component const* timeparts)
{
*ptr++ = (timeparts->hour / 12 == 0 ? 'A' : 'P');
*ptr++ = 'M';
return ptr;
}
inline __device__ char* minute(char* ptr, duration_component const* timeparts)
{
return int_to_2digitstr(ptr, timeparts->minute);
}
inline __device__ char* second(char* ptr, duration_component const* timeparts)
{
return int_to_2digitstr(ptr, timeparts->second);
}
inline __device__ char* subsecond(char* ptr, duration_component const* timeparts)
{
if (timeparts->subsecond == 0) return ptr;
int const digits = format_length('S', timeparts) - 3;
*ptr = '.';
auto value = timeparts->subsecond;
for (int idx = digits; idx > 0; idx--) {
*(ptr + idx) = '0' + std::abs(value % 10);
value /= 10;
}
return ptr + digits + 1;
}
__device__ char* format_from_parts(duration_component const* timeparts, char* ptr)
{
for (size_t idx = 0; idx < items_count; ++idx) {
auto item = d_format_items[idx];
if (item.item_type == format_char_type::literal) {
*ptr++ = item.value;
continue;
}
// special logic for each specifier
switch (item.value) {
case 'D': // days
ptr = day(ptr, timeparts);
break;
case '-': // - if value is negative
if (timeparts->is_negative) *ptr++ = '-';
break;
case 'H': // 24-hour
ptr = hour_24(ptr, timeparts);
break;
case 'I': // 12-hour
ptr = hour_12(ptr, timeparts);
break;
case 'M': // minute
ptr = minute(ptr, timeparts);
break;
case 'S': // second
ptr = second(ptr, timeparts);
if (item.length == 2) break;
case 'f': // sub-second
ptr = subsecond(ptr, timeparts);
break;
case 'p': ptr = am_or_pm(ptr, timeparts); break;
case 'R': // HH:MM 24-hour
ptr = hour_24(ptr, timeparts);
*ptr++ = ':';
ptr = minute(ptr, timeparts);
break;
case 'T': // HH:MM:SS 24-hour
ptr = hour_24(ptr, timeparts);
*ptr++ = ':';
ptr = minute(ptr, timeparts);
*ptr++ = ':';
ptr = second(ptr, timeparts);
break;
case 'r': // HH:MM:SS AM/PM 12-hour
ptr = hour_12(ptr, timeparts);
*ptr++ = ':';
ptr = minute(ptr, timeparts);
*ptr++ = ':';
ptr = second(ptr, timeparts);
*ptr++ = ' ';
ptr = am_or_pm(ptr, timeparts);
break;
default: // ignore everything else
break;
}
}
return ptr;
}
__device__ size_type string_size(T duration)
{
duration_component timeparts = {0}; // days, hours, minutes, seconds, subseconds(9)
dissect_duration(duration, &timeparts);
return thrust::transform_reduce(
thrust::seq,
d_format_items,
d_format_items + items_count,
[this, &timeparts] __device__(format_item item) -> size_type {
if (item.item_type == format_char_type::literal) { return 1; }
return (item.length != -1) ? item.length : format_length(item.value, &timeparts);
},
size_type{0},
thrust::plus<size_type>());
}
__device__ void set_chars(size_type idx)
{
auto duration = d_durations.template element<T>(idx);
duration_component timeparts = {0}; // days, hours, minutes, seconds, subseconds(9)
dissect_duration(duration, &timeparts);
// convert to characters
format_from_parts(&timeparts, d_chars + d_offsets[idx]);
}
__device__ void operator()(size_type idx)
{
if (d_durations.is_null(idx)) {
if (d_chars == nullptr) { d_offsets[idx] = 0; }
return;
}
if (d_chars != nullptr) {
set_chars(idx);
} else {
d_offsets[idx] = string_size(d_durations.template element<T>(idx));
}
}
};
} // namespace
/**
* @brief This dispatch method is for converting durations into strings.
*
* The template function declaration ensures only duration types are used.
*/
struct dispatch_from_durations_fn {
template <typename T, std::enable_if_t<cudf::is_duration<T>()>* = nullptr>
std::unique_ptr<column> operator()(column_view const& durations,
std::string_view format,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr) const
{
CUDF_EXPECTS(!format.empty(), "Format parameter must not be empty.");
format_compiler compiler(format, stream);
auto d_format_items = compiler.compiled_format_items();
size_type strings_count = durations.size();
auto column = column_device_view::create(durations, stream);
auto d_column = *column;
// copy null mask
rmm::device_buffer null_mask = cudf::detail::copy_bitmask(durations, stream, mr);
auto [offsets, chars] =
make_strings_children(from_durations_fn<T>{d_column, d_format_items, compiler.items_count()},
strings_count,
stream,
mr);
return make_strings_column(strings_count,
std::move(offsets),
std::move(chars),
durations.null_count(),
std::move(null_mask));
}
// non-duration types throw an exception
template <typename T, typename... Args>
std::enable_if_t<not cudf::is_duration<T>(), std::unique_ptr<column>> operator()(Args&&...) const
{
CUDF_FAIL("Values for from_durations function must be a duration type.");
}
};
static const __device__ __constant__ int32_t powers_of_ten[10] = {
1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L, 1000000000L};
// this parses duration string into a duration integer
template <typename T> // duration type
struct parse_duration {
column_device_view const d_strings;
format_item const* d_format_items;
size_type items_count;
// function to parse string (maximum 10 digits) to integer.
__device__ int32_t str2int(char const* str, int8_t max_bytes, int8_t& actual_length)
{
char const* ptr = (*str == '-' || *str == '+') ? str + 1 : str;
int32_t value = 0;
for (int8_t idx = 0; idx < max_bytes; ++idx) {
char chr = *ptr++;
if (chr < '0' || chr > '9') {
ptr--; // roll back
break;
}
value = (value * 10) + static_cast<int32_t>(chr - '0');
}
actual_length += (ptr - str);
return (*str == '-') ? -value : value;
}
// function to parse fraction of decimal value with trailing zeros removed.
__device__ int32_t str2int_fixed(char const* str,
int8_t fixed_width,
size_type string_length,
int8_t& actual_length)
{
char const* ptr = (*str == '.') ? str + 1 : str;
int32_t value = 0;
// parse till fixed_width or end of string.
for (int8_t idx = 0; idx < fixed_width && idx < string_length; ++idx) {
char chr = *ptr++;
if (chr < '0' || chr > '9') {
ptr--; // roll back
break;
}
value = (value * 10) + static_cast<int32_t>(chr - '0');
}
auto parsed_length = ptr - str;
// compensate for missing trailing zeros
if (parsed_length < fixed_width) value *= powers_of_ten[fixed_width - parsed_length];
actual_length += parsed_length;
return value;
}
// parse 2 digit string to integer
__device__ int8_t parse_2digit_int(char const* str, int8_t& actual_length)
{
char const* ptr = (*str == '-' || *str == '+') ? str + 1 : str;
int8_t value = 0;
if (*ptr >= '0' && *ptr <= '9') value = (value * 10) + static_cast<int32_t>(*ptr++ - '0');
if (*ptr >= '0' && *ptr <= '9') value = (value * 10) + static_cast<int32_t>(*ptr++ - '0');
actual_length += (ptr - str);
return (*str == '-') ? -value : value;
}
inline __device__ int8_t parse_hour(char const* str, int8_t& actual_length)
{
return parse_2digit_int(str, actual_length);
}
inline __device__ int8_t parse_minute(char const* str, int8_t& actual_length)
{
return parse_2digit_int(str, actual_length);
}
inline __device__ int8_t parse_second(char const* str, int8_t& actual_length)
{
return parse_2digit_int(str, actual_length);
}
// Walk the format_items to read the datetime string.
// Returns 0 if all ok.
__device__ int parse_into_parts(string_view const& d_string, duration_component* timeparts)
{
auto ptr = d_string.data();
auto length = d_string.size_bytes();
int8_t hour_shift{0};
for (size_type idx = 0; idx < items_count; ++idx) {
auto item = d_format_items[idx];
if (length < item.length) return 1;
if (item.item_type == format_char_type::literal) { // static character we'll just skip;
// consume item.length bytes from string
ptr += item.length;
length -= item.length;
continue;
}
timeparts->is_negative |= (*ptr == '-');
// special logic for each specifier
int8_t item_length{0};
switch (item.value) {
case 'D': // day
timeparts->day = str2int(ptr, 11, item_length);
break;
case '-': // skip
item_length = (*ptr == '-');
break;
case 'H': // 24-hour
timeparts->hour = parse_hour(ptr, item_length);
hour_shift = 0;
break;
case 'I': // 12-hour
timeparts->hour = parse_hour(ptr, item_length);
break;
case 'M': // minute
timeparts->minute = parse_minute(ptr, item_length);
break;
case 'S': // [-]SS[.mmm][uuu][nnn]
timeparts->second = parse_second(ptr, item_length);
if ((item_length < length) && *(ptr + item_length) == '.') {
item_length++;
int64_t nanoseconds = str2int_fixed(
ptr + item_length, 9, length - item_length, item_length); // normalize to nanoseconds
timeparts->subsecond = nanoseconds;
}
break;
case 'p': // AM/PM
if (*ptr == 'P' && *(ptr + 1) == 'M')
hour_shift = 12;
else
hour_shift = 0;
item_length = 2;
break;
case 'R': // [-]HH:SS
timeparts->hour = parse_hour(ptr, item_length);
hour_shift = 0;
item_length++; // :
timeparts->minute = parse_minute(ptr + item_length, item_length);
break;
case 'T': // [-]HH:MM:SS
timeparts->hour = parse_hour(ptr, item_length);
hour_shift = 0;
item_length++; // :
timeparts->minute = parse_minute(ptr + item_length, item_length);
item_length++; // :
timeparts->second = parse_second(ptr + item_length, item_length);
break;
case 'r': // hh:MM:SS AM/PM
timeparts->hour = parse_hour(ptr, item_length);
item_length++; // :
timeparts->minute = parse_minute(ptr + item_length, item_length);
item_length++; // :
timeparts->second = parse_second(ptr + item_length, item_length);
item_length++; // space
if (*(ptr + item_length) == 'P' && *(ptr + item_length + 1) == 'M')
hour_shift = 12;
else
hour_shift = 0;
item_length += 2;
break;
default: return 3;
}
ptr += item_length;
length -= item_length;
}
// negate all if duration has negative sign
if (timeparts->is_negative) {
auto negate = [](auto i) { return (i < 0 ? i : -i); };
timeparts->day = negate(timeparts->day);
timeparts->hour = negate(timeparts->hour);
timeparts->minute = negate(timeparts->minute);
timeparts->second = negate(timeparts->second);
timeparts->subsecond = negate(timeparts->subsecond);
hour_shift = -hour_shift;
}
timeparts->hour += hour_shift;
return 0;
}
inline __device__ int64_t duration_from_parts(duration_component const* timeparts)
{
int32_t days = timeparts->day;
auto hour = timeparts->hour;
auto minute = timeparts->minute;
auto second = timeparts->second;
auto duration = duration_D(days) + cuda::std::chrono::hours(hour) +
cuda::std::chrono::minutes(minute) + duration_s(second);
if (cuda::std::is_same_v<T, duration_D>)
return cuda::std::chrono::duration_cast<duration_D>(duration).count();
else if (cuda::std::is_same_v<T, duration_s>)
return cuda::std::chrono::duration_cast<duration_s>(duration).count();
duration_ns subsecond(timeparts->subsecond); // ns
if (cuda::std::is_same_v<T, duration_ms>) {
return cuda::std::chrono::duration_cast<duration_ms>(duration + subsecond).count();
} else if (cuda::std::is_same_v<T, duration_us>) {
return cuda::std::chrono::duration_cast<duration_us>(duration + subsecond).count();
} else if (cuda::std::is_same_v<T, duration_ns>)
return cuda::std::chrono::duration_cast<duration_ns>(duration + subsecond).count();
return cuda::std::chrono::duration_cast<duration_ns>(duration + subsecond).count();
}
__device__ T operator()(size_type idx)
{
if (d_strings.is_null(idx)) return T{0};
string_view d_str = d_strings.element<string_view>(idx);
if (d_str.empty()) return T{0};
//
duration_component timeparts = {0};
if (parse_into_parts(d_str, &timeparts)) return T{0}; // unexpected parse case
//
return static_cast<T>(duration_from_parts(&timeparts));
}
};
/**
* @brief This dispatch method is for converting strings to durations.
*
* The template function declaration ensures only duration types are used.
*/
struct dispatch_to_durations_fn {
template <typename T, std::enable_if_t<cudf::is_duration<T>()>* = nullptr>
void operator()(column_device_view const& d_strings,
std::string_view format,
mutable_column_view& results_view,
rmm::cuda_stream_view stream) const
{
format_compiler compiler(format, stream);
auto d_items = compiler.compiled_format_items();
auto d_results = results_view.data<T>();
parse_duration<T> pfn{d_strings, d_items, compiler.items_count()};
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(results_view.size()),
d_results,
pfn);
}
template <typename T, std::enable_if_t<not cudf::is_duration<T>()>* = nullptr>
void operator()(column_device_view const&,
std::string_view,
mutable_column_view&,
rmm::cuda_stream_view) const
{
CUDF_FAIL("Only durations type are expected for to_durations function");
}
};
} // namespace
std::unique_ptr<column> from_durations(column_view const& durations,
std::string_view format,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = durations.size();
if (strings_count == 0) return make_empty_column(type_id::STRING);
return type_dispatcher(
durations.type(), dispatch_from_durations_fn{}, durations, format, stream, mr);
}
std::unique_ptr<column> to_durations(strings_column_view const& input,
data_type duration_type,
std::string_view format,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = input.size();
if (strings_count == 0) return make_duration_column(duration_type, 0);
CUDF_EXPECTS(!format.empty(), "Format parameter must not be empty.");
auto strings_column = column_device_view::create(input.parent(), stream);
auto d_column = *strings_column;
auto results = make_duration_column(duration_type,
strings_count,
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto results_view = results->mutable_view();
cudf::type_dispatcher(
duration_type, dispatch_to_durations_fn(), d_column, format, results_view, stream);
results->set_null_count(input.null_count());
return results;
}
} // namespace detail
std::unique_ptr<column> from_durations(column_view const& durations,
std::string_view format,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::from_durations(durations, format, stream, mr);
}
std::unique_ptr<column> to_durations(strings_column_view const& input,
data_type duration_type,
std::string_view format,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::to_durations(input, duration_type, format, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/convert/convert_ipv4.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/convert/convert_ipv4.hpp>
#include <cudf/strings/detail/convert/int_to_string.cuh>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Converts IPv4 strings into integers.
*
* Only single-byte characters are expected.
* No checking is done on the format of individual strings.
* Any character that is not [0-9] is considered a delimiter.
* This means "128-34-56-709" will parse successfully.
*/
struct ipv4_to_integers_fn {
column_device_view const d_strings;
__device__ int64_t operator()(size_type idx)
{
if (d_strings.is_null(idx)) return 0;
string_view d_str = d_strings.element<string_view>(idx);
uint32_t ipvals[4] = {0}; // IPV4 format: xxx.xxx.xxx.xxx
int32_t ipv_idx = 0;
int32_t factor = 1;
char const* in_ptr = d_str.data();
char const* end = in_ptr + d_str.size_bytes();
while ((in_ptr < end) && (ipv_idx < 4)) {
char ch = *in_ptr++;
if (ch < '0' || ch > '9') {
++ipv_idx;
factor = 1;
} else {
ipvals[ipv_idx] = (ipvals[ipv_idx] * factor) + static_cast<uint32_t>(ch - '0');
factor = 10;
}
}
uint32_t result = (ipvals[0] << 24) + (ipvals[1] << 16) + (ipvals[2] << 8) + ipvals[3];
return static_cast<int64_t>(result);
}
};
} // namespace
// Convert strings column of IPv4 addresses to integers column
std::unique_ptr<column> ipv4_to_integers(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = input.size();
if (strings_count == 0) return make_numeric_column(data_type{type_id::INT64}, 0);
auto strings_column = column_device_view::create(input.parent(), stream);
// create output column copying the strings' null-mask
auto results = make_numeric_column(data_type{type_id::INT64},
strings_count,
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto d_results = results->mutable_view().data<int64_t>();
// fill output column with ipv4 integers
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_count),
d_results,
ipv4_to_integers_fn{*strings_column});
// done
results->set_null_count(input.null_count());
return results;
}
} // namespace detail
// external API
std::unique_ptr<column> ipv4_to_integers(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::ipv4_to_integers(input, stream, mr);
}
namespace detail {
namespace {
/**
* @brief Converts integers into IPv4 addresses.
*
* Each integer is divided into 8-bit sub-integers.
* The sub-integers are converted into 1-3 character digits.
* These are placed appropriately between '.' character.
*/
struct integers_to_ipv4_fn {
column_device_view const d_column;
size_type* d_offsets{};
char* d_chars{};
__device__ void operator()(size_type idx)
{
if (d_column.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
auto const ip_number = d_column.element<int64_t>(idx);
char* out_ptr = d_chars ? d_chars + d_offsets[idx] : nullptr;
int shift_bits = 24;
size_type bytes = 3; // at least 3 dots: xxx.xxx.xxx.xxx
#pragma unroll
for (int n = 0; n < 4; ++n) {
uint8_t value = static_cast<uint8_t>((ip_number >> shift_bits) & 0x00FF);
if (out_ptr) {
out_ptr += integer_to_string(value, out_ptr);
if ((n + 1) < 4) *out_ptr++ = '.';
} else {
bytes += count_digits(value);
}
shift_bits -= 8;
}
if (!d_chars) { d_offsets[idx] = bytes; }
}
};
} // namespace
// Convert integers into IPv4 addresses
std::unique_ptr<column> integers_to_ipv4(column_view const& integers,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (integers.is_empty()) return make_empty_column(type_id::STRING);
CUDF_EXPECTS(integers.type().id() == type_id::INT64, "Input column must be type_id::INT64 type");
auto d_column = column_device_view::create(integers, stream);
auto children = cudf::strings::detail::make_strings_children(
integers_to_ipv4_fn{*d_column}, integers.size(), stream, mr);
return make_strings_column(integers.size(),
std::move(children.first),
std::move(children.second),
integers.null_count(),
cudf::detail::copy_bitmask(integers, stream, mr));
}
std::unique_ptr<column> is_ipv4(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto strings_column = column_device_view::create(input.parent(), stream);
auto d_column = *strings_column;
// create output column
auto results = make_numeric_column(data_type{type_id::BOOL8},
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto d_results = results->mutable_view().data<bool>();
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(input.size()),
d_results,
[d_column] __device__(size_type idx) {
if (d_column.is_null(idx)) return false;
auto const d_str = d_column.element<string_view>(idx);
if (d_str.empty()) return false;
constexpr int max_ip = 255; // values must be in [0,255]
int ip_vals[4] = {-1, -1, -1, -1};
int ipv_idx = 0; // index into ip_vals
for (auto const ch : d_str) {
if ((ch >= '0') && (ch <= '9')) {
auto const ip_val = ip_vals[ipv_idx];
int const new_ip_val = static_cast<int>(ch - '0') + // compute new value
(ip_val < 0 ? 0 : (10 * ip_val));
if (new_ip_val > max_ip) return false;
ip_vals[ipv_idx] = new_ip_val;
}
// here ipv_idx is incremented only when ch=='.'
else if (ch != '.' || (++ipv_idx > 3))
return false;
}
// final check for any missing values
return ip_vals[0] >= 0 && ip_vals[1] >= 0 && ip_vals[2] >= 0 &&
ip_vals[3] >= 0;
});
results->set_null_count(input.null_count());
return results;
}
} // namespace detail
// external API
std::unique_ptr<column> integers_to_ipv4(column_view const& integers,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::integers_to_ipv4(integers, stream, mr);
}
std::unique_ptr<column> is_ipv4(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::is_ipv4(input, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/convert/convert_urls.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/cuda.cuh>
#include <cudf/detail/utilities/integer_utils.hpp>
#include <cudf/strings/convert/convert_urls.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <cub/cub.cuh>
#include <thrust/scan.h>
#include <algorithm>
namespace cudf {
namespace strings {
namespace detail {
namespace {
//
// This is the functor for the url_encode() method below.
// Specific requirements are documented in custrings issue #321.
// In summary it converts mostly non-ascii characters and control characters into UTF-8 hex
// characters prefixed with '%'. For example, the space character must be converted to characters
// '%20' where the '20' indicates the hex value for space in UTF-8. Likewise, multi-byte characters
// are converted to multiple hex characters. For example, the é character is converted to characters
// '%C3%A9' where 'C3A9' is the UTF-8 bytes xc3a9 for this character.
//
struct url_encoder_fn {
column_device_view const d_strings;
size_type* d_offsets{};
char* d_chars{};
// utility to create 2-byte hex characters from single binary byte
__device__ void byte_to_hex(uint8_t byte, char* hex)
{
hex[0] = '0';
if (byte >= 16) {
uint8_t hibyte = byte / 16;
hex[0] = hibyte < 10 ? '0' + hibyte : 'A' + (hibyte - 10);
byte = byte - (hibyte * 16);
}
hex[1] = byte < 10 ? '0' + byte : 'A' + (byte - 10);
}
__device__ bool should_not_url_encode(char ch)
{
return (
(ch >= '0' && ch <= '9') || // these are the characters
(ch >= 'A' && ch <= 'Z') || // that are not to be url encoded
(ch >= 'a' &&
ch <= 'z') || // reference: docs.python.org/3/library/urllib.parse.html#urllib.parse.quote
(ch == '.') ||
(ch == '_') || (ch == '~') || (ch == '-'));
}
// main part of the functor the performs the url-encoding
__device__ void operator()(size_type idx)
{
if (d_strings.is_null(idx)) {
if (!d_chars) d_offsets[idx] = 0;
return;
}
string_view d_str = d_strings.element<string_view>(idx);
//
char* out_ptr = d_chars ? d_chars + d_offsets[idx] : nullptr;
size_type nbytes = 0;
char hex[2]; // two-byte hex max
for (auto itr = d_str.begin(); itr != d_str.end(); ++itr) {
auto ch = *itr;
if (ch < 128) {
if (should_not_url_encode(static_cast<char>(ch))) {
nbytes++;
if (out_ptr) out_ptr = copy_and_increment(out_ptr, d_str.data() + itr.byte_offset(), 1);
} else // url-encode everything else
{
nbytes += 3;
if (out_ptr) {
out_ptr = copy_and_increment(out_ptr, "%", 1); // add the '%' prefix
byte_to_hex(static_cast<uint8_t>(ch), hex); // convert to 2 hex chars
out_ptr = copy_and_increment(out_ptr, hex, 2); // add them to the output
}
}
} else // these are to be utf-8 url-encoded
{
uint8_t char_bytes[4]; // holds utf-8 bytes for one character
size_type char_width = from_char_utf8(ch, reinterpret_cast<char*>(char_bytes));
nbytes += char_width * 3; // '%' plus 2 hex chars per byte (example: é is %C3%A9)
// process each byte in this current character
for (size_type chidx = 0; out_ptr && (chidx < char_width); ++chidx) {
out_ptr = copy_and_increment(out_ptr, "%", 1); // add '%' prefix
byte_to_hex(char_bytes[chidx], hex); // convert to 2 hex chars
out_ptr = copy_and_increment(out_ptr, hex, 2); // add them to the output
}
}
}
if (!d_chars) d_offsets[idx] = nbytes;
}
};
} // namespace
//
std::unique_ptr<column> url_encode(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty()) return make_empty_column(type_id::STRING);
auto d_column = column_device_view::create(input.parent(), stream);
auto children = cudf::strings::detail::make_strings_children(
url_encoder_fn{*d_column}, input.size(), stream, mr);
return make_strings_column(input.size(),
std::move(children.first),
std::move(children.second),
input.null_count(),
cudf::detail::copy_bitmask(input.parent(), stream, mr));
}
} // namespace detail
// external API
std::unique_ptr<column> url_encode(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::url_encode(input, stream, mr);
}
namespace detail {
namespace {
// utility to convert a hex char into a single byte
constexpr uint8_t hex_char_to_byte(char ch)
{
if (ch >= '0' && ch <= '9') return (ch - '0');
if (ch >= 'A' && ch <= 'F') return (ch - 'A' + 10); // in hex A=10,B=11,...,F=15
if (ch >= 'a' && ch <= 'f') return (ch - 'a' + 10); // same for lower case
return 0;
}
constexpr bool is_hex_digit(char ch)
{
return (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f');
}
__forceinline__ __device__ bool is_escape_char(char const* const ptr)
{
return (ptr[0] == '%' && is_hex_digit(ptr[1]) && is_hex_digit(ptr[2]));
}
// helper function for converting an escaped sequence starting at `ptr` to a single byte
__forceinline__ __device__ char escaped_sequence_to_byte(char const* const ptr)
{
return (hex_char_to_byte(ptr[1]) << 4) | hex_char_to_byte(ptr[2]);
}
/**
* @brief Count the number of characters of each string after URL decoding.
*
* @tparam num_warps_per_threadblock Number of warps in a threadblock. This template argument must
* match the launch configuration, i.e. the kernel must be launched with
* `num_warps_per_threadblock * cudf::detail::warp_size` threads per threadblock.
* @tparam char_block_size Number of characters which will be loaded into the shared memory at a
* time.
*
* @param[in] in_strings Input string column.
* @param[out] out_counts Number of characters in each decode URL.
*/
template <size_type num_warps_per_threadblock, size_type char_block_size>
__global__ void url_decode_char_counter(column_device_view const in_strings,
size_type* const out_counts)
{
constexpr int halo_size = 2;
__shared__ char temporary_buffer[num_warps_per_threadblock][char_block_size + halo_size];
__shared__ typename cub::WarpReduce<int8_t>::TempStorage cub_storage[num_warps_per_threadblock];
auto const global_thread_id = cudf::detail::grid_1d::global_thread_id();
auto const global_warp_id = static_cast<size_type>(global_thread_id / cudf::detail::warp_size);
auto const local_warp_id = static_cast<size_type>(threadIdx.x / cudf::detail::warp_size);
auto const warp_lane = static_cast<size_type>(threadIdx.x % cudf::detail::warp_size);
auto const nwarps = static_cast<size_type>(gridDim.x * blockDim.x / cudf::detail::warp_size);
char* in_chars_shared = temporary_buffer[local_warp_id];
// Loop through strings, and assign each string to a warp.
for (thread_index_type tidx = global_warp_id; tidx < in_strings.size(); tidx += nwarps) {
auto const row_idx = static_cast<size_type>(tidx);
if (in_strings.is_null(row_idx)) {
out_counts[row_idx] = 0;
continue;
}
auto const in_string = in_strings.element<string_view>(row_idx);
auto const in_chars = in_string.data();
auto const string_length = in_string.size_bytes();
auto const nblocks = cudf::util::div_rounding_up_unsafe(string_length, char_block_size);
size_type escape_char_count = 0;
for (size_type block_idx = 0; block_idx < nblocks; block_idx++) {
auto const string_length_block =
std::min(char_block_size, string_length - char_block_size * block_idx);
// Each warp collectively loads input characters of the current block to the shared memory.
// When testing whether a location is the start of an escaped character, we need to access
// the current location as well as the next two locations. To avoid branches, two halo cells
// are added after the end of the block. If the cell is beyond the end of the string, 0s are
// filled in to make sure the last two characters of the string are not the start of an
// escaped sequence.
for (auto char_idx = warp_lane; char_idx < string_length_block + halo_size;
char_idx += cudf::detail::warp_size) {
auto const in_idx = block_idx * char_block_size + char_idx;
in_chars_shared[char_idx] = in_idx < string_length ? in_chars[in_idx] : 0;
}
__syncwarp();
// `char_idx_start` represents the start character index of the current warp.
for (size_type char_idx_start = 0; char_idx_start < string_length_block;
char_idx_start += cudf::detail::warp_size) {
auto const char_idx = char_idx_start + warp_lane;
int8_t const is_ichar_escape_char =
(char_idx < string_length_block && is_escape_char(in_chars_shared + char_idx)) ? 1 : 0;
// Warp-wise reduction to calculate the number of escape characters.
// All threads in the warp participate in the reduction, even if `char_idx` is beyond
// `string_length_block`.
int8_t const total_escape_char =
cub::WarpReduce<int8_t>(cub_storage[local_warp_id]).Sum(is_ichar_escape_char);
if (warp_lane == 0) { escape_char_count += total_escape_char; }
__syncwarp();
}
}
// URL decoding replaces 3 bytes with 1 for each escape character.
if (warp_lane == 0) { out_counts[row_idx] = string_length - escape_char_count * 2; }
}
}
/**
* @brief Decode and copy from the input string column to the output char buffer.
*
* @tparam num_warps_per_threadblock Number of warps in a threadblock. This template argument must
* match the launch configuration, i.e. the kernel must be launched with
* `num_warps_per_threadblock * cudf::detail::warp_size` threads per threadblock.
* @tparam char_block_size Number of characters which will be loaded into the shared memory at a
* time.
*
* @param[in] in_strings Input string column.
* @param[out] out_chars Character buffer for the output string column.
* @param[in] out_offsets Offset value of each string associated with `out_chars`.
*/
template <size_type num_warps_per_threadblock, size_type char_block_size>
__global__ void url_decode_char_replacer(column_device_view const in_strings,
char* const out_chars,
size_type const* const out_offsets)
{
constexpr int halo_size = 2;
__shared__ char temporary_buffer[num_warps_per_threadblock][char_block_size + halo_size * 2];
__shared__ typename cub::WarpScan<int8_t>::TempStorage cub_storage[num_warps_per_threadblock];
__shared__ size_type out_idx[num_warps_per_threadblock];
auto const global_thread_id = cudf::detail::grid_1d::global_thread_id();
auto const global_warp_id = static_cast<size_type>(global_thread_id / cudf::detail::warp_size);
auto const local_warp_id = static_cast<size_type>(threadIdx.x / cudf::detail::warp_size);
auto const warp_lane = static_cast<size_type>(threadIdx.x % cudf::detail::warp_size);
auto const nwarps = static_cast<size_type>(gridDim.x * blockDim.x / cudf::detail::warp_size);
char* in_chars_shared = temporary_buffer[local_warp_id];
// Loop through strings, and assign each string to a warp
for (thread_index_type tidx = global_warp_id; tidx < in_strings.size(); tidx += nwarps) {
auto const row_idx = static_cast<size_type>(tidx);
if (in_strings.is_null(row_idx)) continue;
auto const in_string = in_strings.element<string_view>(row_idx);
auto const in_chars = in_string.data();
auto const string_length = in_string.size_bytes();
auto out_chars_string = out_chars + out_offsets[row_idx];
auto const nblocks = cudf::util::div_rounding_up_unsafe(string_length, char_block_size);
// Use the last thread of the warp to initialize `out_idx` to 0.
if (warp_lane == cudf::detail::warp_size - 1) { out_idx[local_warp_id] = 0; }
for (size_type block_idx = 0; block_idx < nblocks; block_idx++) {
auto const string_length_block =
std::min(char_block_size, string_length - char_block_size * block_idx);
// Each warp collectively loads input characters of the current block to shared memory.
// Two halo cells before and after the block are added. The halo cells are used to test
// whether the current location as well as the previous two locations are escape characters,
// without branches.
for (auto char_idx = warp_lane; char_idx < string_length_block + halo_size * 2;
char_idx += cudf::detail::warp_size) {
auto const in_idx = block_idx * char_block_size + char_idx - halo_size;
in_chars_shared[char_idx] = in_idx >= 0 && in_idx < string_length ? in_chars[in_idx] : 0;
}
__syncwarp();
// `char_idx_start` represents the start character index of the current warp.
for (size_type char_idx_start = 0; char_idx_start < string_length_block;
char_idx_start += cudf::detail::warp_size) {
auto const char_idx = char_idx_start + warp_lane;
// If the current character is part of an escape sequence starting at the previous two
// locations, the thread with the starting location should output the escaped character, and
// the current thread should not output a character.
int8_t const out_size =
(char_idx >= string_length_block || is_escape_char(in_chars_shared + char_idx) ||
is_escape_char(in_chars_shared + char_idx + 1))
? 0
: 1;
// Warp-wise prefix sum to establish output location of the current thread.
// All threads in the warp participate in the prefix sum, even if `char_idx` is beyond
// `string_length_block`.
int8_t out_offset;
cub::WarpScan<int8_t>(cub_storage[local_warp_id]).ExclusiveSum(out_size, out_offset);
if (out_size == 1) {
char const* const ch_ptr = in_chars_shared + char_idx + halo_size;
char const ch =
is_escape_char(ch_ptr)
?
// If the current location is the start of an escape sequence, load and decode.
escaped_sequence_to_byte(ch_ptr)
:
// If the current location is not the start of an escape sequence, load directly.
*ch_ptr;
out_chars_string[out_idx[local_warp_id] + out_offset] = ch;
}
if (warp_lane == cudf::detail::warp_size - 1) {
out_idx[local_warp_id] += (out_offset + out_size);
}
__syncwarp();
}
}
}
}
} // namespace
//
std::unique_ptr<column> url_decode(strings_column_view const& strings,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = strings.size();
if (strings_count == 0) return make_empty_column(type_id::STRING);
constexpr size_type num_warps_per_threadblock = 4;
constexpr size_type threadblock_size = num_warps_per_threadblock * cudf::detail::warp_size;
constexpr size_type char_block_size = 256;
auto const num_threadblocks =
std::min(65536, cudf::util::div_rounding_up_unsafe(strings_count, num_warps_per_threadblock));
auto offset_count = strings_count + 1;
auto const d_strings = column_device_view::create(strings.parent(), stream);
// build offsets column
auto offsets_column = make_numeric_column(
data_type{type_to_id<size_type>()}, offset_count, mask_state::UNALLOCATED, stream, mr);
// count number of bytes in each string after decoding and store it in offsets_column
auto offsets_view = offsets_column->view();
auto offsets_mutable_view = offsets_column->mutable_view();
url_decode_char_counter<num_warps_per_threadblock, char_block_size>
<<<num_threadblocks, threadblock_size, 0, stream.value()>>>(
*d_strings, offsets_mutable_view.begin<size_type>());
// use scan to transform number of bytes into offsets
thrust::exclusive_scan(rmm::exec_policy(stream),
offsets_view.begin<size_type>(),
offsets_view.end<size_type>(),
offsets_mutable_view.begin<size_type>());
// copy the total number of characters of all strings combined (last element of the offset column)
// to the host memory
auto out_chars_bytes = cudf::detail::get_value<size_type>(offsets_view, offset_count - 1, stream);
// create the chars column
auto chars_column = create_chars_child_column(out_chars_bytes, stream, mr);
auto d_out_chars = chars_column->mutable_view().data<char>();
// decode and copy the characters from the input column to the output column
url_decode_char_replacer<num_warps_per_threadblock, char_block_size>
<<<num_threadblocks, threadblock_size, 0, stream.value()>>>(
*d_strings, d_out_chars, offsets_column->view().begin<size_type>());
// copy null mask
rmm::device_buffer null_mask = cudf::detail::copy_bitmask(strings.parent(), stream, mr);
return make_strings_column(strings_count,
std::move(offsets_column),
std::move(chars_column),
strings.null_count(),
std::move(null_mask));
}
} // namespace detail
// external API
std::unique_ptr<column> url_decode(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::url_decode(input, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/convert/convert_datetime.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/strings/convert/convert_datetime.hpp>
#include <cudf/strings/detail/converters.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf/utilities/span.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <cudf/wrappers/timestamps.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/functional.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/logical.h>
#include <thrust/optional.h>
#include <thrust/pair.h>
#include <thrust/transform.h>
#include <map>
#include <numeric>
#include <vector>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Structure of date/time components
*/
struct timestamp_components {
int16_t year;
int8_t month;
int8_t day;
int16_t day_of_year;
int8_t hour;
int8_t minute;
int8_t second;
int8_t week; ///< week of the year
int8_t weekday; ///< day of the week
int32_t subsecond;
int32_t tz_minutes;
};
enum class format_char_type : int8_t {
literal, ///< literal char type passed through
specifier ///< timestamp format specifier
};
/**
* @brief Represents a format specifier or literal from a timestamp format string.
*
* Created by the format_compiler when parsing a format string.
*/
struct alignas(4) format_item {
format_char_type item_type; // specifier or literal indicator
char value; // specifier or literal value
int8_t length; // item length in bytes
static format_item new_specifier(char format_char, int8_t length)
{
return format_item{format_char_type::specifier, format_char, length};
}
static format_item new_literal(char literal)
{
return format_item{format_char_type::literal, literal, 1};
}
};
/**
* @brief The format-compiler parses a timestamp format string into a vector of
* `format_items`.
*
* The vector of `format_items` is used when parsing a string into timestamp
* components and when formatting a string from timestamp components.
*/
using specifier_map = std::map<char, int8_t>;
struct format_compiler {
std::string_view const format;
rmm::device_uvector<format_item> d_items;
// clang-format off
// The specifiers are documented here (not all are supported):
// https://en.cppreference.com/w/cpp/chrono/system_clock/formatter
specifier_map specifiers = {
{'Y', 4}, {'y', 2}, {'m', 2}, {'d', 2}, {'H', 2}, {'I', 2}, {'M', 2},
{'S', 2}, {'f', 6}, {'z', 5}, {'Z', 3}, {'p', 2}, {'j', 3},
{'W', 2}, {'w', 1}, {'U', 2}, {'u', 1}};
// clang-format on
format_compiler(std::string_view fmt,
rmm::cuda_stream_view stream,
specifier_map extra_specifiers = {})
: format(fmt), d_items(0, stream)
{
specifiers.insert(extra_specifiers.begin(), extra_specifiers.end());
std::vector<format_item> items;
auto str = format.data();
auto length = format.length();
while (length > 0) {
char ch = *str++;
length--;
// first check for a literal character
if (ch != '%') {
items.push_back(format_item::new_literal(ch));
continue;
}
CUDF_EXPECTS(length > 0, "Unfinished specifier in timestamp format");
ch = *str++;
length--;
if (ch == '%') // escaped % char
{
items.push_back(format_item::new_literal(ch));
continue;
}
if (ch >= '0' && ch <= '9') {
CUDF_EXPECTS(*str == 'f', "precision not supported for specifier: " + std::string(1, *str));
specifiers[*str] = static_cast<int8_t>(ch - '0');
ch = *str++;
length--;
}
// check if the specifier found is supported
CUDF_EXPECTS(specifiers.find(ch) != specifiers.end(),
"invalid format specifier: " + std::string(1, ch));
// create the format item for this specifier
items.push_back(format_item::new_specifier(ch, specifiers[ch]));
}
// copy format_items to device memory
d_items = cudf::detail::make_device_uvector_async(
items, stream, rmm::mr::get_current_device_resource());
}
device_span<format_item const> format_items() { return device_span<format_item const>(d_items); }
[[nodiscard]] int8_t subsecond_precision() const { return specifiers.at('f'); }
};
/**
* @brief Specialized function to return the integer value reading up to the specified
* bytes or until an invalid character is encountered.
*
* @param str Beginning of characters to read.
* @param bytes Number of bytes in str to read.
* @return Integer value of valid characters read and how many bytes were not read.
*/
__device__ thrust::pair<int32_t, size_type> parse_int(char const* str, size_type bytes)
{
int32_t value = 0;
while (bytes-- > 0) {
char chr = *str++;
if (chr < '0' || chr > '9') break;
value = (value * 10) + static_cast<int32_t>(chr - '0');
}
return thrust::make_pair(value, bytes + 1);
}
/**
* @brief This parses date/time characters into a timestamp integer
*
* @tparam T cudf::timestamp type
*/
template <typename T>
struct parse_datetime {
column_device_view const d_strings;
device_span<format_item const> const d_format_items;
int8_t const subsecond_precision;
/**
* @brief Return power of ten value given an exponent.
*
* @return `1x10^exponent` for `0 <= exponent <= 9`
*/
[[nodiscard]] __device__ constexpr int64_t power_of_ten(int32_t const exponent) const
{
constexpr int64_t powers_of_ten[] = {
1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L, 1000000000L};
return powers_of_ten[exponent];
}
__device__ bool format_contains(char specifier) const
{
return thrust::find_if(thrust::seq,
d_format_items.begin(),
d_format_items.end(),
[specifier](auto const item) { return item.value == specifier; }) !=
d_format_items.end();
}
// Walk the format_items to parse the string into date/time components
[[nodiscard]] __device__ timestamp_components parse_into_parts(string_view const& d_string) const
{
timestamp_components timeparts = {1970, 1, 1, 0}; // init to epoch time
auto ptr = d_string.data();
auto length = d_string.size_bytes();
for (auto item : d_format_items) {
if (item.value != 'f')
item.length = static_cast<int8_t>(std::min(static_cast<size_type>(item.length), length));
if (item.item_type == format_char_type::literal) {
// static character we'll just skip;
// consume item.length bytes from the input string
ptr += item.length;
length -= item.length;
continue;
}
size_type bytes_read = item.length; // number of bytes processed
// special logic for each specifier
switch (item.value) {
case 'Y': {
auto const [year, left] = parse_int(ptr, item.length);
timeparts.year = static_cast<int16_t>(year);
bytes_read -= left;
break;
}
case 'y': {
auto const [year, left] = parse_int(ptr, item.length);
timeparts.year = static_cast<int16_t>(year + (year < 69 ? 2000 : 1900));
bytes_read -= left;
break;
}
case 'm': {
auto const [month, left] = parse_int(ptr, item.length);
timeparts.month = static_cast<int8_t>(month);
bytes_read -= left;
break;
}
case 'd': {
auto const [day, left] = parse_int(ptr, item.length);
timeparts.day = static_cast<int8_t>(day);
bytes_read -= left;
break;
}
case 'j': {
auto const [day, left] = parse_int(ptr, item.length);
timeparts.day_of_year = static_cast<int16_t>(day);
bytes_read -= left;
break;
}
case 'H':
case 'I': {
auto const [hour, left] = parse_int(ptr, item.length);
timeparts.hour = static_cast<int8_t>(hour);
bytes_read -= left;
break;
}
case 'M': {
auto const [minute, left] = parse_int(ptr, item.length);
timeparts.minute = static_cast<int8_t>(minute);
bytes_read -= left;
break;
}
case 'S': {
auto const [second, left] = parse_int(ptr, item.length);
timeparts.second = static_cast<int8_t>(second);
bytes_read -= left;
break;
}
case 'f': {
int32_t const read_size =
std::min(static_cast<int32_t>(item.length), static_cast<int32_t>(length));
auto const [fraction, left] = parse_int(ptr, read_size);
timeparts.subsecond =
static_cast<int32_t>(fraction * power_of_ten(item.length - read_size + left));
bytes_read = read_size - left;
break;
}
case 'p': {
string_view am_pm(ptr, 2);
auto hour = timeparts.hour;
if ((am_pm.compare("AM", 2) == 0) || (am_pm.compare("am", 2) == 0)) {
if (hour == 12) hour = 0;
} else if (hour < 12)
hour += 12;
timeparts.hour = hour;
break;
}
case 'U': [[fallthrough]]; // week of year: Sunday based
case 'W': { // week of year: Monday based
auto const [week, left] = parse_int(ptr, item.length);
timeparts.week = static_cast<int8_t>(week + 1);
bytes_read -= left;
break;
}
case 'u': [[fallthrough]]; // day of week: Mon(1)-Sat(6),Sun(7)
case 'w': { // day of week; Sun(0),Mon(1)-Sat(6)
auto const [weekday, left] = parse_int(ptr, item.length);
timeparts.weekday = // 0 is mapped to 7 for chrono library
static_cast<int8_t>((item.value == 'w' && weekday == 0) ? 7 : weekday);
bytes_read -= left;
break;
}
case 'z': {
// 'z' format is +hh:mm -- single sign char and 2 chars each for hour and minute
if (item.length == 5) {
auto const sign = *ptr == '-' ? 1 : -1;
auto const [hh, lh] = parse_int(ptr + 1, 2);
auto const [mm, lm] = parse_int(ptr + 3, 2);
// revert timezone back to UTC
timeparts.tz_minutes = sign * ((hh * 60) + mm);
bytes_read -= lh + lm;
}
break;
}
case 'Z': break; // skip
default: break;
}
ptr += bytes_read;
length -= bytes_read;
}
return timeparts;
}
[[nodiscard]] __device__ int64_t timestamp_from_parts(timestamp_components const& timeparts) const
{
// Reference: https://howardhinnant.github.io/date/date.html#Reference
auto const days = [timeparts, this] {
// week and weekday prioritize over month/day
if ((timeparts.week > 0) && (timeparts.weekday > 0)) {
auto const y = cuda::std::chrono::year{timeparts.year};
// clang-format off
auto const start = format_contains('U')
? cuda::std::chrono::sys_days{cuda::std::chrono::Sunday[1]/cuda::std::chrono::January/y}
: cuda::std::chrono::sys_days{cuda::std::chrono::Monday[1]/cuda::std::chrono::January/y};
// clang-format on
auto const days = // compute days from year, weeks and weekday
start + cuda::std::chrono::weeks(timeparts.week - 1) - cuda::std::chrono::weeks{1} +
(cuda::std::chrono::weekday(timeparts.weekday) -
cuda::std::chrono::weekday{1}); // cuda::std::chrono::Monday causes compile error here
return days.time_since_epoch().count();
}
auto const ymd = // chrono class handles the leap year calculations for us
cuda::std::chrono::year_month_day(
cuda::std::chrono::year{timeparts.year},
cuda::std::chrono::month{static_cast<uint32_t>(timeparts.month)},
cuda::std::chrono::day{static_cast<uint32_t>(timeparts.day)});
return cuda::std::chrono::sys_days(ymd).time_since_epoch().count();
}();
if constexpr (std::is_same_v<T, cudf::timestamp_D>) { return days; }
int64_t timestamp = (days * 24L * 3600L) + (timeparts.hour * 3600L) + (timeparts.minute * 60L) +
timeparts.second + (timeparts.tz_minutes * 60L);
if constexpr (std::is_same_v<T, cudf::timestamp_s>) { return timestamp; }
int64_t const subsecond =
(timeparts.subsecond * power_of_ten(9 - subsecond_precision)) / // normalize to nanoseconds
(1000000000L / T::period::type::den); // and rescale to T
timestamp *= T::period::type::den;
timestamp += subsecond;
return timestamp;
}
__device__ T operator()(size_type idx) const
{
T epoch_time{typename T::duration{0}};
if (d_strings.is_null(idx)) return epoch_time;
string_view d_str = d_strings.element<string_view>(idx);
if (d_str.empty()) return epoch_time;
auto const timeparts = parse_into_parts(d_str);
return T{T::duration(timestamp_from_parts(timeparts))};
}
};
/**
* @brief Type-dispatch operator to convert timestamp strings to native fixed-width-type
*/
struct dispatch_to_timestamps_fn {
template <typename T, std::enable_if_t<cudf::is_timestamp<T>()>* = nullptr>
void operator()(column_device_view const& d_strings,
std::string_view format,
mutable_column_view& results_view,
rmm::cuda_stream_view stream) const
{
format_compiler compiler(format, stream);
parse_datetime<T> pfn{d_strings, compiler.format_items(), compiler.subsecond_precision()};
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(results_view.size()),
results_view.data<T>(),
pfn);
}
template <typename T, std::enable_if_t<not cudf::is_timestamp<T>()>* = nullptr>
void operator()(column_device_view const&,
std::string_view,
mutable_column_view&,
rmm::cuda_stream_view) const
{
CUDF_FAIL("Only timestamps type are expected");
}
};
} // namespace
//
std::unique_ptr<cudf::column> to_timestamps(strings_column_view const& input,
data_type timestamp_type,
std::string_view format,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input.is_empty())
return make_empty_column(timestamp_type); // make_timestamp_column(timestamp_type, 0);
CUDF_EXPECTS(!format.empty(), "Format parameter must not be empty.");
auto d_strings = column_device_view::create(input.parent(), stream);
auto results = make_timestamp_column(timestamp_type,
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto results_view = results->mutable_view();
cudf::type_dispatcher(
timestamp_type, dispatch_to_timestamps_fn(), *d_strings, format, results_view, stream);
results->set_null_count(input.null_count());
return results;
}
/**
* @brief Functor checks the strings against the given format items.
*
* This does no data conversion.
*/
struct check_datetime_format {
column_device_view const d_strings;
device_span<format_item const> const d_format_items;
/**
* @brief Check the specified characters are between ['0','9'].
*
* @param str Beginning of characters to check.
* @param bytes Number of bytes to check.
* @return true if all digits are 0-9
*/
__device__ bool check_digits(char const* str, size_type bytes)
{
return thrust::all_of(thrust::seq, str, str + bytes, [] __device__(char chr) {
return (chr >= '0' && chr <= '9');
});
}
/**
* @brief Check the specified characters are between ['0','9']
* and the resulting integer is within [`min_value`, `max_value`].
*
* @param str Beginning of characters to check.
* @param bytes Number of bytes to check.
* @param min_value Inclusive minimum value
* @param max_value Inclusive maximum value
* @return If value is valid and number of bytes not successfully processed
*/
__device__ thrust::pair<bool, size_type> check_value(char const* str,
size_type const bytes,
int const min_value,
int const max_value)
{
if (*str < '0' || *str > '9') { return thrust::make_pair(false, bytes); }
int32_t value = 0;
size_type count = bytes;
while (count-- > 0) {
char chr = *str++;
if (chr < '0' || chr > '9') break;
value = (value * 10) + static_cast<int32_t>(chr - '0');
}
return (value >= min_value && value <= max_value) ? thrust::make_pair(true, count + 1)
: thrust::make_pair(false, bytes);
}
/**
* @brief Check the string matches the format.
*
* Walk the `format_items` as we read the string characters
* checking the characters are valid for each format specifier.
* The checking here is a little more strict than the actual
* parser used for conversion.
*/
__device__ thrust::optional<timestamp_components> check_string(string_view const& d_string)
{
timestamp_components dateparts = {1970, 1, 1, 0}; // init to epoch time
auto ptr = d_string.data();
auto length = d_string.size_bytes();
for (auto item : d_format_items) {
// eliminate static character values first
if (item.item_type == format_char_type::literal) {
// check static character matches
if (*ptr != item.value) return thrust::nullopt;
ptr += item.length;
length -= item.length;
continue;
}
// allow for specifiers to be truncated
if (item.value != 'f')
item.length = static_cast<int8_t>(std::min(static_cast<size_type>(item.length), length));
// special logic for each specifier
// reference: https://man7.org/linux/man-pages/man3/strptime.3.html
bool result = false;
size_type bytes_read = item.length;
switch (item.value) {
case 'Y': {
auto const [year, left] = parse_int(ptr, item.length);
result = (left < item.length);
dateparts.year = static_cast<int16_t>(year);
bytes_read -= left;
break;
}
case 'y': {
auto const [year, left] = parse_int(ptr, item.length);
result = (left < item.length);
dateparts.year = static_cast<int16_t>(year + (year < 69 ? 2000 : 1900));
bytes_read -= left;
break;
}
case 'm': {
auto const [month, left] = parse_int(ptr, item.length);
result = (left < item.length);
dateparts.month = static_cast<int8_t>(month);
bytes_read -= left;
break;
}
case 'd': {
auto const [day, left] = parse_int(ptr, item.length);
result = (left < item.length);
dateparts.day = static_cast<int8_t>(day); // value.value()
bytes_read -= left;
break;
}
case 'j': {
auto const cv = check_value(ptr, item.length, 1, 366);
result = cv.first;
bytes_read -= cv.second;
break;
}
case 'H': {
auto const cv = check_value(ptr, item.length, 0, 23);
result = cv.first;
bytes_read -= cv.second;
break;
}
case 'I': {
auto const cv = check_value(ptr, item.length, 1, 12);
result = cv.first;
bytes_read -= cv.second;
break;
}
case 'M': {
auto const cv = check_value(ptr, item.length, 0, 59);
result = cv.first;
bytes_read -= cv.second;
break;
}
case 'S': {
auto const cv = check_value(ptr, item.length, 0, 59); // leap seconds not supported
result = cv.first;
bytes_read -= cv.second;
break;
}
case 'f': {
int32_t const read_size =
std::min(static_cast<int32_t>(item.length), static_cast<int32_t>(length));
result = check_digits(ptr, read_size);
bytes_read = read_size;
break;
}
case 'p': {
if (item.length == 2) {
string_view am_pm(ptr, 2);
result = (am_pm.compare("AM", 2) == 0) || (am_pm.compare("am", 2) == 0) ||
(am_pm.compare("PM", 2) == 0) || (am_pm.compare("pm", 2) == 0);
}
break;
}
case 'U': [[fallthrough]];
case 'W': {
auto const cv = check_value(ptr, item.length, 0, 53);
result = cv.first;
bytes_read -= cv.second;
break;
}
case 'u': [[fallthrough]]; // valid values: 1-7
case 'w': { // valid values: 0-6
auto const first = item.value == 'w' ? 0 : 1;
auto const cv = check_value(ptr, item.length, first, first + 6);
result = cv.first;
bytes_read -= cv.second;
break;
}
case 'z': { // timezone offset
if (item.length == 5) {
auto const cvh = check_value(ptr + 1, 2, 0, 23);
auto const cvm = check_value(ptr + 3, 2, 0, 59);
result = (*ptr == '-' || *ptr == '+') && cvh.first && cvm.first;
bytes_read -= cvh.second + cvm.second;
} else if (item.length == 1) {
result = *ptr == 'Z';
}
break;
}
case 'Z': result = true; // skip
default: break;
}
if (!result) return thrust::nullopt;
ptr += bytes_read;
length -= bytes_read;
}
return dateparts;
}
__device__ bool operator()(size_type idx)
{
if (d_strings.is_null(idx)) return false;
string_view d_str = d_strings.element<string_view>(idx);
if (d_str.empty()) return false;
auto const dateparts = check_string(d_str);
if (!dateparts.has_value()) return false;
auto const year = dateparts.value().year;
auto const month = static_cast<uint32_t>(dateparts.value().month);
auto const day = static_cast<uint32_t>(dateparts.value().day);
return cuda::std::chrono::year_month_day(cuda::std::chrono::year{year},
cuda::std::chrono::month{month},
cuda::std::chrono::day{day})
.ok();
}
};
std::unique_ptr<cudf::column> is_timestamp(strings_column_view const& input,
std::string_view const& format,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = input.size();
if (strings_count == 0) return make_empty_column(type_id::BOOL8);
CUDF_EXPECTS(!format.empty(), "Format parameter must not be empty.");
auto d_strings = column_device_view::create(input.parent(), stream);
auto results = make_numeric_column(data_type{type_id::BOOL8},
strings_count,
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto d_results = results->mutable_view().data<bool>();
format_compiler compiler(format, stream);
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_count),
d_results,
check_datetime_format{*d_strings, compiler.format_items()});
results->set_null_count(input.null_count());
return results;
}
} // namespace detail
// external APIs
std::unique_ptr<cudf::column> to_timestamps(strings_column_view const& input,
data_type timestamp_type,
std::string_view format,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::to_timestamps(input, timestamp_type, format, stream, mr);
}
std::unique_ptr<cudf::column> is_timestamp(strings_column_view const& input,
std::string_view format,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::is_timestamp(input, format, stream, mr);
}
namespace detail {
namespace {
constexpr size_type format_names_size = 40; // 2(am/pm) + 2x7(weekdays) + 2x12(months)
constexpr size_type offset_weekdays = 2;
constexpr size_type offset_months = 16;
constexpr size_type days_in_week = 7;
constexpr size_type months_in_year = 12;
/**
* @brief Time components used by the date_time_formatter
*/
struct time_components {
int8_t hour;
int8_t minute;
int8_t second;
int32_t subsecond;
};
/**
* @brief Functor for from_timestamps to convert a timestamp to a string
*
* This is designed to be used with make_strings_children
*/
template <typename T>
struct datetime_formatter_fn {
column_device_view const d_timestamps;
column_device_view const d_format_names;
device_span<format_item const> const d_format_items;
size_type* d_offsets{};
char* d_chars{};
/**
* @brief Specialized modulo expression that handles negative values.
*
* @code{.pseudo}
* Examples:
* modulo(1,60) -> 1
* modulo(-1,60) -> 59
* @endcode
*/
__device__ int32_t modulo_time(int64_t time, int64_t base) const
{
return static_cast<int32_t>(((time % base) + base) % base);
};
/**
* @brief This function handles converting units by dividing and adjusting for negative values.
*
* @code{.pseudo}
* Examples:
* scale(-61,60) -> -2
* scale(-60,60) -> -1
* scale(-59,60) -> -1
* scale( 59,60) -> 0
* scale( 60,60) -> 1
* scale( 61,60) -> 1
* @endcode
*/
__device__ int64_t scale_time(int64_t time, int64_t base) const
{
return (time - ((time < 0) * (base - 1L))) / base;
};
__device__ time_components get_time_components(int64_t tstamp) const
{
time_components result = {0};
if constexpr (std::is_same_v<T, cudf::timestamp_D>) { return result; }
// Note: Tried using: cuda::std::chrono::hh_mm_ss(T::duration(timestamp));
// and retrieving the hour, minute, second, and subsecond values from it
// but it did not scale/modulo the components for negative timestamps
// correctly -- it simply did an abs(timestamp) as documented here:
// https://en.cppreference.com/w/cpp/chrono/hh_mm_ss/hh_mm_ss
if constexpr (not std::is_same_v<T, cudf::timestamp_s>) {
int64_t constexpr base = T::period::type::den; // 1000=ms, 1000000=us, etc
auto const subsecond = modulo_time(tstamp, base);
tstamp = tstamp / base - ((tstamp < 0) and (subsecond != 0));
result.subsecond = subsecond;
}
result.hour = modulo_time(scale_time(tstamp, 3600), 24);
result.minute = modulo_time(scale_time(tstamp, 60), 60);
result.second = modulo_time(tstamp, 60);
return result;
}
__device__ size_type compute_output_size(T const tstamp) const
{
// We only dissect the timestamp into components if needed
// by a specifier. And then we only do it once and reuse it.
// This can improve performance when not using uncommon specifiers.
thrust::optional<cuda::std::chrono::sys_days> days;
auto days_from_timestamp = [tstamp]() {
auto const count = tstamp.time_since_epoch().count();
return cuda::std::chrono::sys_days(static_cast<cudf::timestamp_D::duration>(
floor<cuda::std::chrono::days>(T::duration(count))));
};
size_type bytes = 0; // output size
for (auto item : d_format_items) {
if (item.item_type == format_char_type::literal) {
bytes += item.length;
continue;
}
// only specifiers resulting in strings require special logic
switch (item.value) {
case 'a': // weekday abbreviated
case 'A': { // weekday full name
if (!days.has_value()) { days = days_from_timestamp(); }
auto const day_of_week =
cuda::std::chrono::year_month_weekday(days.value()).weekday().c_encoding();
auto const day_idx =
day_of_week + offset_weekdays + (item.value == 'a' ? days_in_week : 0);
if (day_idx < d_format_names.size())
bytes += d_format_names.element<cudf::string_view>(day_idx).size_bytes();
break;
}
case 'b': // month abbreviated
case 'B': { // month full name
if (!days.has_value()) { days = days_from_timestamp(); }
auto const month =
static_cast<uint32_t>(cuda::std::chrono::year_month_day(days.value()).month());
auto const month_idx =
month - 1 + offset_months + (item.value == 'b' ? months_in_year : 0);
if (month_idx < d_format_names.size())
bytes += d_format_names.element<cudf::string_view>(month_idx).size_bytes();
break;
}
case 'p': // AM/PM
{
auto const times = get_time_components(tstamp.time_since_epoch().count());
bytes += d_format_names.size() > 1
? d_format_names.element<cudf::string_view>(static_cast<int>(times.hour >= 12))
.size_bytes()
: 2;
break;
}
default: {
bytes += item.length;
break;
}
}
}
return bytes;
}
// utility to create 0-padded integers (up to 9 chars)
__device__ char* int2str(char* str, int bytes, int val) const
{
char tmpl[9] = {'0', '0', '0', '0', '0', '0', '0', '0', '0'};
char* ptr = tmpl;
while (val > 0) {
int digit = val % 10;
*ptr++ = '0' + digit;
val = val / 10;
}
ptr = tmpl + bytes - 1;
while (bytes-- > 0)
*str++ = *ptr--;
return str;
}
// from https://howardhinnant.github.io/date/date.html
__device__ thrust::pair<int32_t, int32_t> get_iso_week_year(
cuda::std::chrono::year_month_day const& ymd) const
{
auto const days = cuda::std::chrono::sys_days(ymd);
auto year = ymd.year();
auto iso_week_start = [](cuda::std::chrono::year const y) {
// clang-format off
return cuda::std::chrono::sys_days{cuda::std::chrono::Thursday[1]/cuda::std::chrono::January/y} -
(cuda::std::chrono::Thursday - cuda::std::chrono::Monday);
// clang-format on
};
auto start = iso_week_start(year);
if (days < start)
start = iso_week_start(--year);
else {
auto const next_start = iso_week_start(year + cuda::std::chrono::years{1});
if (days >= next_start) {
++year;
start = next_start;
}
}
return thrust::make_pair(
(cuda::std::chrono::duration_cast<cuda::std::chrono::weeks>(days - start) +
cuda::std::chrono::weeks{1}) // always [1-53]
.count(),
static_cast<int32_t>(year));
}
__device__ int8_t get_week_of_year(cuda::std::chrono::sys_days const days,
cuda::std::chrono::sys_days const start) const
{
return days < start
? 0
: (cuda::std::chrono::duration_cast<cuda::std::chrono::weeks>(days - start) +
cuda::std::chrono::weeks{1})
.count();
}
__device__ int32_t get_day_of_year(cuda::std::chrono::year_month_day const& ymd) const
{
auto const month = static_cast<uint32_t>(ymd.month());
auto const day = static_cast<uint32_t>(ymd.day());
int32_t const monthDayOffset[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
return static_cast<int32_t>(day + monthDayOffset[month - 1] +
(month > 2 and ymd.year().is_leap()));
}
__device__ void timestamp_to_string(T const tstamp, char* ptr) const
{
auto const days = cuda::std::chrono::sys_days(
static_cast<cudf::timestamp_D::duration>(cuda::std::chrono::floor<cuda::std::chrono::days>(
T::duration(tstamp.time_since_epoch().count()))));
auto const ymd = cuda::std::chrono::year_month_day(days);
auto timeparts = get_time_components(tstamp.time_since_epoch().count());
// convert to characters using the format items
for (auto item : d_format_items) {
if (item.item_type == format_char_type::literal) {
*ptr++ = item.value;
continue;
}
// Value to use for int2str call at the end of the switch-statement.
// This simplifies the case statements and prevents a lot of extra inlining.
int32_t copy_value = -1; // default set for non-int2str usage cases
// special logic for each specifier
switch (item.value) {
case 'Y': // 4-digit year
copy_value = static_cast<int32_t>(ymd.year());
break;
case 'y': // 2-digit year
{
auto year = static_cast<int32_t>(ymd.year());
// remove hundredths digits and above
copy_value = year - ((year / 100) * 100);
break;
}
case 'm': // month
copy_value = static_cast<int32_t>(static_cast<uint32_t>(ymd.month()));
break;
case 'd': // day of month
copy_value = static_cast<int32_t>(static_cast<uint32_t>(ymd.day()));
break;
case 'j': // day of year
copy_value = get_day_of_year(ymd);
break;
case 'H': // 24-hour
copy_value = timeparts.hour;
break;
case 'I': // 12-hour
{
// 0 = 12am; 12 = 12pm; 6 = 06am; 18 = 06pm
copy_value = [h = timeparts.hour] {
if (h == 0) return 12;
return h > 12 ? h - 12 : h;
}();
break;
}
case 'M': // minute
copy_value = timeparts.minute;
break;
case 'S': // second
copy_value = timeparts.second;
break;
case 'f': // sub-second
{
char subsecond_digits[] = "000000000"; // 9 max digits
int const digits = [] {
if constexpr (std::is_same_v<T, cudf::timestamp_ms>) return 3;
if constexpr (std::is_same_v<T, cudf::timestamp_us>) return 6;
if constexpr (std::is_same_v<T, cudf::timestamp_ns>) return 9;
return 0;
}();
int2str(subsecond_digits, digits, timeparts.subsecond);
ptr = copy_and_increment(ptr, subsecond_digits, item.length);
break;
}
case 'p': // am or pm
{
// 0 = 12am, 12 = 12pm
auto const am_pm = [&] {
if (d_format_names.size() > 1)
return d_format_names.element<cudf::string_view>(
static_cast<int>(timeparts.hour >= 12));
return string_view(timeparts.hour >= 12 ? "PM" : "AM", 2);
}();
ptr = copy_string(ptr, am_pm);
break;
}
case 'z': // timezone -- always UTC
ptr = copy_and_increment(ptr, "+0000", 5);
break;
case 'Z': // timezone string -- always UTC
ptr = copy_and_increment(ptr, "UTC", 3);
break;
case 'u': // day of week ISO
case 'w': { // day of week non-ISO
auto const day_of_week = static_cast<int32_t>(
cuda::std::chrono::year_month_weekday(days).weekday().c_encoding());
copy_value = day_of_week == 0 && item.value == 'u' ? 7 : day_of_week;
break;
}
// clang-format off
case 'U': { // week of year: first week includes the first Sunday of the year
copy_value = get_week_of_year(days, cuda::std::chrono::sys_days{
cuda::std::chrono::Sunday[1]/cuda::std::chrono::January/ymd.year()});
break;
}
case 'W': { // week of year: first week includes the first Monday of the year
copy_value = get_week_of_year(days, cuda::std::chrono::sys_days{
cuda::std::chrono::Monday[1]/cuda::std::chrono::January/ymd.year()});
break;
}
// clang-format on
case 'V': // ISO week number
case 'G': { // ISO year number
auto const [week, year] = get_iso_week_year(ymd);
copy_value = item.value == 'G' ? year : week;
break;
}
case 'a': // abbreviated day of the week
case 'A': { // day of the week
auto const day_of_week =
cuda::std::chrono::year_month_weekday(days).weekday().c_encoding();
auto const day_idx =
day_of_week + offset_weekdays + (item.value == 'a' ? days_in_week : 0);
if (d_format_names.size())
ptr = copy_string(ptr, d_format_names.element<cudf::string_view>(day_idx));
break;
}
case 'b': // abbreviated month of the year
case 'B': { // month of the year
auto const month = static_cast<uint32_t>(ymd.month());
auto const month_idx =
month - 1 + offset_months + (item.value == 'b' ? months_in_year : 0);
if (d_format_names.size())
ptr = copy_string(ptr, d_format_names.element<cudf::string_view>(month_idx));
break;
}
default: break;
}
if (copy_value >= 0) ptr = int2str(ptr, item.length, copy_value);
}
}
__device__ void operator()(size_type idx) const
{
if (d_timestamps.is_null(idx)) {
if (!d_chars) { d_offsets[idx] = 0; }
return;
}
auto const tstamp = d_timestamps.element<T>(idx);
if (d_chars) {
timestamp_to_string(tstamp, d_chars + d_offsets[idx]);
} else {
d_offsets[idx] = compute_output_size(tstamp);
}
}
};
//
using strings_children = std::pair<std::unique_ptr<cudf::column>, std::unique_ptr<cudf::column>>;
struct dispatch_from_timestamps_fn {
template <typename T, std::enable_if_t<cudf::is_timestamp<T>()>* = nullptr>
strings_children operator()(column_device_view const& d_timestamps,
column_device_view const& d_format_names,
device_span<format_item const> d_format_items,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr) const
{
return make_strings_children(
datetime_formatter_fn<T>{d_timestamps, d_format_names, d_format_items},
d_timestamps.size(),
stream,
mr);
}
template <typename T, typename... Args>
std::enable_if_t<not cudf::is_timestamp<T>(), strings_children> operator()(Args&&...) const
{
CUDF_FAIL("Only timestamps type are expected");
}
};
} // namespace
//
std::unique_ptr<column> from_timestamps(column_view const& timestamps,
std::string_view format,
strings_column_view const& names,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (timestamps.is_empty()) return make_empty_column(type_id::STRING);
CUDF_EXPECTS(!format.empty(), "Format parameter must not be empty.");
CUDF_EXPECTS(names.is_empty() || names.size() == format_names_size,
"Invalid size for format names.");
auto const d_names = column_device_view::create(names.parent(), stream);
// This API supports a few more specifiers than to_timestamps.
// clang-format off
format_compiler compiler(format, stream,
specifier_map{{'V', 2}, {'G', 4}, {'a', 3}, {'A', 3}, {'b', 3}, {'B', 3}});
// clang-format on
auto const d_format_items = compiler.format_items();
auto const d_timestamps = column_device_view::create(timestamps, stream);
// dispatcher is called to handle the different timestamp types
auto [offsets_column, chars_column] = cudf::type_dispatcher(timestamps.type(),
dispatch_from_timestamps_fn(),
*d_timestamps,
*d_names,
d_format_items,
stream,
mr);
return make_strings_column(timestamps.size(),
std::move(offsets_column),
std::move(chars_column),
timestamps.null_count(),
cudf::detail::copy_bitmask(timestamps, stream, mr));
}
} // namespace detail
// external API
std::unique_ptr<column> from_timestamps(column_view const& timestamps,
std::string_view format,
strings_column_view const& names,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::from_timestamps(timestamps, format, names, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/convert/convert_floats.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/convert/convert_floats.hpp>
#include <cudf/strings/detail/convert/string_to_float.cuh>
#include <cudf/strings/detail/converters.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/traits.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/iterator/transform_iterator.h>
#include <thrust/transform.h>
#include <cmath>
#include <limits>
namespace cudf {
namespace strings {
namespace detail {
namespace {
/**
* @brief Converts strings column entries into floats.
*
* Used by the dispatch method to convert to different float types.
*/
template <typename FloatType>
struct string_to_float_fn {
column_device_view const strings_column; // strings to convert
__device__ FloatType operator()(size_type idx)
{
if (strings_column.is_null(idx)) return static_cast<FloatType>(0);
// The cast to FloatType will create predictable results for floats that are larger than the
// FloatType can hold
return static_cast<FloatType>(stod(strings_column.element<string_view>(idx)));
}
};
/**
* @brief The dispatch functions for converting strings to floats.
*
* The output_column is expected to be one of the float types only.
*/
struct dispatch_to_floats_fn {
template <typename FloatType, std::enable_if_t<std::is_floating_point_v<FloatType>>* = nullptr>
void operator()(column_device_view const& strings_column,
mutable_column_view& output_column,
rmm::cuda_stream_view stream) const
{
auto d_results = output_column.data<FloatType>();
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_column.size()),
d_results,
string_to_float_fn<FloatType>{strings_column});
}
// non-integral types throw an exception
template <typename T, std::enable_if_t<not std::is_floating_point_v<T>>* = nullptr>
void operator()(column_device_view const&, mutable_column_view&, rmm::cuda_stream_view) const
{
CUDF_FAIL("Output for to_floats must be a float type.");
}
};
} // namespace
// This will convert a strings column into any float column type.
std::unique_ptr<column> to_floats(strings_column_view const& input,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = input.size();
if (strings_count == 0) return make_numeric_column(output_type, 0);
auto strings_column = column_device_view::create(input.parent(), stream);
auto d_strings = *strings_column;
// create float output column copying the strings null-mask
auto results = make_numeric_column(output_type,
strings_count,
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto results_view = results->mutable_view();
// fill output column with floats
type_dispatcher(output_type, dispatch_to_floats_fn{}, d_strings, results_view, stream);
results->set_null_count(input.null_count());
return results;
}
} // namespace detail
// external API
std::unique_ptr<column> to_floats(strings_column_view const& input,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::to_floats(input, output_type, stream, mr);
}
namespace detail {
namespace {
/**
* @brief Code logic for converting float value into a string.
*
* The floating point components are dissected and used to fill an
* existing output char array.
*/
struct ftos_converter {
// significant digits is independent of scientific notation range
// digits more than this may require using long values instead of ints
static constexpr unsigned int significant_digits = 10;
// maximum power-of-10 that will fit in 32-bits
static constexpr unsigned int nine_digits = 1000000000; // 1x10^9
// Range of numbers here is for normalizing the value.
// If the value is above or below the following limits, the output is converted to
// scientific notation in order to show (at most) the number of significant digits.
static constexpr double upper_limit = 1000000000; // max is 1x10^9
static constexpr double lower_limit = 0.0001; // printf uses scientific notation below this
// Tables for doing normalization: converting to exponent form
// IEEE double float has maximum exponent of 305 so these should cover everything
double const upper10[9] = {10, 100, 10000, 1e8, 1e16, 1e32, 1e64, 1e128, 1e256};
double const lower10[9] = {.1, .01, .0001, 1e-8, 1e-16, 1e-32, 1e-64, 1e-128, 1e-256};
double const blower10[9] = {1.0, .1, .001, 1e-7, 1e-15, 1e-31, 1e-63, 1e-127, 1e-255};
// utility for quickly converting known integer range to character array
__device__ char* int2str(int value, char* output)
{
if (value == 0) {
*output++ = '0';
return output;
}
char buffer[significant_digits]; // should be big-enough for significant digits
char* ptr = buffer;
while (value > 0) {
*ptr++ = (char)('0' + (value % 10));
value /= 10;
}
while (ptr != buffer)
*output++ = *--ptr; // 54321 -> 12345
return output;
}
/**
* @brief Dissect a float value into integer, decimal, and exponent components.
*
* @return The number of decimal places.
*/
__device__ int dissect_value(double value,
unsigned int& integer,
unsigned int& decimal,
int& exp10)
{
int decimal_places = significant_digits - 1;
// normalize step puts value between lower-limit and upper-limit
// by adjusting the exponent up or down
exp10 = 0;
if (value > upper_limit) {
int fx = 256;
for (int idx = 8; idx >= 0; --idx) {
if (value >= upper10[idx]) {
value *= lower10[idx];
exp10 += fx;
}
fx = fx >> 1;
}
} else if ((value > 0.0) && (value < lower_limit)) {
int fx = 256;
for (int idx = 8; idx >= 0; --idx) {
if (value < blower10[idx]) {
value *= upper10[idx];
exp10 -= fx;
}
fx = fx >> 1;
}
}
//
unsigned int max_digits = nine_digits;
integer = (unsigned int)value;
for (unsigned int i = integer; i >= 10; i /= 10) {
--decimal_places;
max_digits /= 10;
}
double remainder = (value - (double)integer) * (double)max_digits;
decimal = (unsigned int)remainder;
remainder -= (double)decimal;
decimal += (unsigned int)(2.0 * remainder);
if (decimal >= max_digits) {
decimal = 0;
++integer;
if (exp10 && (integer >= 10)) {
++exp10;
integer = 1;
}
}
//
while ((decimal % 10) == 0 && (decimal_places > 0)) {
decimal /= 10;
--decimal_places;
}
return decimal_places;
}
/**
* @brief Main kernel method for converting float value to char output array.
*
* Output need not be more than (significant_digits + 7) bytes:
* 7 = 1 sign, 1 decimal point, 1 exponent ('e'), 1 exponent-sign, 3 digits for exponent
*
* @param value Float value to convert.
* @param output Memory to write output characters.
* @return Number of bytes written.
*/
__device__ int float_to_string(double value, char* output)
{
// check for valid value
if (std::isnan(value)) {
memcpy(output, "NaN", 3);
return 3;
}
bool bneg = false;
if (signbit(value)) { // handles -0.0 too
value = -value;
bneg = true;
}
if (std::isinf(value)) {
if (bneg)
memcpy(output, "-Inf", 4);
else
memcpy(output, "Inf", 3);
return bneg ? 4 : 3;
}
// dissect value into components
unsigned int integer = 0, decimal = 0;
int exp10 = 0;
int decimal_places = dissect_value(value, integer, decimal, exp10);
//
// now build the string from the
// components: sign, integer, decimal, exp10, decimal_places
//
// sign
char* ptr = output;
if (bneg) *ptr++ = '-';
// integer
ptr = int2str(integer, ptr);
// decimal
*ptr++ = '.';
if (decimal_places) {
char buffer[10];
char* pb = buffer;
while (decimal_places--) {
*pb++ = (char)('0' + (decimal % 10));
decimal /= 10;
}
while (pb != buffer) // reverses the digits
*ptr++ = *--pb; // e.g. 54321 -> 12345
} else
*ptr++ = '0'; // always include at least .0
// exponent
if (exp10) {
*ptr++ = 'e';
if (exp10 < 0) {
*ptr++ = '-';
exp10 = -exp10;
} else
*ptr++ = '+';
if (exp10 < 10) *ptr++ = '0'; // extra zero-pad
ptr = int2str(exp10, ptr);
}
// done
return (int)(ptr - output); // number of bytes written
}
/**
* @brief Compute how man bytes are needed to hold the output string.
*
* @param value Float value to convert.
* @return Number of bytes required.
*/
__device__ int compute_ftos_size(double value)
{
if (std::isnan(value)) return 3; // NaN
bool bneg = false;
if (signbit(value)) { // handles -0.0 too
value = -value;
bneg = true;
}
if (std::isinf(value)) return 3 + (int)bneg; // Inf
// dissect float into parts
unsigned int integer = 0, decimal = 0;
int exp10 = 0;
int decimal_places = dissect_value(value, integer, decimal, exp10);
// now count up the components
// sign
int count = (int)bneg;
// integer
count += (int)(integer == 0);
while (integer > 0) {
integer /= 10;
++count;
} // log10(integer)
// decimal
++count; // decimal point
if (decimal_places)
count += decimal_places;
else
++count; // always include .0
// exponent
if (exp10) {
count += 2; // 'e±'
if (exp10 < 0) exp10 = -exp10;
count += (int)(exp10 < 10); // padding
while (exp10 > 0) {
exp10 /= 10;
++count;
} // log10(exp10)
}
return count;
}
};
template <typename FloatType>
struct from_floats_fn {
column_device_view d_floats;
size_type* d_offsets;
char* d_chars;
__device__ size_type compute_output_size(FloatType value)
{
ftos_converter fts;
return static_cast<size_type>(fts.compute_ftos_size(static_cast<double>(value)));
}
__device__ void float_to_string(size_type idx)
{
FloatType value = d_floats.element<FloatType>(idx);
ftos_converter fts;
fts.float_to_string(static_cast<double>(value), d_chars + d_offsets[idx]);
}
__device__ void operator()(size_type idx)
{
if (d_floats.is_null(idx)) {
if (d_chars == nullptr) { d_offsets[idx] = 0; }
return;
}
if (d_chars != nullptr) {
float_to_string(idx);
} else {
d_offsets[idx] = compute_output_size(d_floats.element<FloatType>(idx));
}
}
};
/**
* @brief This dispatch method is for converting floats into strings.
*
* The template function declaration ensures only float types are allowed.
*/
struct dispatch_from_floats_fn {
template <typename FloatType, std::enable_if_t<std::is_floating_point_v<FloatType>>* = nullptr>
std::unique_ptr<column> operator()(column_view const& floats,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr) const
{
size_type strings_count = floats.size();
auto column = column_device_view::create(floats, stream);
auto d_column = *column;
// copy the null mask
rmm::device_buffer null_mask = cudf::detail::copy_bitmask(floats, stream, mr);
auto [offsets, chars] =
make_strings_children(from_floats_fn<FloatType>{d_column}, strings_count, stream, mr);
return make_strings_column(strings_count,
std::move(offsets),
std::move(chars),
floats.null_count(),
std::move(null_mask));
}
// non-float types throw an exception
template <typename T, std::enable_if_t<not std::is_floating_point_v<T>>* = nullptr>
std::unique_ptr<column> operator()(column_view const&,
rmm::cuda_stream_view,
rmm::mr::device_memory_resource*) const
{
CUDF_FAIL("Values for from_floats function must be a float type.");
}
};
} // namespace
// This will convert all float column types into a strings column.
std::unique_ptr<column> from_floats(column_view const& floats,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = floats.size();
if (strings_count == 0) return make_empty_column(type_id::STRING);
return type_dispatcher(floats.type(), dispatch_from_floats_fn{}, floats, stream, mr);
}
} // namespace detail
// external API
std::unique_ptr<column> from_floats(column_view const& floats,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::from_floats(floats, stream, mr);
}
namespace detail {
std::unique_ptr<column> is_float(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto strings_column = column_device_view::create(input.parent(), stream);
auto d_column = *strings_column;
// create output column
auto results = make_numeric_column(data_type{type_id::BOOL8},
input.size(),
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto d_results = results->mutable_view().data<bool>();
// check strings for valid float chars
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(input.size()),
d_results,
[d_column] __device__(size_type idx) {
if (d_column.is_null(idx)) return false;
return is_float(d_column.element<string_view>(idx));
});
results->set_null_count(input.null_count());
return results;
}
} // namespace detail
// external API
std::unique_ptr<column> is_float(strings_column_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::is_float(input, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/strings
|
rapidsai_public_repos/cudf/cpp/src/strings/convert/convert_booleans.cu
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/convert/convert_booleans.hpp>
#include <cudf/strings/detail/converters.hpp>
#include <cudf/strings/detail/strings_children.cuh>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/traits.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include <thrust/transform.h>
namespace cudf {
namespace strings {
namespace detail {
// Convert strings column to boolean column
std::unique_ptr<column> to_booleans(strings_column_view const& input,
string_scalar const& true_string,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = input.size();
if (strings_count == 0) return make_numeric_column(data_type{type_id::BOOL8}, 0);
CUDF_EXPECTS(true_string.is_valid(stream) && true_string.size() > 0,
"Parameter true_string must not be empty.");
auto d_true = string_view(true_string.data(), true_string.size());
auto strings_column = column_device_view::create(input.parent(), stream);
auto d_strings = *strings_column;
// create output column copying the strings' null-mask
auto results = make_numeric_column(data_type{type_id::BOOL8},
strings_count,
cudf::detail::copy_bitmask(input.parent(), stream, mr),
input.null_count(),
stream,
mr);
auto results_view = results->mutable_view();
auto d_results = results_view.data<bool>();
thrust::transform(rmm::exec_policy(stream),
thrust::make_counting_iterator<size_type>(0),
thrust::make_counting_iterator<size_type>(strings_count),
d_results,
[d_strings, d_true] __device__(size_type idx) {
bool result = false;
if (!d_strings.is_null(idx))
result = d_strings.element<string_view>(idx).compare(d_true) == 0;
return result;
});
results->set_null_count(input.null_count());
return results;
}
} // namespace detail
// external API
std::unique_ptr<column> to_booleans(strings_column_view const& input,
string_scalar const& true_string,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::to_booleans(input, true_string, stream, mr);
}
namespace detail {
namespace {
struct from_booleans_fn {
column_device_view const d_column;
string_view d_true;
string_view d_false;
size_type* d_offsets{};
char* d_chars{};
__device__ void operator()(size_type idx) const
{
if (d_column.is_null(idx)) {
if (d_chars == nullptr) { d_offsets[idx] = 0; }
return;
}
if (d_chars != nullptr) {
auto const result = d_column.element<bool>(idx) ? d_true : d_false;
memcpy(d_chars + d_offsets[idx], result.data(), result.size_bytes());
} else {
d_offsets[idx] = d_column.element<bool>(idx) ? d_true.size_bytes() : d_false.size_bytes();
}
};
};
} // namespace
// Convert boolean column to strings column
std::unique_ptr<column> from_booleans(column_view const& booleans,
string_scalar const& true_string,
string_scalar const& false_string,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
size_type strings_count = booleans.size();
if (strings_count == 0) return make_empty_column(type_id::STRING);
CUDF_EXPECTS(booleans.type().id() == type_id::BOOL8, "Input column must be boolean type");
CUDF_EXPECTS(true_string.is_valid(stream) && true_string.size() > 0,
"Parameter true_string must not be empty.");
auto d_true = string_view(true_string.data(), true_string.size());
CUDF_EXPECTS(false_string.is_valid(stream) && false_string.size() > 0,
"Parameter false_string must not be empty.");
auto d_false = string_view(false_string.data(), false_string.size());
auto column = column_device_view::create(booleans, stream);
auto d_column = *column;
// copy null mask
rmm::device_buffer null_mask = cudf::detail::copy_bitmask(booleans, stream, mr);
auto [offsets, chars] =
make_strings_children(from_booleans_fn{d_column, d_true, d_false}, strings_count, stream, mr);
return make_strings_column(strings_count,
std::move(offsets),
std::move(chars),
booleans.null_count(),
std::move(null_mask));
}
} // namespace detail
// external API
std::unique_ptr<column> from_booleans(column_view const& booleans,
string_scalar const& true_string,
string_scalar const& false_string,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::from_booleans(booleans, true_string, false_string, stream, mr);
}
} // namespace strings
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/interop/dlpack.cpp
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/interop.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/lists/list_view.hpp>
#include <cudf/structs/struct_view.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <dlpack/dlpack.h>
#include <algorithm>
#include <cudf/utilities/traits.hpp>
namespace cudf {
namespace {
struct get_column_data_impl {
template <typename T, CUDF_ENABLE_IF(not is_rep_layout_compatible<T>())>
void const* operator()(column_view const& col)
{
CUDF_FAIL("Unsupported type to convert to dlpack.");
}
template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
void const* operator()(column_view const& col)
{
return col.data<T>();
}
};
template <>
void const* get_column_data_impl::operator()<string_view>(column_view const& col)
{
return nullptr;
}
void const* get_column_data(column_view const& col)
{
return type_dispatcher(col.type(), get_column_data_impl{}, col);
}
data_type DLDataType_to_data_type(DLDataType type)
{
CUDF_EXPECTS(type.lanes == 1, "Unsupported DLPack vector type");
if (type.code == kDLInt) {
switch (type.bits) {
case 8: return data_type(type_id::INT8);
case 16: return data_type(type_id::INT16);
case 32: return data_type(type_id::INT32);
case 64: return data_type(type_id::INT64);
default: CUDF_FAIL("Unsupported bitsize for kDLInt");
}
} else if (type.code == kDLUInt) {
switch (type.bits) {
case 8: return data_type(type_id::UINT8);
case 16: return data_type(type_id::UINT16);
case 32: return data_type(type_id::UINT32);
case 64: return data_type(type_id::UINT64);
default: CUDF_FAIL("Unsupported bitsize for kDLUInt");
}
} else if (type.code == kDLFloat) {
switch (type.bits) {
case 32: return data_type(type_id::FLOAT32);
case 64: return data_type(type_id::FLOAT64);
default: CUDF_FAIL("Unsupported bitsize for kDLFloat");
}
} else {
CUDF_FAIL("Invalid DLPack type code");
}
}
struct data_type_to_DLDataType_impl {
template <typename T, std::enable_if_t<is_numeric<T>()>* = nullptr>
DLDataType operator()()
{
uint8_t const bits{sizeof(T) * 8};
uint16_t const lanes{1};
if (std::is_floating_point_v<T>) {
return DLDataType{kDLFloat, bits, lanes};
} else if (std::is_signed_v<T>) {
return DLDataType{kDLInt, bits, lanes};
} else {
return DLDataType{kDLUInt, bits, lanes};
}
}
template <typename T, std::enable_if_t<not is_numeric<T>()>* = nullptr>
DLDataType operator()()
{
CUDF_FAIL("Conversion of non-numeric types to DLPack is unsupported");
}
};
DLDataType data_type_to_DLDataType(data_type type)
{
return type_dispatcher(type, data_type_to_DLDataType_impl{});
}
// Context object to own memory allocated for DLManagedTensor
struct dltensor_context {
int64_t shape[2];
int64_t strides[2];
rmm::device_buffer buffer;
static void deleter(DLManagedTensor* arg)
{
auto context = static_cast<dltensor_context*>(arg->manager_ctx);
delete context;
delete arg;
}
};
} // namespace
namespace detail {
std::unique_ptr<table> from_dlpack(DLManagedTensor const* managed_tensor,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_EXPECTS(nullptr != managed_tensor, "managed_tensor is null");
auto const& tensor = managed_tensor->dl_tensor;
// We can copy from host or device pointers
CUDF_EXPECTS(tensor.device.device_type == kDLCPU || tensor.device.device_type == kDLCUDA ||
tensor.device.device_type == kDLCUDAHost,
"DLTensor device type must be CPU, CUDA or CUDAHost");
// Make sure the current device ID matches the Tensor's device ID
if (tensor.device.device_type != kDLCPU) {
int device_id = 0;
CUDF_CUDA_TRY(cudaGetDevice(&device_id));
CUDF_EXPECTS(tensor.device.device_id == device_id, "DLTensor device ID must be current device");
}
// We only support 1D and 2D tensors with some restrictions on layout
if (tensor.ndim == 1) {
// 1D tensors must have dense layout (strides == nullptr <=> dense layout), or have shape (0,)
CUDF_EXPECTS(nullptr == tensor.strides || tensor.strides[0] == 1 || tensor.shape[0] == 0,
"from_dlpack of 1D DLTensor only for unit-stride data");
} else if (tensor.ndim == 2) {
CUDF_EXPECTS(
// Empty array is fine. If ncols == 0 then we get an empty dataframe
// irrespective of nrows, which is slightly different behaviour from
// cudf.DataFrame(np.empty((3, 0))) because there's no way to communicate
// the index information out with a table view if no columns exist.
(tensor.shape[0] == 0 || tensor.shape[1] == 0)
// (N, 1) is fine as long as the 1D array has dense layout
|| (tensor.shape[1] == 1 && (nullptr == tensor.strides || tensor.strides[0] == 1))
// Column major is fine as long as the fastest dimension has dense layout
|| (nullptr != tensor.strides && tensor.strides[0] == 1 &&
tensor.strides[1] >= tensor.shape[0]),
"from_dlpack of 2D DLTensor only for column-major unit-stride data");
} else {
CUDF_FAIL("DLTensor must be 1D or 2D");
}
CUDF_EXPECTS(tensor.shape[0] >= 0,
"DLTensor first dim should be of shape greater than or equal to 0.");
CUDF_EXPECTS(tensor.shape[0] <= std::numeric_limits<size_type>::max(),
"DLTensor first dim exceeds the column size limit",
std::overflow_error);
if (tensor.ndim > 1) {
CUDF_EXPECTS(tensor.shape[1] >= 0,
"DLTensor second dim should be of shape greater than or equal to 0.");
CUDF_EXPECTS(tensor.shape[1] <= std::numeric_limits<size_type>::max(),
"DLTensor second dim exceeds the column size limit",
std::overflow_error);
}
size_t const num_columns = (tensor.ndim == 2) ? static_cast<size_t>(tensor.shape[1]) : 1;
// Validate and convert data type to cudf
data_type const dtype = DLDataType_to_data_type(tensor.dtype);
size_t const byte_width = size_of(dtype);
auto const num_rows = static_cast<size_t>(tensor.shape[0]);
size_t const bytes = num_rows * byte_width;
// For 2D tensors, if the strides pointer is not null, then strides[1] is the
// number of elements (not bytes) between the start of each column
size_t const col_stride = (tensor.ndim == 2 && nullptr != tensor.strides)
? byte_width * tensor.strides[1]
: byte_width * num_rows;
auto tensor_data = reinterpret_cast<uintptr_t>(tensor.data) + tensor.byte_offset;
// Allocate columns and copy data from tensor
std::vector<std::unique_ptr<column>> columns(num_columns);
for (auto& col : columns) {
col = make_numeric_column(dtype, num_rows, mask_state::UNALLOCATED, stream, mr);
CUDF_CUDA_TRY(cudaMemcpyAsync(col->mutable_view().head<void>(),
reinterpret_cast<void*>(tensor_data),
bytes,
cudaMemcpyDefault,
stream.value()));
tensor_data += col_stride;
}
return std::make_unique<table>(std::move(columns));
}
DLManagedTensor* to_dlpack(table_view const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto const num_rows = input.num_rows();
auto const num_cols = input.num_columns();
if (num_rows == 0 && num_cols == 0) { return nullptr; }
// Ensure that type is convertible to DLDataType
data_type const type = input.column(0).type();
DLDataType const dltype = data_type_to_DLDataType(type);
// Ensure all columns are the same type
CUDF_EXPECTS(
std::all_of(input.begin(), input.end(), [type](auto const& col) { return col.type() == type; }),
"All columns required to have same data type");
// Ensure none of the columns have nulls
CUDF_EXPECTS(
std::none_of(input.begin(), input.end(), [](auto const& col) { return col.has_nulls(); }),
"Input required to have null count zero");
auto managed_tensor = std::make_unique<DLManagedTensor>();
auto context = std::make_unique<dltensor_context>();
DLTensor& tensor = managed_tensor->dl_tensor;
tensor.dtype = dltype;
tensor.ndim = (num_cols > 1) ? 2 : 1;
tensor.shape = context->shape;
tensor.shape[0] = num_rows;
if (tensor.ndim > 1) {
tensor.shape[1] = num_cols;
tensor.strides = context->strides;
tensor.strides[0] = num_rows > 1 ? 1 : 0;
tensor.strides[1] = num_rows;
}
CUDF_CUDA_TRY(cudaGetDevice(&tensor.device.device_id));
tensor.device.device_type = kDLCUDA;
// If there is only one column, then a 1D tensor can just copy the pointer
// to the data in the column, and the deleter should not delete the original
// data. However, this is inconsistent with the 2D cases where we must do a
// copy of each column's data into the dense tensor array. Also, if we don't
// copy, then the original column data could be changed, which would change
// the contents of the tensor, which might be surprising or cause issues.
// Therefore, for now we ALWAYS do a copy of the data. If this becomes
// a performance issue we can reevaluate in the future.
size_t const stride_bytes = num_rows * size_of(type);
size_t const total_bytes = stride_bytes * num_cols;
context->buffer = rmm::device_buffer(total_bytes, stream, mr);
tensor.data = context->buffer.data();
auto tensor_data = reinterpret_cast<uintptr_t>(tensor.data);
for (auto const& col : input) {
CUDF_CUDA_TRY(cudaMemcpyAsync(reinterpret_cast<void*>(tensor_data),
get_column_data(col),
stride_bytes,
cudaMemcpyDefault,
stream.value()));
tensor_data += stride_bytes;
}
// Defer ownership of managed tensor to caller
managed_tensor->deleter = dltensor_context::deleter;
managed_tensor->manager_ctx = context.release();
// synchronize the stream because after the return the data may be accessed from the host before
// the above `cudaMemcpyAsync` calls have completed their copies (especially if pinned host
// memory is used).
stream.synchronize();
return managed_tensor.release();
}
} // namespace detail
std::unique_ptr<table> from_dlpack(DLManagedTensor const* managed_tensor,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::from_dlpack(managed_tensor, cudf::get_default_stream(), mr);
}
DLManagedTensor* to_dlpack(table_view const& input, rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::to_dlpack(input, cudf::get_default_stream(), mr);
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/interop/to_arrow.cu
|
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column.hpp>
#include <cudf/column/column_factories.hpp>
#include <cudf/column/column_view.hpp>
#include <cudf/copying.hpp>
#include <cudf/detail/interop.hpp>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/unary.hpp>
#include <cudf/dictionary/dictionary_column_view.hpp>
#include <cudf/interop.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/traits.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/exec_policy.hpp>
#include <rmm/mr/device/per_device_resource.hpp>
#include <thrust/copy.h>
#include <thrust/for_each.h>
#include <thrust/iterator/counting_iterator.h>
#include "detail/arrow_allocator.hpp"
namespace cudf {
namespace detail {
namespace {
/**
* @brief Create arrow data buffer from given cudf column
*/
template <typename T>
std::shared_ptr<arrow::Buffer> fetch_data_buffer(column_view input_view,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
int64_t const data_size_in_bytes = sizeof(T) * input_view.size();
auto data_buffer = allocate_arrow_buffer(data_size_in_bytes, ar_mr);
CUDF_CUDA_TRY(cudaMemcpyAsync(data_buffer->mutable_data(),
input_view.data<T>(),
data_size_in_bytes,
cudaMemcpyDefault,
stream.value()));
return std::move(data_buffer);
}
/**
* @brief Create arrow buffer of mask from given cudf column
*/
std::shared_ptr<arrow::Buffer> fetch_mask_buffer(column_view input_view,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
int64_t const mask_size_in_bytes = cudf::bitmask_allocation_size_bytes(input_view.size());
if (input_view.has_nulls()) {
auto mask_buffer = allocate_arrow_bitmap(static_cast<int64_t>(input_view.size()), ar_mr);
CUDF_CUDA_TRY(cudaMemcpyAsync(
mask_buffer->mutable_data(),
(input_view.offset() > 0)
? cudf::detail::copy_bitmask(input_view, stream, rmm::mr::get_current_device_resource())
.data()
: input_view.null_mask(),
mask_size_in_bytes,
cudaMemcpyDefault,
stream.value()));
// Resets all padded bits to 0
mask_buffer->ZeroPadding();
return mask_buffer;
}
return nullptr;
}
/**
* @brief Functor to convert cudf column to arrow array
*/
struct dispatch_to_arrow {
/**
* @brief Creates vector Arrays from given cudf column children
*/
std::vector<std::shared_ptr<arrow::Array>> fetch_child_array(
column_view input_view,
std::vector<column_metadata> const& metadata,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
std::vector<std::shared_ptr<arrow::Array>> child_arrays;
std::transform(
input_view.child_begin(),
input_view.child_end(),
metadata.begin(),
std::back_inserter(child_arrays),
[&ar_mr, &stream](auto const& child, auto const& meta) {
return type_dispatcher(
child.type(), dispatch_to_arrow{}, child, child.type().id(), meta, ar_mr, stream);
});
return child_arrays;
}
template <typename T, CUDF_ENABLE_IF(not is_rep_layout_compatible<T>())>
std::shared_ptr<arrow::Array> operator()(
column_view, cudf::type_id, column_metadata const&, arrow::MemoryPool*, rmm::cuda_stream_view)
{
CUDF_FAIL("Unsupported type for to_arrow.");
}
template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
std::shared_ptr<arrow::Array> operator()(column_view input_view,
cudf::type_id id,
column_metadata const&,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
return to_arrow_array(id,
static_cast<int64_t>(input_view.size()),
fetch_data_buffer<T>(input_view, ar_mr, stream),
fetch_mask_buffer(input_view, ar_mr, stream),
static_cast<int64_t>(input_view.null_count()));
}
};
// Convert decimal types from libcudf to arrow where those types are not
// directly supported by Arrow. These types must be fit into 128 bits, the
// smallest decimal resolution supported by Arrow.
template <typename DeviceType>
std::shared_ptr<arrow::Array> unsupported_decimals_to_arrow(column_view input,
int32_t precision,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
constexpr size_type BIT_WIDTH_RATIO = sizeof(__int128_t) / sizeof(DeviceType);
rmm::device_uvector<DeviceType> buf(input.size() * BIT_WIDTH_RATIO, stream);
auto count = thrust::make_counting_iterator(0);
thrust::for_each(
rmm::exec_policy(cudf::get_default_stream()),
count,
count + input.size(),
[in = input.begin<DeviceType>(), out = buf.data(), BIT_WIDTH_RATIO] __device__(auto in_idx) {
auto const out_idx = in_idx * BIT_WIDTH_RATIO;
// The lowest order bits are the value, the remainder
// simply matches the sign bit to satisfy the two's
// complement integer representation of negative numbers.
out[out_idx] = in[in_idx];
#pragma unroll BIT_WIDTH_RATIO - 1
for (auto i = 1; i < BIT_WIDTH_RATIO; ++i) {
out[out_idx + i] = in[in_idx] < 0 ? -1 : 0;
}
});
auto const buf_size_in_bytes = buf.size() * sizeof(DeviceType);
auto data_buffer = allocate_arrow_buffer(buf_size_in_bytes, ar_mr);
CUDF_CUDA_TRY(cudaMemcpyAsync(
data_buffer->mutable_data(), buf.data(), buf_size_in_bytes, cudaMemcpyDefault, stream.value()));
auto type = arrow::decimal(precision, -input.type().scale());
auto mask = fetch_mask_buffer(input, ar_mr, stream);
auto buffers = std::vector<std::shared_ptr<arrow::Buffer>>{mask, std::move(data_buffer)};
auto data = std::make_shared<arrow::ArrayData>(type, input.size(), buffers);
return std::make_shared<arrow::Decimal128Array>(data);
}
template <>
std::shared_ptr<arrow::Array> dispatch_to_arrow::operator()<numeric::decimal32>(
column_view input,
cudf::type_id,
column_metadata const&,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
using DeviceType = int32_t;
return unsupported_decimals_to_arrow<DeviceType>(
input, cudf::detail::max_precision<DeviceType>(), ar_mr, stream);
}
template <>
std::shared_ptr<arrow::Array> dispatch_to_arrow::operator()<numeric::decimal64>(
column_view input,
cudf::type_id,
column_metadata const&,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
using DeviceType = int64_t;
return unsupported_decimals_to_arrow<DeviceType>(
input, cudf::detail::max_precision<DeviceType>(), ar_mr, stream);
}
template <>
std::shared_ptr<arrow::Array> dispatch_to_arrow::operator()<numeric::decimal128>(
column_view input,
cudf::type_id,
column_metadata const&,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
using DeviceType = __int128_t;
auto const max_precision = cudf::detail::max_precision<DeviceType>();
rmm::device_uvector<DeviceType> buf(input.size(), stream);
thrust::copy(rmm::exec_policy(stream), //
input.begin<DeviceType>(),
input.end<DeviceType>(),
buf.begin());
auto const buf_size_in_bytes = buf.size() * sizeof(DeviceType);
auto data_buffer = allocate_arrow_buffer(buf_size_in_bytes, ar_mr);
CUDF_CUDA_TRY(cudaMemcpyAsync(
data_buffer->mutable_data(), buf.data(), buf_size_in_bytes, cudaMemcpyDefault, stream.value()));
auto type = arrow::decimal(max_precision, -input.type().scale());
auto mask = fetch_mask_buffer(input, ar_mr, stream);
auto buffers = std::vector<std::shared_ptr<arrow::Buffer>>{mask, std::move(data_buffer)};
auto data = std::make_shared<arrow::ArrayData>(type, input.size(), buffers);
return std::make_shared<arrow::Decimal128Array>(data);
}
template <>
std::shared_ptr<arrow::Array> dispatch_to_arrow::operator()<bool>(column_view input,
cudf::type_id id,
column_metadata const&,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
auto bitmask = bools_to_mask(input, stream, rmm::mr::get_current_device_resource());
auto data_buffer = allocate_arrow_buffer(static_cast<int64_t>(bitmask.first->size()), ar_mr);
CUDF_CUDA_TRY(cudaMemcpyAsync(data_buffer->mutable_data(),
bitmask.first->data(),
bitmask.first->size(),
cudaMemcpyDefault,
stream.value()));
return to_arrow_array(id,
static_cast<int64_t>(input.size()),
std::move(data_buffer),
fetch_mask_buffer(input, ar_mr, stream),
static_cast<int64_t>(input.null_count()));
}
template <>
std::shared_ptr<arrow::Array> dispatch_to_arrow::operator()<cudf::string_view>(
column_view input,
cudf::type_id,
column_metadata const&,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
std::unique_ptr<column> tmp_column =
((input.offset() != 0) or
((input.num_children() == 2) and (input.child(0).size() - 1 != input.size())))
? std::make_unique<cudf::column>(input, stream)
: nullptr;
column_view input_view = (tmp_column != nullptr) ? tmp_column->view() : input;
auto child_arrays = fetch_child_array(input_view, {{}, {}}, ar_mr, stream);
if (child_arrays.empty()) {
// Empty string will have only one value in offset of 4 bytes
auto tmp_offset_buffer = allocate_arrow_buffer(4, ar_mr);
auto tmp_data_buffer = allocate_arrow_buffer(0, ar_mr);
tmp_offset_buffer->mutable_data()[0] = 0;
return std::make_shared<arrow::StringArray>(
0, std::move(tmp_offset_buffer), std::move(tmp_data_buffer));
}
auto offset_buffer = child_arrays[0]->data()->buffers[1];
auto data_buffer = child_arrays[1]->data()->buffers[1];
return std::make_shared<arrow::StringArray>(static_cast<int64_t>(input_view.size()),
offset_buffer,
data_buffer,
fetch_mask_buffer(input_view, ar_mr, stream),
static_cast<int64_t>(input_view.null_count()));
}
template <>
std::shared_ptr<arrow::Array> dispatch_to_arrow::operator()<cudf::struct_view>(
column_view input,
cudf::type_id,
column_metadata const& metadata,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
CUDF_EXPECTS(metadata.children_meta.size() == static_cast<std::size_t>(input.num_children()),
"Number of field names and number of children doesn't match\n");
std::unique_ptr<column> tmp_column = nullptr;
if (input.offset() != 0) { tmp_column = std::make_unique<cudf::column>(input, stream); }
column_view input_view = (tmp_column != nullptr) ? tmp_column->view() : input;
auto child_arrays = fetch_child_array(input_view, metadata.children_meta, ar_mr, stream);
auto mask = fetch_mask_buffer(input_view, ar_mr, stream);
std::vector<std::shared_ptr<arrow::Field>> fields;
std::transform(child_arrays.cbegin(),
child_arrays.cend(),
metadata.children_meta.cbegin(),
std::back_inserter(fields),
[](auto const array, auto const meta) {
return std::make_shared<arrow::Field>(
meta.name, array->type(), array->null_count() > 0);
});
auto dtype = std::make_shared<arrow::StructType>(fields);
return std::make_shared<arrow::StructArray>(dtype,
static_cast<int64_t>(input_view.size()),
child_arrays,
mask,
static_cast<int64_t>(input_view.null_count()));
}
template <>
std::shared_ptr<arrow::Array> dispatch_to_arrow::operator()<cudf::list_view>(
column_view input,
cudf::type_id,
column_metadata const& metadata,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
std::unique_ptr<column> tmp_column = nullptr;
if ((input.offset() != 0) or
((input.num_children() == 2) and (input.child(0).size() - 1 != input.size()))) {
tmp_column = std::make_unique<cudf::column>(input, stream);
}
column_view input_view = (tmp_column != nullptr) ? tmp_column->view() : input;
auto children_meta =
metadata.children_meta.empty() ? std::vector<column_metadata>{{}, {}} : metadata.children_meta;
auto child_arrays = fetch_child_array(input_view, children_meta, ar_mr, stream);
if (child_arrays.empty()) {
return std::make_shared<arrow::ListArray>(arrow::list(arrow::null()), 0, nullptr, nullptr);
}
auto offset_buffer = child_arrays[0]->data()->buffers[1];
auto data = child_arrays[1];
return std::make_shared<arrow::ListArray>(arrow::list(data->type()),
static_cast<int64_t>(input_view.size()),
offset_buffer,
data,
fetch_mask_buffer(input_view, ar_mr, stream),
static_cast<int64_t>(input_view.null_count()));
}
template <>
std::shared_ptr<arrow::Array> dispatch_to_arrow::operator()<cudf::dictionary32>(
column_view input,
cudf::type_id,
column_metadata const& metadata,
arrow::MemoryPool* ar_mr,
rmm::cuda_stream_view stream)
{
// Arrow dictionary requires indices to be signed integer
std::unique_ptr<column> dict_indices =
detail::cast(cudf::dictionary_column_view(input).get_indices_annotated(),
cudf::data_type{type_id::INT32},
stream,
rmm::mr::get_current_device_resource());
auto indices = dispatch_to_arrow{}.operator()<int32_t>(
dict_indices->view(), dict_indices->type().id(), {}, ar_mr, stream);
auto dict_keys = cudf::dictionary_column_view(input).keys();
auto dictionary =
type_dispatcher(dict_keys.type(),
dispatch_to_arrow{},
dict_keys,
dict_keys.type().id(),
metadata.children_meta.empty() ? column_metadata{} : metadata.children_meta[0],
ar_mr,
stream);
return std::make_shared<arrow::DictionaryArray>(
arrow::dictionary(indices->type(), dictionary->type()), indices, dictionary);
}
} // namespace
std::shared_ptr<arrow::Table> to_arrow(table_view input,
std::vector<column_metadata> const& metadata,
rmm::cuda_stream_view stream,
arrow::MemoryPool* ar_mr)
{
CUDF_EXPECTS((metadata.size() == static_cast<std::size_t>(input.num_columns())),
"columns' metadata should be equal to number of columns in table");
std::vector<std::shared_ptr<arrow::Array>> arrays;
std::vector<std::shared_ptr<arrow::Field>> fields;
std::transform(
input.begin(),
input.end(),
metadata.begin(),
std::back_inserter(arrays),
[&](auto const& c, auto const& meta) {
return c.type().id() != type_id::EMPTY
? type_dispatcher(
c.type(), detail::dispatch_to_arrow{}, c, c.type().id(), meta, ar_mr, stream)
: std::make_shared<arrow::NullArray>(c.size());
});
std::transform(
arrays.begin(),
arrays.end(),
metadata.begin(),
std::back_inserter(fields),
[](auto const& array, auto const& meta) { return arrow::field(meta.name, array->type()); });
auto result = arrow::Table::Make(arrow::schema(fields), arrays);
// synchronize the stream because after the return the data may be accessed from the host before
// the above `cudaMemcpyAsync` calls have completed their copies (especially if pinned host
// memory is used).
stream.synchronize();
return result;
}
std::shared_ptr<arrow::Scalar> to_arrow(cudf::scalar const& input,
column_metadata const& metadata,
rmm::cuda_stream_view stream,
arrow::MemoryPool* ar_mr)
{
auto const column = cudf::make_column_from_scalar(input, 1, stream);
cudf::table_view const tv{{column->view()}};
auto const arrow_table = cudf::to_arrow(tv, {metadata}, stream);
auto const ac = arrow_table->column(0);
auto const maybe_scalar = ac->GetScalar(0);
if (!maybe_scalar.ok()) { CUDF_FAIL("Failed to produce a scalar"); }
return maybe_scalar.ValueOrDie();
}
} // namespace detail
std::shared_ptr<arrow::Table> to_arrow(table_view input,
std::vector<column_metadata> const& metadata,
rmm::cuda_stream_view stream,
arrow::MemoryPool* ar_mr)
{
CUDF_FUNC_RANGE();
return detail::to_arrow(input, metadata, stream, ar_mr);
}
std::shared_ptr<arrow::Scalar> to_arrow(cudf::scalar const& input,
column_metadata const& metadata,
rmm::cuda_stream_view stream,
arrow::MemoryPool* ar_mr)
{
CUDF_FUNC_RANGE();
return detail::to_arrow(input, metadata, stream, ar_mr);
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/interop/from_arrow.cu
|
/*
* Copyright (c) 2020-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/column/column_factories.hpp>
#include <cudf/column/column_view.hpp>
#include <cudf/detail/concatenate.hpp>
#include <cudf/detail/copy.hpp>
#include <cudf/detail/interop.hpp>
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/transform.hpp>
#include <cudf/detail/unary.hpp>
#include <cudf/dictionary/dictionary_factories.hpp>
#include <cudf/interop.hpp>
#include <cudf/null_mask.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/types.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/traits.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_buffer.hpp>
#include <thrust/gather.h>
namespace cudf {
namespace detail {
data_type arrow_to_cudf_type(arrow::DataType const& arrow_type)
{
switch (arrow_type.id()) {
case arrow::Type::NA: return data_type(type_id::EMPTY);
case arrow::Type::BOOL: return data_type(type_id::BOOL8);
case arrow::Type::INT8: return data_type(type_id::INT8);
case arrow::Type::INT16: return data_type(type_id::INT16);
case arrow::Type::INT32: return data_type(type_id::INT32);
case arrow::Type::INT64: return data_type(type_id::INT64);
case arrow::Type::UINT8: return data_type(type_id::UINT8);
case arrow::Type::UINT16: return data_type(type_id::UINT16);
case arrow::Type::UINT32: return data_type(type_id::UINT32);
case arrow::Type::UINT64: return data_type(type_id::UINT64);
case arrow::Type::FLOAT: return data_type(type_id::FLOAT32);
case arrow::Type::DOUBLE: return data_type(type_id::FLOAT64);
case arrow::Type::DATE32: return data_type(type_id::TIMESTAMP_DAYS);
case arrow::Type::TIMESTAMP: {
auto type = static_cast<arrow::TimestampType const*>(&arrow_type);
switch (type->unit()) {
case arrow::TimeUnit::type::SECOND: return data_type(type_id::TIMESTAMP_SECONDS);
case arrow::TimeUnit::type::MILLI: return data_type(type_id::TIMESTAMP_MILLISECONDS);
case arrow::TimeUnit::type::MICRO: return data_type(type_id::TIMESTAMP_MICROSECONDS);
case arrow::TimeUnit::type::NANO: return data_type(type_id::TIMESTAMP_NANOSECONDS);
default: CUDF_FAIL("Unsupported timestamp unit in arrow");
}
}
case arrow::Type::DURATION: {
auto type = static_cast<arrow::DurationType const*>(&arrow_type);
switch (type->unit()) {
case arrow::TimeUnit::type::SECOND: return data_type(type_id::DURATION_SECONDS);
case arrow::TimeUnit::type::MILLI: return data_type(type_id::DURATION_MILLISECONDS);
case arrow::TimeUnit::type::MICRO: return data_type(type_id::DURATION_MICROSECONDS);
case arrow::TimeUnit::type::NANO: return data_type(type_id::DURATION_NANOSECONDS);
default: CUDF_FAIL("Unsupported duration unit in arrow");
}
}
case arrow::Type::STRING: return data_type(type_id::STRING);
case arrow::Type::DICTIONARY: return data_type(type_id::DICTIONARY32);
case arrow::Type::LIST: return data_type(type_id::LIST);
case arrow::Type::DECIMAL: {
auto const type = static_cast<arrow::Decimal128Type const*>(&arrow_type);
return data_type{type_id::DECIMAL128, -type->scale()};
}
case arrow::Type::STRUCT: return data_type(type_id::STRUCT);
default: CUDF_FAIL("Unsupported type_id conversion to cudf");
}
}
namespace {
/**
* @brief Functor to return column for a corresponding arrow array. column
* is formed from buffer underneath the arrow array along with any offset and
* change in length that array has.
*/
struct dispatch_to_cudf_column {
/**
* @brief Returns mask from an array without any offsets.
*/
std::unique_ptr<rmm::device_buffer> get_mask_buffer(arrow::Array const& array,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (array.null_bitmap_data() == nullptr) {
return std::make_unique<rmm::device_buffer>(0, stream, mr);
}
auto const null_bitmap_size = array.null_bitmap()->size();
auto const allocation_size =
bitmask_allocation_size_bytes(static_cast<size_type>(null_bitmap_size * CHAR_BIT));
auto mask = std::make_unique<rmm::device_buffer>(allocation_size, stream, mr);
auto mask_buffer = array.null_bitmap();
CUDF_CUDA_TRY(cudaMemcpyAsync(mask->data(),
reinterpret_cast<uint8_t const*>(mask_buffer->address()),
null_bitmap_size,
cudaMemcpyDefault,
stream.value()));
// Zero-initialize trailing padding bytes
auto const num_trailing_bytes = allocation_size - null_bitmap_size;
if (num_trailing_bytes > 0) {
auto trailing_bytes = static_cast<uint8_t*>(mask->data()) + null_bitmap_size;
CUDF_CUDA_TRY(cudaMemsetAsync(trailing_bytes, 0, num_trailing_bytes, stream.value()));
}
return mask;
}
template <typename T, CUDF_ENABLE_IF(not is_rep_layout_compatible<T>())>
std::unique_ptr<column> operator()(
arrow::Array const&, data_type, bool, rmm::cuda_stream_view, rmm::mr::device_memory_resource*)
{
CUDF_FAIL("Unsupported type in from_arrow.");
}
template <typename T, CUDF_ENABLE_IF(is_rep_layout_compatible<T>())>
std::unique_ptr<column> operator()(arrow::Array const& array,
data_type type,
bool skip_mask,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto data_buffer = array.data()->buffers[1];
size_type const num_rows = array.length();
auto const has_nulls = skip_mask ? false : array.null_bitmap_data() != nullptr;
auto col = make_fixed_width_column(type, num_rows, mask_state::UNALLOCATED, stream, mr);
auto mutable_column_view = col->mutable_view();
CUDF_CUDA_TRY(cudaMemcpyAsync(
mutable_column_view.data<T>(),
reinterpret_cast<uint8_t const*>(data_buffer->address()) + array.offset() * sizeof(T),
sizeof(T) * num_rows,
cudaMemcpyDefault,
stream.value()));
if (has_nulls) {
auto tmp_mask = get_mask_buffer(array, stream, mr);
// If array is sliced, we have to copy whole mask and then take copy.
auto out_mask = (num_rows == static_cast<size_type>(data_buffer->size() / sizeof(T)))
? std::move(*tmp_mask)
: cudf::detail::copy_bitmask(static_cast<bitmask_type*>(tmp_mask->data()),
array.offset(),
array.offset() + num_rows,
stream,
mr);
col->set_null_mask(std::move(out_mask), array.null_count());
}
return col;
}
};
std::unique_ptr<column> get_empty_type_column(size_type size)
{
// this abomination is required by cuDF Python, which needs to handle
// [PyArrow null arrays](https://arrow.apache.org/docs/python/generated/pyarrow.NullArray.html)
// of finite length
return std::make_unique<column>(
data_type(type_id::EMPTY), size, rmm::device_buffer{}, rmm::device_buffer{}, size);
}
/**
* @brief Returns cudf column formed from given arrow array
* This has been introduced to take care of compiler error "error: explicit specialization of
* function must precede its first use"
*/
std::unique_ptr<column> get_column(arrow::Array const& array,
data_type type,
bool skip_mask,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);
template <>
std::unique_ptr<column> dispatch_to_cudf_column::operator()<numeric::decimal128>(
arrow::Array const& array,
data_type type,
bool skip_mask,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
using DeviceType = __int128_t;
auto data_buffer = array.data()->buffers[1];
auto const num_rows = static_cast<size_type>(array.length());
auto col = make_fixed_width_column(type, num_rows, mask_state::UNALLOCATED, stream, mr);
auto mutable_column_view = col->mutable_view();
CUDF_CUDA_TRY(cudaMemcpyAsync(
mutable_column_view.data<DeviceType>(),
reinterpret_cast<uint8_t const*>(data_buffer->address()) + array.offset() * sizeof(DeviceType),
sizeof(DeviceType) * num_rows,
cudaMemcpyDefault,
stream.value()));
auto null_mask = [&] {
if (not skip_mask and array.null_bitmap_data()) {
auto temp_mask = get_mask_buffer(array, stream, mr);
// If array is sliced, we have to copy whole mask and then take copy.
return (num_rows == static_cast<size_type>(data_buffer->size() / sizeof(DeviceType)))
? std::move(*temp_mask.release())
: cudf::detail::copy_bitmask(static_cast<bitmask_type*>(temp_mask->data()),
array.offset(),
array.offset() + num_rows,
stream,
mr);
}
return rmm::device_buffer{};
}();
col->set_null_mask(std::move(null_mask), array.null_count());
return col;
}
template <>
std::unique_ptr<column> dispatch_to_cudf_column::operator()<bool>(
arrow::Array const& array,
data_type,
bool skip_mask,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto data_buffer = array.data()->buffers[1];
// mask-to-bools expects the mask to be bitmask_type aligned/padded
auto data = rmm::device_buffer(
cudf::bitmask_allocation_size_bytes(data_buffer->size() * CHAR_BIT), stream, mr);
CUDF_CUDA_TRY(cudaMemcpyAsync(data.data(),
reinterpret_cast<uint8_t const*>(data_buffer->address()),
data_buffer->size(),
cudaMemcpyDefault,
stream.value()));
auto out_col = mask_to_bools(static_cast<bitmask_type*>(data.data()),
array.offset(),
array.offset() + array.length(),
stream,
mr);
auto const has_nulls = skip_mask ? false : array.null_bitmap_data() != nullptr;
if (has_nulls) {
auto out_mask =
detail::copy_bitmask(static_cast<bitmask_type*>(get_mask_buffer(array, stream, mr)->data()),
array.offset(),
array.offset() + array.length(),
stream,
mr);
out_col->set_null_mask(std::move(out_mask), array.null_count());
}
return out_col;
}
template <>
std::unique_ptr<column> dispatch_to_cudf_column::operator()<cudf::string_view>(
arrow::Array const& array,
data_type,
bool,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (array.length() == 0) { return make_empty_column(type_id::STRING); }
auto str_array = static_cast<arrow::StringArray const*>(&array);
auto offset_array = std::make_unique<arrow::Int32Array>(
str_array->value_offsets()->size() / sizeof(int32_t), str_array->value_offsets(), nullptr);
auto char_array = std::make_unique<arrow::Int8Array>(
str_array->value_data()->size(), str_array->value_data(), nullptr);
auto offsets_column = dispatch_to_cudf_column{}.operator()<int32_t>(
*offset_array, data_type(type_id::INT32), true, stream, mr);
auto chars_column = dispatch_to_cudf_column{}.operator()<int8_t>(
*char_array, data_type(type_id::INT8), true, stream, mr);
auto const num_rows = offsets_column->size() - 1;
auto out_col = make_strings_column(num_rows,
std::move(offsets_column),
std::move(chars_column),
array.null_count(),
std::move(*get_mask_buffer(array, stream, mr)));
return num_rows == array.length()
? std::move(out_col)
: std::make_unique<column>(
cudf::detail::slice(out_col->view(),
static_cast<size_type>(array.offset()),
static_cast<size_type>(array.offset() + array.length()),
stream),
stream,
mr);
}
template <>
std::unique_ptr<column> dispatch_to_cudf_column::operator()<cudf::dictionary32>(
arrow::Array const& array,
data_type,
bool,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto dict_array = static_cast<arrow::DictionaryArray const*>(&array);
auto dict_type = arrow_to_cudf_type(*(dict_array->dictionary()->type()));
auto keys_column = get_column(*(dict_array->dictionary()), dict_type, true, stream, mr);
auto ind_type = arrow_to_cudf_type(*(dict_array->indices()->type()));
auto indices_column = get_column(*(dict_array->indices()), ind_type, false, stream, mr);
// If index type is not of type uint32_t, then cast it to uint32_t
auto const dict_indices_type = data_type{type_id::UINT32};
if (indices_column->type().id() != dict_indices_type.id())
indices_column = cudf::detail::cast(indices_column->view(), dict_indices_type, stream, mr);
// Child columns shouldn't have masks and we need the mask in main column
auto column_contents = indices_column->release();
indices_column = std::make_unique<column>(dict_indices_type,
static_cast<size_type>(array.length()),
std::move(*(column_contents.data)),
rmm::device_buffer{},
0);
return make_dictionary_column(std::move(keys_column),
std::move(indices_column),
std::move(*(column_contents.null_mask)),
array.null_count());
}
template <>
std::unique_ptr<column> dispatch_to_cudf_column::operator()<cudf::struct_view>(
arrow::Array const& array,
data_type,
bool,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto struct_array = static_cast<arrow::StructArray const*>(&array);
std::vector<std::unique_ptr<column>> child_columns;
// Offsets have already been applied to child
arrow::ArrayVector array_children = struct_array->fields();
std::transform(array_children.cbegin(),
array_children.cend(),
std::back_inserter(child_columns),
[&mr, &stream](auto const& child_array) {
auto type = arrow_to_cudf_type(*(child_array->type()));
return get_column(*child_array, type, false, stream, mr);
});
auto out_mask = std::move(*(get_mask_buffer(array, stream, mr)));
if (struct_array->null_bitmap_data() != nullptr) {
out_mask = detail::copy_bitmask(static_cast<bitmask_type*>(out_mask.data()),
array.offset(),
array.offset() + array.length(),
stream,
mr);
}
return make_structs_column(
array.length(), move(child_columns), array.null_count(), std::move(out_mask), stream, mr);
}
template <>
std::unique_ptr<column> dispatch_to_cudf_column::operator()<cudf::list_view>(
arrow::Array const& array,
data_type,
bool,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
auto list_array = static_cast<arrow::ListArray const*>(&array);
auto offset_array = std::make_unique<arrow::Int32Array>(
list_array->value_offsets()->size() / sizeof(int32_t), list_array->value_offsets(), nullptr);
auto offsets_column = dispatch_to_cudf_column{}.operator()<int32_t>(
*offset_array, data_type(type_id::INT32), true, stream, mr);
auto child_type = arrow_to_cudf_type(*(list_array->values()->type()));
auto child_column = get_column(*(list_array->values()), child_type, false, stream, mr);
auto const num_rows = offsets_column->size() - 1;
auto out_col = make_lists_column(num_rows,
std::move(offsets_column),
std::move(child_column),
array.null_count(),
std::move(*get_mask_buffer(array, stream, mr)),
stream,
mr);
return num_rows == array.length()
? std::move(out_col)
: std::make_unique<column>(
cudf::detail::slice(out_col->view(),
static_cast<size_type>(array.offset()),
static_cast<size_type>(array.offset() + array.length()),
stream),
stream,
mr);
}
std::unique_ptr<column> get_column(arrow::Array const& array,
data_type type,
bool skip_mask,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return type.id() != type_id::EMPTY
? type_dispatcher(type, dispatch_to_cudf_column{}, array, type, skip_mask, stream, mr)
: get_empty_type_column(array.length());
}
struct BuilderGenerator {
template <typename T,
CUDF_ENABLE_IF(!std::is_same_v<T, arrow::ListType> &&
!std::is_same_v<T, arrow::StructType>)>
std::shared_ptr<arrow::ArrayBuilder> operator()(std::shared_ptr<arrow::DataType> const& type)
{
return std::make_shared<typename arrow::TypeTraits<T>::BuilderType>(
type, arrow::default_memory_pool());
}
template <typename T,
CUDF_ENABLE_IF(std::is_same_v<T, arrow::ListType> ||
std::is_same_v<T, arrow::StructType>)>
std::shared_ptr<arrow::ArrayBuilder> operator()(std::shared_ptr<arrow::DataType> const& type)
{
CUDF_FAIL("Type not supported by BuilderGenerator");
}
};
std::shared_ptr<arrow::ArrayBuilder> make_builder(std::shared_ptr<arrow::DataType> const& type)
{
switch (type->id()) {
case arrow::Type::STRUCT: {
std::vector<std::shared_ptr<arrow::ArrayBuilder>> field_builders;
for (auto field : type->fields()) {
auto const vt = field->type();
if (vt->id() == arrow::Type::STRUCT || vt->id() == arrow::Type::LIST) {
field_builders.push_back(make_builder(vt));
} else {
field_builders.push_back(arrow_type_dispatcher(*vt, BuilderGenerator{}, vt));
}
}
return std::make_shared<arrow::StructBuilder>(
type, arrow::default_memory_pool(), field_builders);
}
case arrow::Type::LIST: {
return std::make_shared<arrow::ListBuilder>(arrow::default_memory_pool(),
make_builder(type->field(0)->type()));
}
default: {
return arrow_type_dispatcher(*type, BuilderGenerator{}, type);
}
}
}
} // namespace
std::unique_ptr<table> from_arrow(arrow::Table const& input_table,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (input_table.num_columns() == 0) { return std::make_unique<table>(); }
std::vector<std::unique_ptr<column>> columns;
auto chunked_arrays = input_table.columns();
std::transform(chunked_arrays.begin(),
chunked_arrays.end(),
std::back_inserter(columns),
[&mr, &stream](auto const& chunked_array) {
std::vector<std::unique_ptr<column>> concat_columns;
auto cudf_type = arrow_to_cudf_type(*(chunked_array->type()));
auto array_chunks = chunked_array->chunks();
if (cudf_type.id() == type_id::EMPTY) {
return get_empty_type_column(chunked_array->length());
}
std::transform(array_chunks.begin(),
array_chunks.end(),
std::back_inserter(concat_columns),
[&cudf_type, &mr, &stream](auto const& array_chunk) {
return get_column(*array_chunk, cudf_type, false, stream, mr);
});
if (concat_columns.empty()) {
return std::make_unique<column>(
cudf_type, 0, rmm::device_buffer{}, rmm::device_buffer{}, 0);
} else if (concat_columns.size() == 1) {
return std::move(concat_columns[0]);
}
std::vector<cudf::column_view> column_views;
std::transform(concat_columns.begin(),
concat_columns.end(),
std::back_inserter(column_views),
[](auto const& col) { return col->view(); });
return cudf::detail::concatenate(column_views, stream, mr);
});
return std::make_unique<table>(std::move(columns));
}
std::unique_ptr<cudf::scalar> from_arrow(arrow::Scalar const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// Get a builder for the scalar type
auto builder = detail::make_builder(input.type);
auto status = builder->AppendScalar(input);
if (status != arrow::Status::OK()) {
if (status.IsNotImplemented()) {
// The only known failure case here is for nulls
CUDF_FAIL("Cannot create untyped null scalars or nested types with untyped null leaf nodes",
std::invalid_argument);
}
CUDF_FAIL("Arrow ArrayBuilder::AppendScalar failed");
}
auto maybe_array = builder->Finish();
if (!maybe_array.ok()) { CUDF_FAIL("Arrow ArrayBuilder::Finish failed"); }
auto array = *maybe_array;
auto field = arrow::field("", input.type);
auto table = arrow::Table::Make(arrow::schema({field}), {array});
auto cudf_table = detail::from_arrow(*table, stream, mr);
auto cv = cudf_table->view().column(0);
return get_element(cv, 0, stream);
}
} // namespace detail
std::unique_ptr<table> from_arrow(arrow::Table const& input_table,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::from_arrow(input_table, stream, mr);
}
std::unique_ptr<cudf::scalar> from_arrow(arrow::Scalar const& input,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::from_arrow(input, stream, mr);
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/interop
|
rapidsai_public_repos/cudf/cpp/src/interop/detail/arrow_allocator.cpp
|
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cudf/detail/interop.hpp>
#include <memory>
#include <sys/mman.h>
#include <unistd.h>
namespace cudf {
namespace detail {
/*
Enable Transparent Huge Pages (THP) for large (>4MB) allocations.
`buf` is returned untouched.
Enabling THP can improve performance of device-host memory transfers
significantly, see <https://github.com/rapidsai/cudf/pull/13914>.
*/
template <typename T>
T enable_hugepage(T&& buf)
{
if (buf->size() < (1u << 22u)) { // Smaller than 4 MB
return std::move(buf);
}
#ifdef MADV_HUGEPAGE
const auto pagesize = sysconf(_SC_PAGESIZE);
void* addr = const_cast<uint8_t*>(buf->data());
if (addr == nullptr) { return std::move(buf); }
auto length{static_cast<std::size_t>(buf->size())};
if (std::align(pagesize, pagesize, addr, length)) {
// Intentionally not checking for errors that may be returned by older kernel versions;
// optimistically tries enabling huge pages.
madvise(addr, length, MADV_HUGEPAGE);
}
#endif
return std::move(buf);
}
std::unique_ptr<arrow::Buffer> allocate_arrow_buffer(int64_t const size, arrow::MemoryPool* ar_mr)
{
/*
nvcc 11.0 generates Internal Compiler Error during codegen when arrow::AllocateBuffer
and `ValueOrDie` are used inside a CUDA compilation unit.
To work around this issue we compile an allocation shim in C++ and use
that from our cuda sources
*/
arrow::Result<std::unique_ptr<arrow::Buffer>> result = arrow::AllocateBuffer(size, ar_mr);
CUDF_EXPECTS(result.ok(), "Failed to allocate Arrow buffer");
return enable_hugepage(std::move(result).ValueOrDie());
}
std::shared_ptr<arrow::Buffer> allocate_arrow_bitmap(int64_t const size, arrow::MemoryPool* ar_mr)
{
/*
nvcc 11.0 generates Internal Compiler Error during codegen when arrow::AllocateBuffer
and `ValueOrDie` are used inside a CUDA compilation unit.
To work around this issue we compile an allocation shim in C++ and use
that from our cuda sources
*/
arrow::Result<std::shared_ptr<arrow::Buffer>> result = arrow::AllocateBitmap(size, ar_mr);
CUDF_EXPECTS(result.ok(), "Failed to allocate Arrow bitmap");
return enable_hugepage(std::move(result).ValueOrDie());
}
} // namespace detail
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/interop
|
rapidsai_public_repos/cudf/cpp/src/interop/detail/arrow_allocator.hpp
|
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cudf/detail/interop.hpp>
namespace cudf {
namespace detail {
// unique_ptr because that is what AllocateBuffer returns
std::unique_ptr<arrow::Buffer> allocate_arrow_buffer(int64_t const size, arrow::MemoryPool* ar_mr);
// shared_ptr because that is what AllocateBitmap returns
std::shared_ptr<arrow::Buffer> allocate_arrow_bitmap(int64_t const size, arrow::MemoryPool* ar_mr);
} // namespace detail
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src
|
rapidsai_public_repos/cudf/cpp/src/binaryop/binaryop.cpp
|
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
*
* Copyright 2018-2019 BlazingDB, Inc.
* Copyright 2018 Christian Noboa Mardini <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "compiled/binary_ops.hpp"
#include <jit_preprocessed_files/binaryop/jit/kernel.cu.jit.hpp>
#include <jit/cache.hpp>
#include <jit/parser.hpp>
#include <jit/util.hpp>
#include <cudf/binaryop.hpp>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/binaryop.hpp>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/fixed_point/fixed_point.hpp>
#include <cudf/scalar/scalar.hpp>
#include <cudf/scalar/scalar_factories.hpp>
#include <cudf/table/table_view.hpp>
#include <cudf/types.hpp>
#include <cudf/unary.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf/utilities/traits.hpp>
#include <cudf/utilities/type_dispatcher.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <string>
#include <thrust/optional.h>
namespace cudf {
namespace binops {
/**
* @brief Computes output valid mask for op between a column and a scalar
*/
std::pair<rmm::device_buffer, size_type> scalar_col_valid_mask_and(
column_view const& col,
scalar const& s,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (col.is_empty()) return std::pair(rmm::device_buffer{0, stream, mr}, 0);
if (not s.is_valid(stream)) {
return std::pair(cudf::detail::create_null_mask(col.size(), mask_state::ALL_NULL, stream, mr),
col.size());
} else if (s.is_valid(stream) and col.nullable()) {
return std::pair(cudf::detail::copy_bitmask(col, stream, mr), col.null_count());
} else {
return std::pair(rmm::device_buffer{0, stream, mr}, 0);
}
}
/**
* @brief Does the binop need to know if an operand is null/invalid to perform special
* processing?
*/
inline bool is_null_dependent(binary_operator op)
{
return op == binary_operator::NULL_EQUALS || op == binary_operator::NULL_MIN ||
op == binary_operator::NULL_MAX || op == binary_operator::NULL_LOGICAL_AND ||
op == binary_operator::NULL_LOGICAL_OR;
}
/**
* @brief Returns `true` if `binary_operator` `op` is a basic arithmetic binary operation
*/
bool is_basic_arithmetic_binop(binary_operator op)
{
return op == binary_operator::ADD or // operator +
op == binary_operator::SUB or // operator -
op == binary_operator::MUL or // operator *
op == binary_operator::DIV or // operator / using common type of lhs and rhs
op == binary_operator::NULL_MIN or // 2 null = null, 1 null = value, else min
op == binary_operator::NULL_MAX or // 2 null = null, 1 null = value, else max
op == binary_operator::MOD or // operator %
op == binary_operator::PMOD or // positive modulo operator
op == binary_operator::PYMOD; // operator % but following Python's negative sign rules
}
/**
* @brief Returns `true` if `binary_operator` `op` is a comparison binary operation
*/
bool is_comparison_binop(binary_operator op)
{
return op == binary_operator::EQUAL or // operator ==
op == binary_operator::NOT_EQUAL or // operator !=
op == binary_operator::LESS or // operator <
op == binary_operator::GREATER or // operator >
op == binary_operator::LESS_EQUAL or // operator <=
op == binary_operator::GREATER_EQUAL or // operator >=
op == binary_operator::NULL_EQUALS; // 2 null = true; 1 null = false; else ==
}
/**
* @brief Returns `true` if `binary_operator` `op` is supported by `fixed_point`
*/
bool is_supported_fixed_point_binop(binary_operator op)
{
return is_basic_arithmetic_binop(op) or is_comparison_binop(op);
}
/**
* @brief Helper predicate function that identifies if `op` requires scales to be the same
*
* @param op `binary_operator`
* @return true `op` requires scales of lhs and rhs to be the same
* @return false `op` does not require scales of lhs and rhs to be the same
*/
bool is_same_scale_necessary(binary_operator op)
{
return op != binary_operator::MUL && op != binary_operator::DIV;
}
namespace jit {
void binary_operation(mutable_column_view& out,
column_view const& lhs,
column_view const& rhs,
std::string const& ptx,
rmm::cuda_stream_view stream)
{
std::string const output_type_name = cudf::type_to_name(out.type());
std::string cuda_source =
cudf::jit::parse_single_function_ptx(ptx, "GENERIC_BINARY_OP", output_type_name);
std::string kernel_name = jitify2::reflection::Template("cudf::binops::jit::kernel_v_v")
.instantiate(output_type_name, // list of template arguments
cudf::type_to_name(lhs.type()),
cudf::type_to_name(rhs.type()),
std::string("cudf::binops::jit::UserDefinedOp"));
cudf::jit::get_program_cache(*binaryop_jit_kernel_cu_jit)
.get_kernel(kernel_name, {}, {{"binaryop/jit/operation-udf.hpp", cuda_source}}, {"-arch=sm_."})
->configure_1d_max_occupancy(0, 0, 0, stream.value())
->launch(out.size(),
cudf::jit::get_data_ptr(out),
cudf::jit::get_data_ptr(lhs),
cudf::jit::get_data_ptr(rhs));
}
} // namespace jit
// Compiled Binary operation
namespace compiled {
template <typename Lhs, typename Rhs>
void fixed_point_binary_operation_validation(binary_operator op,
Lhs lhs,
Rhs rhs,
thrust::optional<cudf::data_type> output_type = {})
{
CUDF_EXPECTS((is_fixed_point(lhs) or is_fixed_point(rhs)),
"One of the inputs must have fixed_point data_type.");
CUDF_EXPECTS(binops::is_supported_fixed_point_binop(op),
"Unsupported fixed_point binary operation");
if (output_type.has_value() and binops::is_comparison_binop(op))
CUDF_EXPECTS(output_type == cudf::data_type{type_id::BOOL8},
"Comparison operations require boolean output type.");
}
/**
* @copydoc cudf::binary_operation(column_view const&, column_view const&,
* binary_operator, data_type, rmm::mr::device_memory_resource*)
*
* @param stream CUDA stream used for device memory operations and kernel launches.
*/
template <typename LhsType, typename RhsType>
std::unique_ptr<column> binary_operation(LhsType const& lhs,
RhsType const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if constexpr (std::is_same_v<LhsType, column_view> and std::is_same_v<RhsType, column_view>)
CUDF_EXPECTS(lhs.size() == rhs.size(), "Column sizes don't match");
if (lhs.type().id() == type_id::STRING and rhs.type().id() == type_id::STRING and
output_type.id() == type_id::STRING and
(op == binary_operator::NULL_MAX or op == binary_operator::NULL_MIN))
return cudf::binops::compiled::string_null_min_max(lhs, rhs, op, output_type, stream, mr);
if (not cudf::binops::compiled::is_supported_operation(output_type, lhs.type(), rhs.type(), op))
CUDF_FAIL("Unsupported operator for these types", cudf::data_type_error);
if (cudf::is_fixed_point(lhs.type()) or cudf::is_fixed_point(rhs.type())) {
cudf::binops::compiled::fixed_point_binary_operation_validation(
op, lhs.type(), rhs.type(), output_type);
}
auto out = make_fixed_width_column_for_output(lhs, rhs, op, output_type, stream, mr);
if constexpr (std::is_same_v<LhsType, column_view>)
if (lhs.is_empty()) return out;
if constexpr (std::is_same_v<RhsType, column_view>)
if (rhs.is_empty()) return out;
auto out_view = out->mutable_view();
cudf::binops::compiled::binary_operation(out_view, lhs, rhs, op, stream);
// TODO: consider having the binary_operation count nulls instead
out->set_null_count(cudf::detail::null_count(out_view.null_mask(), 0, out->size(), stream));
return out;
}
} // namespace compiled
} // namespace binops
namespace detail {
// There are 3 overloads of each of the following functions:
// - `make_fixed_width_column_for_output`
// - `binary_operation`
// The overloads are overloaded on the first two parameters of each function:
// - scalar const& lhs, column_view const& rhs,
// - column_view const& lhs, scalar const& rhs
// - column_view const& lhs, column_view const& rhs,
/**
* @brief Helper function for making output column for binary operation
*
* @param lhs Left-hand side `scalar` used in the binary operation
* @param rhs Right-hand side `column_view` used in the binary operation
* @param op `binary_operator` to be used to combine `lhs` and `rhs`
* @param output_type `data_type` of the output column
* @param stream CUDA stream used for device memory operations
* @param mr Device memory resource to use for device memory allocation
* @return std::unique_ptr<column> Output column used for binary operation
*/
std::unique_ptr<column> make_fixed_width_column_for_output(scalar const& lhs,
column_view const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (binops::is_null_dependent(op)) {
return make_fixed_width_column(output_type, rhs.size(), mask_state::ALL_VALID, stream, mr);
} else {
auto [new_mask, new_null_count] = binops::scalar_col_valid_mask_and(rhs, lhs, stream, mr);
return make_fixed_width_column(
output_type, rhs.size(), std::move(new_mask), new_null_count, stream, mr);
}
};
/**
* @brief Helper function for making output column for binary operation
*
* @param lhs Left-hand side `column_view` used in the binary operation
* @param rhs Right-hand side `scalar` used in the binary operation
* @param op `binary_operator` to be used to combine `lhs` and `rhs`
* @param output_type `data_type` of the output column
* @param stream CUDA stream used for device memory operations
* @param mr Device memory resource to use for device memory allocation
* @return std::unique_ptr<column> Output column used for binary operation
*/
std::unique_ptr<column> make_fixed_width_column_for_output(column_view const& lhs,
scalar const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (binops::is_null_dependent(op)) {
return make_fixed_width_column(output_type, lhs.size(), mask_state::ALL_VALID, stream, mr);
} else {
auto [new_mask, new_null_count] = binops::scalar_col_valid_mask_and(lhs, rhs, stream, mr);
return make_fixed_width_column(
output_type, lhs.size(), std::move(new_mask), new_null_count, stream, mr);
}
};
/**
* @brief Helper function for making output column for binary operation
*
* @param lhs Left-hand side `column_view` used in the binary operation
* @param rhs Right-hand side `column_view` used in the binary operation
* @param op `binary_operator` to be used to combine `lhs` and `rhs`
* @param output_type `data_type` of the output column
* @param stream CUDA stream used for device memory operations
* @param mr Device memory resource to use for device memory allocation
* @return std::unique_ptr<column> Output column used for binary operation
*/
std::unique_ptr<column> make_fixed_width_column_for_output(column_view const& lhs,
column_view const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
if (binops::is_null_dependent(op)) {
return make_fixed_width_column(output_type, rhs.size(), mask_state::ALL_VALID, stream, mr);
} else {
auto [new_mask, null_count] = cudf::detail::bitmask_and(table_view({lhs, rhs}), stream, mr);
return make_fixed_width_column(
output_type, lhs.size(), std::move(new_mask), null_count, stream, mr);
}
};
std::unique_ptr<column> binary_operation(scalar const& lhs,
column_view const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return binops::compiled::binary_operation<scalar, column_view>(
lhs, rhs, op, output_type, stream, mr);
}
std::unique_ptr<column> binary_operation(column_view const& lhs,
scalar const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return binops::compiled::binary_operation<column_view, scalar>(
lhs, rhs, op, output_type, stream, mr);
}
std::unique_ptr<column> binary_operation(column_view const& lhs,
column_view const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
return binops::compiled::binary_operation<column_view, column_view>(
lhs, rhs, op, output_type, stream, mr);
}
std::unique_ptr<column> binary_operation(column_view const& lhs,
column_view const& rhs,
std::string const& ptx,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
// Check for datatype
auto is_type_supported_ptx = [](data_type type) -> bool {
return is_fixed_width(type) and not is_fixed_point(type) and
type.id() != type_id::INT8; // Numba PTX doesn't support int8
};
CUDF_EXPECTS(is_type_supported_ptx(lhs.type()), "Invalid/Unsupported lhs datatype");
CUDF_EXPECTS(is_type_supported_ptx(rhs.type()), "Invalid/Unsupported rhs datatype");
CUDF_EXPECTS(is_type_supported_ptx(output_type), "Invalid/Unsupported output datatype");
CUDF_EXPECTS((lhs.size() == rhs.size()), "Column sizes don't match");
auto [new_mask, null_count] = cudf::detail::bitmask_and(table_view({lhs, rhs}), stream, mr);
auto out =
make_fixed_width_column(output_type, lhs.size(), std::move(new_mask), null_count, stream, mr);
// Check for 0 sized data
if (lhs.is_empty() or rhs.is_empty()) return out;
auto out_view = out->mutable_view();
binops::jit::binary_operation(out_view, lhs, rhs, ptx, stream);
out->set_null_count(cudf::detail::null_count(out_view.null_mask(), 0, out->size(), stream));
return out;
}
} // namespace detail
int32_t binary_operation_fixed_point_scale(binary_operator op,
int32_t left_scale,
int32_t right_scale)
{
CUDF_EXPECTS(binops::is_supported_fixed_point_binop(op),
"Unsupported fixed_point binary operation.");
if (op == binary_operator::MUL) return left_scale + right_scale;
if (op == binary_operator::DIV) return left_scale - right_scale;
return std::min(left_scale, right_scale);
}
cudf::data_type binary_operation_fixed_point_output_type(binary_operator op,
cudf::data_type const& lhs,
cudf::data_type const& rhs)
{
cudf::binops::compiled::fixed_point_binary_operation_validation(op, lhs, rhs);
auto const scale = binary_operation_fixed_point_scale(op, lhs.scale(), rhs.scale());
return cudf::data_type{lhs.id(), scale};
}
std::unique_ptr<column> binary_operation(scalar const& lhs,
column_view const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::binary_operation(lhs, rhs, op, output_type, stream, mr);
}
std::unique_ptr<column> binary_operation(column_view const& lhs,
scalar const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::binary_operation(lhs, rhs, op, output_type, stream, mr);
}
std::unique_ptr<column> binary_operation(column_view const& lhs,
column_view const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::binary_operation(lhs, rhs, op, output_type, stream, mr);
}
std::unique_ptr<column> binary_operation(column_view const& lhs,
column_view const& rhs,
std::string const& ptx,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();
return detail::binary_operation(lhs, rhs, ptx, output_type, stream, mr);
}
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/ShiftRightUnsigned.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::ShiftRightUnsigned>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/binary_ops.hpp
|
/*
* Copyright (c) 2018-2023, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cudf/binaryop.hpp>
#include <cudf/null_mask.hpp>
#include <cudf/utilities/default_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <optional>
namespace cudf {
// Forward declarations
class column_device_view;
class mutable_column_device_view;
namespace binops {
namespace compiled {
std::unique_ptr<column> string_null_min_max(scalar const& lhs,
column_view const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);
std::unique_ptr<column> string_null_min_max(column_view const& lhs,
scalar const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);
std::unique_ptr<column> string_null_min_max(column_view const& lhs,
column_view const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);
/**
* @brief Performs a binary operation between a string scalar and a string
* column.
*
* The output contains the result of op(lhs, rhs[i]) for all 0 <= i < rhs.size()
* The scalar is the left operand and the column elements are the right operand.
* This distinction is significant in case of non-commutative binary operations
*
* Regardless of the operator, the validity of the output value is the logical
* AND of the validity of the two operands
*
* @param lhs The left operand string scalar
* @param rhs The right operand string column
* @param op The binary operator
* @param output_type The desired data type of the output column
* @param stream CUDA stream used for device memory operations and kernel launches.
* @param mr Device memory resource used to allocate the returned column's device memory
* @return std::unique_ptr<column> Output column
*/
std::unique_ptr<column> binary_operation(scalar const& lhs,
column_view const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);
/**
* @brief Performs a binary operation between a string column and a string
* scalar.
*
* The output contains the result of op(lhs[i], rhs) for all 0 <= i < lhs.size()
* The column elements are the left operand and the scalar is the right operand.
* This distinction is significant in case of non-commutative binary operations
*
* Regardless of the operator, the validity of the output value is the logical
* AND of the validity of the two operands
*
* @param lhs The left operand string column
* @param rhs The right operand string scalar
* @param op The binary operator
* @param output_type The desired data type of the output column
* @param stream CUDA stream used for device memory operations and kernel launches.
* @param mr Device memory resource used to allocate the returned column's device memory
* @return std::unique_ptr<column> Output column
*/
std::unique_ptr<column> binary_operation(column_view const& lhs,
scalar const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);
/**
* @brief Performs a binary operation between two string columns.
*
* @note The sizes of @p lhs and @p rhs should be the same
*
* The output contains the result of op(lhs[i], rhs[i]) for all 0 <= i < lhs.size()
*
* Regardless of the operator, the validity of the output value is the logical
* AND of the validity of the two operands
*
* @param lhs The left operand string column
* @param rhs The right operand string column
* @param op The binary operator enum
* @param output_type The desired data type of the output column
* @param stream CUDA stream used for device memory operations and kernel launches.
* @param mr Device memory resource used to allocate the returned column's device memory
* @return std::unique_ptr<column> Output column
*/
std::unique_ptr<column> binary_operation(column_view const& lhs,
column_view const& rhs,
binary_operator op,
data_type output_type,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr);
void binary_operation(mutable_column_view& out,
scalar const& lhs,
column_view const& rhs,
binary_operator op,
rmm::cuda_stream_view stream);
void binary_operation(mutable_column_view& out,
column_view const& lhs,
scalar const& rhs,
binary_operator op,
rmm::cuda_stream_view stream);
void binary_operation(mutable_column_view& out,
column_view const& lhs,
column_view const& rhs,
binary_operator op,
rmm::cuda_stream_view stream);
// Defined in util.cpp
/**
* @brief Get the common type among all input types.
*
* @param out type 1
* @param lhs type 2
* @param rhs type 3
* @return common type among @p out, @p lhs, @p rhs.
*/
std::optional<data_type> get_common_type(data_type out, data_type lhs, data_type rhs);
/**
* @brief Check if input binary operation is supported for the given input and output types.
*
* @param out output type of the binary operation
* @param lhs first operand type of the binary operation
* @param rhs second operand type of the binary operation
* @param op binary operator enum.
* @return true if given binary operator supports given input and output types.
*/
bool is_supported_operation(data_type out, data_type lhs, data_type rhs, binary_operator op);
// Defined in individual .cu files.
/**
* @brief Deploys single type or double type dispatcher that runs binary operation on each element
* of @p lhs and @p rhs columns.
*
* This template is instantiated for each binary operator.
*
* @tparam BinaryOperator Binary operator functor
* @param out mutable view of output column
* @param lhs view of left operand column
* @param rhs view of right operand column
* @param is_lhs_scalar true if @p lhs is a single element column representing a scalar
* @param is_rhs_scalar true if @p rhs is a single element column representing a scalar
* @param stream CUDA stream used for device memory operations
*/
template <class BinaryOperator>
void apply_binary_op(mutable_column_view& out,
column_view const& lhs,
column_view const& rhs,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view stream);
/**
* @brief Deploys single type or double type dispatcher that runs equality operation on each element
* of @p lhs and @p rhs columns.
*
* Comparison operators are EQUAL, NOT_EQUAL, NULL_EQUALS.
* @p out type is boolean.
*
* This template is instantiated for each binary operator.
*
* @param out mutable view of output column
* @param lhs view of left operand column
* @param rhs view of right operand column
* @param is_lhs_scalar true if @p lhs is a single element column representing a scalar
* @param is_rhs_scalar true if @p rhs is a single element column representing a scalar
* @param op comparison binary operator
* @param stream CUDA stream used for device memory operations
*/
void dispatch_equality_op(mutable_column_view& out,
column_view const& lhs,
column_view const& rhs,
bool is_lhs_scalar,
bool is_rhs_scalar,
binary_operator op,
rmm::cuda_stream_view stream);
} // namespace compiled
} // namespace binops
} // namespace cudf
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/LogicalOr.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::LogicalOr>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/Pow.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::Pow>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/FloorDiv.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::FloorDiv>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/NullMax.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::NullMax>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
} // namespace cudf::binops::compiled
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/GreaterEqual.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::GreaterEqual>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/NullEquals.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::NullEquals>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
} // namespace cudf::binops::compiled
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/ATan2.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::ATan2>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/BitwiseOr.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::BitwiseOr>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/LessEqual.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::LessEqual>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/Mul.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::Mul>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/Div.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::Div>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/Sub.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::Sub>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/ShiftRight.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::ShiftRight>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/Less.cu
|
/*
* Copyright (c) 2021-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::Less>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
rapidsai_public_repos/cudf/cpp/src/binaryop
|
rapidsai_public_repos/cudf/cpp/src/binaryop/compiled/IntPow.cu
|
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "binary_ops.cuh"
namespace cudf::binops::compiled {
template void apply_binary_op<ops::IntPow>(mutable_column_view&,
column_view const&,
column_view const&,
bool is_lhs_scalar,
bool is_rhs_scalar,
rmm::cuda_stream_view);
}
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.