Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote IO support queries to cudf API #16125

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions cpp/include/cudf/io/config_utils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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.
*/
#pragma once

#include <cudf/utilities/export.hpp>

namespace CUDF_EXPORT cudf {
namespace io::cufile_integration {

/**
* @brief Returns true if cuFile and its compatibility mode are enabled.
*/
bool is_always_enabled();

/**
* @brief Returns true if only direct IO through cuFile is enabled (compatibility mode is disabled).
*/
bool is_gds_enabled();

/**
* @brief Returns true if KvikIO is enabled.
*/
bool is_kvikio_enabled();

} // namespace io::cufile_integration

namespace io::nvcomp_integration {

/**
* @brief Returns true if all nvCOMP uses are enabled.
*/
bool is_all_enabled();

/**
* @brief Returns true if stable nvCOMP use is enabled.
*/
bool is_stable_enabled();

} // namespace io::nvcomp_integration
} // namespace CUDF_EXPORT cudf
106 changes: 106 additions & 0 deletions cpp/include/cudf/io/nvcomp_adapter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* 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.
*/

#pragma once

#include <cudf/utilities/export.hpp>

#include <optional>
#include <string>

namespace CUDF_EXPORT cudf {
namespace io::nvcomp {

enum class compression_type { SNAPPY, ZSTD, DEFLATE, LZ4 };

/**
* @brief Set of parameters that impact whether nvCOMP features are enabled.
*
*/
struct feature_status_parameters {
int lib_major_version; ///< major version
int lib_minor_version; ///< minor version
int lib_patch_version; ///< patch version
bool are_all_integrations_enabled; ///< all integrations
bool are_stable_integrations_enabled; ///< stable integrations
int compute_capability_major; ///< cuda compute major version

/**
* @brief Default Constructor
*/
feature_status_parameters();

/**
* @brief feature_status_parameters Constructor
*
* @param major positive integer representing major value of nvcomp
* @param minor positive integer representing minor value of nvcomp
* @param patch positive integer representing patch value of nvcomp
* @param all_enabled if all integrations are enabled
* @param stable_enabled if stable integrations are enabled
* @param cc_major CUDA compute capability
*/
feature_status_parameters(
int major, int minor, int patch, bool all_enabled, bool stable_enabled, int cc_major)
: lib_major_version{major},
lib_minor_version{minor},
lib_patch_version{patch},
are_all_integrations_enabled{all_enabled},
are_stable_integrations_enabled{stable_enabled},
compute_capability_major{cc_major}
{
}
};

/**
* @brief Equality operator overload. Required to use `feature_status_parameters` as a map key.
*/
inline bool operator==(feature_status_parameters const& lhs, feature_status_parameters const& rhs)
{
return lhs.lib_major_version == rhs.lib_major_version and
lhs.lib_minor_version == rhs.lib_minor_version and
lhs.lib_patch_version == rhs.lib_patch_version and
lhs.are_all_integrations_enabled == rhs.are_all_integrations_enabled and
lhs.are_stable_integrations_enabled == rhs.are_stable_integrations_enabled and
lhs.compute_capability_major == rhs.compute_capability_major;
}

/**
* @brief If a compression type is disabled through nvCOMP, returns the reason as a string.
*
* Result depends on nvCOMP version and environment variables.
*
* @param compression Compression type
* @param params Optional parameters to query status with different configurations
* @returns Reason for the feature disablement, `std::nullopt` if the feature is enabled
*/
[[nodiscard]] std::optional<std::string> is_compression_disabled(
compression_type compression, feature_status_parameters params = feature_status_parameters());

/**
* @brief If a decompression type is disabled through nvCOMP, returns the reason as a string.
*
* Result depends on nvCOMP version and environment variables.
*
* @param compression Compression type
* @param params Optional parameters to query status with different configurations
* @returns Reason for the feature disablement, `std::nullopt` if the feature is enabled
*/
[[nodiscard]] std::optional<std::string> is_decompression_disabled(
compression_type compression, feature_status_parameters params = feature_status_parameters());

} // namespace io::nvcomp
} // namespace CUDF_EXPORT cudf
8 changes: 5 additions & 3 deletions cpp/include/cudf/utilities/logger.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, NVIDIA CORPORATION.
* Copyright (c) 2023-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 @@ -16,9 +16,11 @@

#pragma once

#include <cudf/utilities/export.hpp>

