Skip to content

Commit

Permalink
Merge branch 'branch-24.02' into fea/add_ci_check_for_external_kernels
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmaynard authored Jan 19, 2024
2 parents 5af4390 + f785ed3 commit f8e401f
Show file tree
Hide file tree
Showing 171 changed files with 3,193 additions and 1,730 deletions.
6 changes: 3 additions & 3 deletions ci/build_docs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-2024, NVIDIA CORPORATION.

set -euo pipefail

Expand Down Expand Up @@ -40,8 +40,8 @@ popd

rapids-logger "Build Python docs"
pushd docs/cudf
make dirhtml
make text
make dirhtml O="-j 4"
make text O="-j 4"
mkdir -p "${RAPIDS_DOCS_DIR}/cudf/"{html,txt}
mv build/dirhtml/* "${RAPIDS_DOCS_DIR}/cudf/html"
mv build/text/* "${RAPIDS_DOCS_DIR}/cudf/txt"
Expand Down
3 changes: 2 additions & 1 deletion conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:
- benchmark==1.8.0
- boto3>=1.21.21
- botocore>=1.24.21
- breathe>=4.35.0
- c-compiler
- cachetools
- clang-tools=16.0.6
Expand Down Expand Up @@ -74,7 +75,7 @@ dependencies:
- pydata-sphinx-theme!=0.14.2
- pytest
- pytest-benchmark
- pytest-cases<3.8.2
- pytest-cases>=3.8.2
- pytest-cov
- pytest-xdist
- python-confluent-kafka>=1.9.0,<1.10.0a0
Expand Down
3 changes: 2 additions & 1 deletion conda/environments/all_cuda-120_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:
- benchmark==1.8.0
- boto3>=1.21.21
- botocore>=1.24.21
- breathe>=4.35.0
- c-compiler
- cachetools
- clang-tools=16.0.6
Expand Down Expand Up @@ -71,7 +72,7 @@ dependencies:
- pydata-sphinx-theme!=0.14.2
- pytest
- pytest-benchmark
- pytest-cases<3.8.2
- pytest-cases>=3.8.2
- pytest-cov
- pytest-xdist
- python-confluent-kafka>=1.9.0,<1.10.0a0
Expand Down
2 changes: 2 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ add_library(
src/io/orc/dict_enc.cu
src/io/orc/orc.cpp
src/io/orc/reader_impl.cu
src/io/orc/reader_impl_helpers.cpp
src/io/orc/reader_impl_preprocess.cu
src/io/orc/stats_enc.cu
src/io/orc/stripe_data.cu
src/io/orc/stripe_enc.cu
Expand Down
7 changes: 6 additions & 1 deletion cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2018-2023, NVIDIA CORPORATION.
# Copyright (c) 2018-2024, 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
Expand Down Expand Up @@ -183,6 +183,11 @@ ConfigureNVBench(
sort/sort_lists.cpp sort/sort_structs.cpp
)

# ##################################################################################################
# * structs benchmark
# --------------------------------------------------------------------------------
ConfigureNVBench(STRUCT_CREATION_NVBENCH structs/create_structs.cpp)

# ##################################################################################################
# * quantiles benchmark
# --------------------------------------------------------------------------------
Expand Down
31 changes: 31 additions & 0 deletions cpp/benchmarks/structs/create_structs.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2024, 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 <benchmarks/common/generate_nested_types.hpp>

#include <nvbench/nvbench.cuh>

void nvbench_create_structs(nvbench::state& state)
{
state.exec(nvbench::exec_tag::sync,
[&](nvbench::launch& launch) { auto const table_ptr = create_structs_data(state); });
}

NVBENCH_BENCH(nvbench_create_structs)
.set_name("create_structs")
.add_int64_power_of_two_axis("NumRows", {10, 18, 26})
.add_int64_axis("Depth", {1, 8, 16})
.add_int64_axis("Nulls", {0, 1});
6 changes: 3 additions & 3 deletions cpp/doxygen/developer_guide/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ the host (`to_host`).

### Background

libcudf employs a custom-built [preload library
docs](https://man7.org/linux/man-pages/man8/ld.so.8.html) to validate its internal stream usage (the
code may be found
libcudf employs a custom-built [preload
library](https://man7.org/linux/man-pages/man8/ld.so.8.html) to validate its internal stream usage
(the code may be found
[`here`](https://github.com/rapidsai/cudf/blob/main/cpp/tests/utilities/identify_stream_usage.cpp)).
This library wraps every asynchronous CUDA runtime API call that accepts a stream with a check to
ensure that the passed CUDA stream is a valid one, immediately throwing an exception if an invalid
Expand Down
10 changes: 8 additions & 2 deletions cpp/include/cudf/io/orc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,15 @@ class orc_reader_options_builder {
* @endcode
*
* @param options Settings for controlling reading behavior
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate device memory of the table in the returned
* table_with_metadata.
*
* @return The set of columns
*/
table_with_metadata read_orc(
orc_reader_options const& options,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::mr::device_memory_resource* mr = rmm::mr::get_current_device_resource());

