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

Use nvCOMP for ZLIB decompression in ORC reader #11024

Merged
merged 1 commit into from
Jun 2, 2022
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
16 changes: 16 additions & 0 deletions cpp/src/io/comp/nvcomp_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
#define NVCOMP_HAS_ZSTD 0
#endif

#define NVCOMP_DEFLATE_HEADER <nvcomp/deflate.h>
#if __has_include(NVCOMP_DEFLATE_HEADER)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. This is the first time I've seen __has_include. It's a standardized feature since C++17.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, when I was adding ZSTD support, I searched libcudf for existing uses and found none :D
I'm not sure if we covered it in the C++17 talks we did a while ago.

#include NVCOMP_DEFLATE_HEADER
#define NVCOMP_HAS_DEFLATE 1
#else
#define NVCOMP_HAS_DEFLATE 0
#endif

namespace cudf::io::nvcomp {

template <typename... Args>
Expand All @@ -40,6 +48,10 @@ auto batched_decompress_get_temp_size(compression_type compression, Args&&... ar
#if NVCOMP_HAS_ZSTD
case compression_type::ZSTD:
return nvcompBatchedZstdDecompressGetTempSize(std::forward<Args>(args)...);
#endif
#if NVCOMP_HAS_DEFLATE
case compression_type::DEFLATE:
return nvcompBatchedDeflateDecompressGetTempSize(std::forward<Args>(args)...);
#endif
default: CUDF_FAIL("Unsupported compression type");
}
Expand All @@ -54,6 +66,10 @@ auto batched_decompress_async(compression_type compression, Args&&... args)
#if NVCOMP_HAS_ZSTD
case compression_type::ZSTD:
return nvcompBatchedZstdDecompressAsync(std::forward<Args>(args)...);
#endif
#if NVCOMP_HAS_DEFLATE
case compression_type::DEFLATE:
return nvcompBatchedDeflateDecompressAsync(std::forward<Args>(args)...);
#endif
default: CUDF_FAIL("Unsupported compression type");
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/io/comp/nvcomp_adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace cudf::io::nvcomp {

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

/**
* @brief Device batch decompression of given type.
Expand Down
13 changes: 11 additions & 2 deletions cpp/src/io/orc/reader_impl.cu
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,17 @@ rmm::device_buffer reader::impl::decompress_stripe_data(
device_span<device_span<uint8_t>> inflate_out_view{inflate_out.data(), num_compressed_blocks};
switch (decompressor.compression()) {
case compression_type::ZLIB:
gpuinflate(
inflate_in_view, inflate_out_view, inflate_stats, gzip_header_included::NO, stream);
if (nvcomp_integration::is_all_enabled()) {
nvcomp::batched_decompress(nvcomp::compression_type::DEFLATE,
inflate_in_view,
inflate_out_view,
inflate_stats,
max_uncomp_block_size,
stream);
} else {
gpuinflate(
inflate_in_view, inflate_out_view, inflate_stats, gzip_header_included::NO, stream);
}
break;
case compression_type::SNAPPY:
if (nvcomp_integration::is_stable_enabled()) {
Expand Down