* In this example, we: * 1) construct an nvcompManager * 2) compress the input data * 3) decompress the input data */
| 108 | * 3) decompress the input data |
| 109 | */ |
| 110 | void comp_decomp_with_single_manager(uint8_t* device_input_ptrs, const size_t input_buffer_len) |
| 111 | { |
| 112 | cudaStream_t stream; |
| 113 | CUDA_CHECK(cudaStreamCreate(&stream)); |
| 114 | |
| 115 | const int chunk_size = 1 << 16; |
| 116 | nvcompType_t data_type = NVCOMP_TYPE_CHAR; |
| 117 | |
| 118 | nvcompBatchedLZ4Opts_t format_opts{data_type}; |
| 119 | LZ4Manager nvcomp_manager{chunk_size, format_opts, stream}; |
| 120 | CompressionConfig comp_config = nvcomp_manager.configure_compression(input_buffer_len); |
| 121 | |
| 122 | uint8_t* comp_buffer; |
| 123 | CUDA_CHECK(cudaMalloc(&comp_buffer, comp_config.max_compressed_buffer_size)); |
| 124 | |
| 125 | nvcomp_manager.compress(device_input_ptrs, comp_buffer, comp_config); |
| 126 | |
| 127 | DecompressionConfig decomp_config = nvcomp_manager.configure_decompression(comp_buffer); |
| 128 | uint8_t* res_decomp_buffer; |
| 129 | CUDA_CHECK(cudaMalloc(&res_decomp_buffer, decomp_config.decomp_data_size)); |
| 130 | |
| 131 | nvcomp_manager.decompress(res_decomp_buffer, comp_buffer, decomp_config); |
| 132 | |
| 133 | CUDA_CHECK(cudaStreamSynchronize(stream)); |
| 134 | |
| 135 | CUDA_CHECK(cudaFree(comp_buffer)); |
| 136 | CUDA_CHECK(cudaFree(res_decomp_buffer)); |
| 137 | |
| 138 | CUDA_CHECK(cudaStreamDestroy(stream)); |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Additionally, we can use the same manager to execute multiple streamed compressions / decompressions |