/** @} */ // end of group
Expand Down Expand Up @@ -864,8 +866,10 @@ class orc_writer_options_builder {
* @endcode
*
* @param options Settings for controlling reading behavior
* @param stream CUDA stream used for device memory operations and kernel launches
*/
void write_orc(orc_writer_options const& options);
void write_orc(orc_writer_options const& options,
rmm::cuda_stream_view stream = cudf::get_default_stream());

/**
* @brief Builds settings to use for `write_orc_chunked()`.
Expand Down Expand Up @@ -1287,8 +1291,10 @@ class orc_chunked_writer {
* @brief Constructor with chunked writer options
*
* @param[in] options options used to write table
* @param[in] stream CUDA stream used for device memory operations and kernel launches
*/
orc_chunked_writer(chunked_orc_writer_options const& options);
orc_chunked_writer(chunked_orc_writer_options const& options,
rmm::cuda_stream_view stream = cudf::get_default_stream());

/**
* @brief Writes table to output.
Expand Down
14 changes: 10 additions & 4 deletions cpp/include/cudf/io/orc_metadata.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2023, NVIDIA CORPORATION.
* Copyright (c) 2019-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -63,10 +63,12 @@ struct raw_orc_statistics {
* @endcode
*
* @param src_info Dataset source
* @param stream CUDA stream used for device memory operations and kernel launches
*
* @return Column names and encoded ORC statistics
*/
raw_orc_statistics read_raw_orc_statistics(source_info const& src_info);
raw_orc_statistics read_raw_orc_statistics(
source_info const& src_info, rmm::cuda_stream_view stream = cudf::get_default_stream());

/**
* @brief Monostate type alias for the statistics variant.
Expand Down Expand Up @@ -207,10 +209,12 @@ struct parsed_orc_statistics {
* @ingroup io_readers
*
* @param src_info Dataset source
* @param stream CUDA stream used for device memory operations and kernel launches
*
* @return Column names and decoded ORC statistics
*/
parsed_orc_statistics read_parsed_orc_statistics(source_info const& src_info);
parsed_orc_statistics read_parsed_orc_statistics(
source_info const& src_info, rmm::cuda_stream_view stream = cudf::get_default_stream());

/**
* @brief Schema of an ORC column, including the nested columns.
Expand Down Expand Up @@ -368,10 +372,12 @@ class orc_metadata {
* @ingroup io_readers
*
* @param src_info Dataset source
* @param stream CUDA stream used for device memory operations and kernel launches
*
* @return orc_metadata with ORC schema, number of rows and number of stripes.
*/
orc_metadata read_orc_metadata(source_info const& src_info);
orc_metadata read_orc_metadata(source_info const& src_info,
rmm::cuda_stream_view stream = cudf::get_default_stream());

/** @} */ // end of group
} // namespace io
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/cudf/strings/strings_column_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class strings_column_view : private column_view {
/**
* @brief Returns the internal column of chars
*
* @throw cudf::logic error if this is an empty column
* @throw cudf::logic_error if this is an empty column
* @param stream CUDA stream used for device memory operations and kernel launches
* @return The chars column
*/
Expand Down
31 changes: 16 additions & 15 deletions cpp/src/io/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ void write_csv(csv_writer_options const& options,
mr);
}

