Skip to content

Developer Reference

J. Tian edited this page Mar 21, 2022 · 1 revision

Application Compressor Component kernel with configuration kernel subroutine

High Level

Abstraction

  • Application (API)
    • involve IO, user-interacted memory operation, and communication (future)
  • Compressor (API)
    • one-time memory allocation (GPU allocation is expensive)
    • assume data on device
  • Component (API)
    • Predictor-Quantizer (Predictor as synonym)
      • Lorenzo; Spline3
    • Lossless Codec
      • Huffman, coarse-grained
    • Sparsity Codec
      • CSR format (relying on cuSPARSE methods)
      • plain gather-scatter (future)
  • kernel with configuration
    • __global__ & <<<...>>>
  • kernel subrountine
    • __device__

Compression and Decompression

We use pseudocode to describe high-level compression and decompression procedures. Particularly, the compression/decompression is expected free from memory management such as allocation and deallocation, except an exception is raised due to illegal memory access.

The major memory managements that are wrapped in allocate and destroy.

FUNC allocate(INPUT max_len, INPUT config):
    allocate(BY: max_len, FOR: predictor, FOR: spreducer, FOR: default_codec)
    allocate(BY: max_len, FOR: fallback_codec) if config.force_use_fbcodec

FUNC destroy(INPUT state):
    destroy(predictor, spreducer, default_code)
    destroy(fallback_codec) if state.fbcodec.previously_allocated
FUNC compress(REF::INPUT uncompressed, INPUT nd_len, REF::OUTPUT compressed, REF::OUTPUT compressed_len):
    errctrl_code, outlier = predictor.construct(uncompressed)

    histogram = inspect(errctrl_code)
    codec = select_encoder_and_build_codebook(histogram)

    formatted_encoded = codec.encode(errctrl_code, codebook)
    formatted_outlier = spreducer.gather(outlier) 

    compressed, compressed_len = concatenate(formatted_encoded, formatted_outlier)

FUNC decompress(INPUT header, REF::INPUT compressed, REF::OUTPUT decompressed):
    codec = select_decoder(header)
    predictor = header.predictor_in_use

    outlier = spreducer.scatter(compressed.formatted_outlier)
    errctrl_code = codec.decode(compressed.formatted)
    decompressed = predictor.reconstruct(errctrl_code, outlier)

Under the hood,

FUNC select_encoder_and_build_codebook(histogram):
    if config.use_default_codec:
        try:
            default_codec.build_codebook(histogram)
            codec = default_codec
        except Exception::UseLongerCodeword:
            allocate(max_len; fallback_codec)
            fallback_codec.build_codebook(histogram)
            codec = fallback_codec
    elif config.force_use_fallback_codec:
        fallback_codec.build_codebook(histogram)
        codec = fallback_codec
    
    return codec, codebook

FUNC select_decoder(header):
    if header.code_in_use is default_codec:
        codec = default_codec
    elif header.codec_in_use is fallback_codec:
        try:
            codec = fallback_codec
        except Exception::FallbackCodecIsNull:
            allocate(max_len; fallback_codec)
            codec = fallback_codec
Clone this wiki locally