#include <spdlog/spdlog.h>

namespace cudf {
namespace CUDF_EXPORT cudf {

/**
* @brief Returns the global logger.
Expand All @@ -43,4 +45,4 @@ namespace cudf {
*/
spdlog::logger& logger();

} // namespace cudf
} // namespace CUDF_EXPORT cudf
8 changes: 5 additions & 3 deletions cpp/src/io/comp/nvcomp_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "nvcomp_adapter.hpp"

#include "io/utilities/config_utils.hpp"
#include "nvcomp_adapter.cuh"

#include <cudf/detail/utilities/logger.hpp>
#include <cudf/io/config_utils.hpp>
#include <cudf/utilities/error.hpp>

#include <nvcomp/lz4.h>
Expand Down Expand Up @@ -472,8 +474,8 @@ feature_status_parameters::feature_status_parameters()
: lib_major_version{NVCOMP_MAJOR_VERSION},
lib_minor_version{NVCOMP_MINOR_VERSION},
lib_patch_version{NVCOMP_PATCH_VERSION},
are_all_integrations_enabled{detail::nvcomp_integration::is_all_enabled()},
are_stable_integrations_enabled{detail::nvcomp_integration::is_stable_enabled()}
are_all_integrations_enabled{nvcomp_integration::is_all_enabled()},
are_stable_integrations_enabled{nvcomp_integration::is_stable_enabled()}
{
int device;
CUDF_CUDA_TRY(cudaGetDevice(&device));
Expand Down
67 changes: 2 additions & 65 deletions cpp/src/io/comp/nvcomp_adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
#pragma once

#include "gpuinflate.hpp"
#include "io/utilities/config_utils.hpp"

#include <cudf/io/config_utils.hpp>
#include <cudf/io/nvcomp_adapter.hpp>
#include <cudf/utilities/error.hpp>
#include <cudf/utilities/span.hpp>

Expand All @@ -27,70 +28,6 @@
#include <optional>

namespace cudf::io::nvcomp {

enum class compression_type { SNAPPY, ZSTD, DEFLATE, LZ4 };

/**
* @brief Set of parameters that impact whether the use nvCOMP features is enabled.
*/
struct feature_status_parameters {
int lib_major_version;
int lib_minor_version;
int lib_patch_version;
bool are_all_integrations_enabled;
bool are_stable_integrations_enabled;
int compute_capability_major;

feature_status_parameters();
feature_status_parameters(
int major, int minor, int patch, bool all_enabled, bool stable_enabled, int cc_major)
: lib_major_version{major},
lib_minor_version{minor},
lib_patch_version{patch},
are_all_integrations_enabled{all_enabled},
are_stable_integrations_enabled{stable_enabled},
compute_capability_major{cc_major}
{
}
};

/**
* @brief Equality operator overload. Required to use `feature_status_parameters` as a map key.
*/
inline bool operator==(feature_status_parameters const& lhs, feature_status_parameters const& rhs)
{
return lhs.lib_major_version == rhs.lib_major_version and
lhs.lib_minor_version == rhs.lib_minor_version and
lhs.lib_patch_version == rhs.lib_patch_version and
lhs.are_all_integrations_enabled == rhs.are_all_integrations_enabled and
lhs.are_stable_integrations_enabled == rhs.are_stable_integrations_enabled and
lhs.compute_capability_major == rhs.compute_capability_major;
}

/**
* @brief If a compression type is disabled through nvCOMP, returns the reason as a string.
*
* Result cab depend on nvCOMP version and environment variables.
*
* @param compression Compression type
* @param params Optional parameters to query status with different configurations
* @returns Reason for the feature disablement, `std::nullopt` if the feature is enabled
*/
[[nodiscard]] std::optional<std::string> is_compression_disabled(
compression_type compression, feature_status_parameters params = feature_status_parameters());

/**
* @brief If a decompression type is disabled through nvCOMP, returns the reason as a string.
*
* Result can depend on nvCOMP version and environment variables.
*
* @param compression Compression type
* @param params Optional parameters to query status with different configurations
* @returns Reason for the feature disablement, `std::nullopt` if the feature is enabled
*/
[[nodiscard]] std::optional<std::string> is_decompression_disabled(
compression_type compression, feature_status_parameters params = feature_status_parameters());

/**
* @brief Device batch decompression of given type.
*
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/io/orc/reader_impl_decode.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
#include "io/orc/reader_impl.hpp"
#include "io/orc/reader_impl_chunking.hpp"
#include "io/orc/reader_impl_helpers.hpp"
#include "io/utilities/config_utils.hpp"
#include "io/utilities/hostdevice_span.hpp"

#include <cudf/detail/copy.hpp>
#include <cudf/detail/transform.hpp>
#include <cudf/detail/utilities/integer_utils.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/io/config_utils.hpp>
#include <cudf/table/table.hpp>
#include <cudf/utilities/error.hpp>

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/io/orc/stripe_enc.cu
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

#include "io/comp/nvcomp_adapter.hpp"
#include "io/utilities/block_utils.cuh"
#include "io/utilities/config_utils.hpp"
#include "io/utilities/time_utils.cuh"
#include "orc_gpu.hpp"

#include <cudf/column/column_device_view.cuh>
#include <cudf/detail/utilities/integer_utils.hpp>
#include <cudf/detail/utilities/logger.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/io/orc_types.hpp>
#include <cudf/lists/lists_column_view.hpp>
Expand Down
1 change: 1 addition & 0 deletions cpp/src/io/orc/writer_impl.cu
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <cudf/detail/iterator.cuh>
#include <cudf/detail/null_mask.hpp>
#include <cudf/detail/utilities/cuda.cuh>
#include <cudf/detail/utilities/logger.hpp>
#include <cudf/detail/utilities/stream_pool.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/strings/strings_column_view.hpp>
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/io/parquet/reader_impl_chunking.cu
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "compact_protocol_reader.hpp"
#include "io/comp/nvcomp_adapter.hpp"
#include "io/utilities/config_utils.hpp"
#include "io/utilities/time_utils.cuh"
#include "reader_impl.hpp"
#include "reader_impl_chunking.hpp"
Expand All @@ -25,6 +24,7 @@
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/integer_utils.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/io/config_utils.hpp>

#include <rmm/exec_policy.hpp>

Expand Down Expand Up @@ -862,7 +862,7 @@ std::vector<row_range> compute_page_splits_by_row(device_span<cumulative_page_in
gpuinflate(d_comp_in, d_comp_out, d_comp_res_view, gzip_header_included::YES, stream);
break;
case SNAPPY:
if (cudf::io::detail::nvcomp_integration::is_stable_enabled()) {
if (cudf::io::nvcomp_integration::is_stable_enabled()) {
nvcomp::batched_decompress(nvcomp::compression_type::SNAPPY,
d_comp_in,
d_comp_out,
Expand Down Expand Up @@ -1071,7 +1071,7 @@ struct get_decomp_scratch {
case BROTLI: return get_gpu_debrotli_scratch_size(di.num_pages);

case SNAPPY:
if (cudf::io::detail::nvcomp_integration::is_stable_enabled()) {
if (cudf::io::nvcomp_integration::is_stable_enabled()) {
return cudf::io::nvcomp::batched_decompress_temp_size(
cudf::io::nvcomp::compression_type::SNAPPY,
di.num_pages,
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/io/parquet/writer_impl.cu
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "io/parquet/parquet_gpu.hpp"
#include "io/statistics/column_statistics.cuh"
#include "io/utilities/column_utils.cuh"
#include "io/utilities/config_utils.hpp"
#include "parquet_common.hpp"
#include "parquet_gpu.cuh"
#include "writer_impl.hpp"
Expand All @@ -36,6 +35,7 @@
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/utilities/integer_utils.hpp>
#include <cudf/detail/utilities/linked_column.hpp>
#include <cudf/detail/utilities/logger.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/lists/detail/dremel.hpp>
#include <cudf/lists/lists_column_view.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/io/text/bgzip_data_chunk_source.cu
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

#include "io/comp/nvcomp_adapter.hpp"
#include "io/text/device_data_chunks.hpp"
#include "io/utilities/config_utils.hpp"

#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/detail/utilities/host_vector.hpp>
#include <cudf/detail/utilities/integer_utils.hpp>
#include <cudf/detail/utilities/vector_factories.hpp>
#include <cudf/io/config_utils.hpp>
#include <cudf/io/text/data_chunk_source_factories.hpp>
#include <cudf/io/text/detail/bgzip_utils.hpp>
#include <cudf/utilities/default_stream.hpp>
Expand Down
Loading
Loading