raw_orc_statistics read_raw_orc_statistics(source_info const& src_info)
raw_orc_statistics read_raw_orc_statistics(source_info const& src_info,
rmm::cuda_stream_view stream)
{
auto stream = cudf::get_default_stream();
// Get source to read statistics from
std::unique_ptr<datasource> source;
if (src_info.type() == io_type::FILEPATH) {
Expand Down Expand Up @@ -342,9 +342,10 @@ column_statistics::column_statistics(orc::column_statistics&& cs)
}
}

parsed_orc_statistics read_parsed_orc_statistics(source_info const& src_info)
parsed_orc_statistics read_parsed_orc_statistics(source_info const& src_info,
rmm::cuda_stream_view stream)
{
auto const raw_stats = read_raw_orc_statistics(src_info);
auto const raw_stats = read_raw_orc_statistics(src_info, stream);

parsed_orc_statistics result;
result.column_names = raw_stats.column_names;
Expand Down Expand Up @@ -395,12 +396,12 @@ orc_column_schema make_orc_column_schema(host_span<orc::SchemaType const> orc_sc
}
}; // namespace

orc_metadata read_orc_metadata(source_info const& src_info)
orc_metadata read_orc_metadata(source_info const& src_info, rmm::cuda_stream_view stream)
{
auto sources = make_datasources(src_info);

CUDF_EXPECTS(sources.size() == 1, "Only a single source is currently supported.");
auto const footer = orc::metadata(sources.front().get(), cudf::detail::default_stream_value).ff;
auto const footer = orc::metadata(sources.front().get(), stream).ff;

return {{make_orc_column_schema(footer.types, 0, "")},
static_cast<size_type>(footer.numberOfRows),
Expand All @@ -410,21 +411,21 @@ orc_metadata read_orc_metadata(source_info const& src_info)
/**
* @copydoc cudf::io::read_orc
*/
table_with_metadata read_orc(orc_reader_options const& options, rmm::mr::device_memory_resource* mr)
table_with_metadata read_orc(orc_reader_options const& options,
rmm::cuda_stream_view stream,
rmm::mr::device_memory_resource* mr)
{
CUDF_FUNC_RANGE();

auto datasources = make_datasources(options.get_source());
auto reader = std::make_unique<orc::detail::reader>(
std::move(datasources), options, cudf::get_default_stream(), mr);

auto reader = std::make_unique<orc::detail::reader>(std::move(datasources), options, stream, mr);
return reader->read(options);
}

/**
* @copydoc cudf::io::write_orc
*/
void write_orc(orc_writer_options const& options)
void write_orc(orc_writer_options const& options, rmm::cuda_stream_view stream)
{
namespace io_detail = cudf::io::detail;

Expand All @@ -434,8 +435,7 @@ void write_orc(orc_writer_options const& options)
CUDF_EXPECTS(sinks.size() == 1, "Multiple sinks not supported for ORC writing");

auto writer = std::make_unique<orc::detail::writer>(
std::move(sinks[0]), options, io_detail::single_write_mode::YES, cudf::get_default_stream());

std::move(sinks[0]), options, io_detail::single_write_mode::YES, stream);
try {
writer->write(options.get_table());
} catch (...) {
Expand All @@ -451,15 +451,16 @@ void write_orc(orc_writer_options const& options)
/**
* @copydoc cudf::io::orc_chunked_writer::orc_chunked_writer
*/
orc_chunked_writer::orc_chunked_writer(chunked_orc_writer_options const& options)
orc_chunked_writer::orc_chunked_writer(chunked_orc_writer_options const& options,
rmm::cuda_stream_view stream)
{
namespace io_detail = cudf::io::detail;

auto sinks = make_datasinks(options.get_sink());
CUDF_EXPECTS(sinks.size() == 1, "Multiple sinks not supported for ORC writing");

writer = std::make_unique<orc::detail::writer>(
std::move(sinks[0]), options, io_detail::single_write_mode::NO, cudf::get_default_stream());
std::move(sinks[0]), options, io_detail::single_write_mode::NO, stream);
}

/**
Expand Down
45 changes: 21 additions & 24 deletions cpp/src/io/orc/aggregate_orc_metadata.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023, NVIDIA CORPORATION.
* Copyright (c) 2021-2024, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,6 @@

#include <algorithm>
#include <numeric>
#include <optional>

namespace cudf::io::orc::detail {

Expand Down Expand Up @@ -220,27 +219,25 @@ aggregate_orc_metadata::select_stripes(
}

// Read each stripe's stripefooter metadata
if (not selected_stripes_mapping.empty()) {
for (auto& mapping : selected_stripes_mapping) {
// Resize to all stripe_info for the source level
per_file_metadata[mapping.source_idx].stripefooters.resize(mapping.stripe_info.size());

for (size_t i = 0; i < mapping.stripe_info.size(); i++) {
auto const stripe = mapping.stripe_info[i].first;
auto const sf_comp_offset = stripe->offset + stripe->indexLength + stripe->dataLength;
auto const sf_comp_length = stripe->footerLength;
CUDF_EXPECTS(
sf_comp_offset + sf_comp_length < per_file_metadata[mapping.source_idx].source->size(),
"Invalid stripe information");
auto const buffer =
per_file_metadata[mapping.source_idx].source->host_read(sf_comp_offset, sf_comp_length);
auto sf_data = per_file_metadata[mapping.source_idx].decompressor->decompress_blocks(
{buffer->data(), buffer->size()}, stream);
ProtobufReader(sf_data.data(), sf_data.size())
.read(per_file_metadata[mapping.source_idx].stripefooters[i]);
mapping.stripe_info[i].second = &per_file_metadata[mapping.source_idx].stripefooters[i];
if (stripe->indexLength == 0) { row_grp_idx_present = false; }
}
for (auto& mapping : selected_stripes_mapping) {
// Resize to all stripe_info for the source level
per_file_metadata[mapping.source_idx].stripefooters.resize(mapping.stripe_info.size());

for (size_t i = 0; i < mapping.stripe_info.size(); i++) {
auto const stripe = mapping.stripe_info[i].first;
auto const sf_comp_offset = stripe->offset + stripe->indexLength + stripe->dataLength;
auto const sf_comp_length = stripe->footerLength;
CUDF_EXPECTS(
sf_comp_offset + sf_comp_length < per_file_metadata[mapping.source_idx].source->size(),
"Invalid stripe information");
auto const buffer =
per_file_metadata[mapping.source_idx].source->host_read(sf_comp_offset, sf_comp_length);
auto sf_data = per_file_metadata[mapping.source_idx].decompressor->decompress_blocks(
{buffer->data(), buffer->size()}, stream);
ProtobufReader(sf_data.data(), sf_data.size())
.read(per_file_metadata[mapping.source_idx].stripefooters[i]);
mapping.stripe_info[i].second = &per_file_metadata[mapping.source_idx].stripefooters[i];
if (stripe->indexLength == 0) { row_grp_idx_present = false; }
}
}

Expand Down Expand Up @@ -270,7 +267,7 @@ column_hierarchy aggregate_orc_metadata::select_columns(
CUDF_EXPECTS(name_found, "Unknown column name: " + std::string(path));
}
}
return {std::move(selected_columns)};
return column_hierarchy{std::move(selected_columns)};
}

} // namespace cudf::io::orc::detail
Loading

0 comments on commit f8e401f

Please sign in to comment.