2. AOCL-Compression
2.1. Introduction
AOCL-Compression is a software framework of various lossless compression and decompression methods tuned and optimized for AMD Zen™ based CPUs. This framework offers a single set of unified APIs for all the supported compression and decompression methods which facilitate the applications to easily integrate and use them. For AOCL-Compression framework APIs, refer to Unified API.
2.1.1. Methods Supported
AOCL-Compression supports compression and decompression methods of the following libraries.
It supports the dynamic dispatcher feature that executes the most optimal function variant implemented using Function Multi-versioning thereby offering a single optimized library portable across different x86 CPU architectures. AOCL-Compression framework is developed in C for UNIX® and Windows® based systems. A test suite is provided for the validation and performance benchmarking of the supported compression and decompression methods. This suite also supports the benchmarking of IPP compression methods, such as, lz4, lz4hc, zlib and bzip2. The library build framework offers CTest-based testing of the test cases implemented using GTest and the library test suite. Starting from AOCL-Compression 4.2, the library offers openMP based multi-threaded compression for all the methods (for LZMA, only multi-threaded compression is supported).
2.2. Unified APIs
Unified API abstracts individual compression and decompression routines into a single, standardized interface that uses a common handle and shared data structures, simplifying integration and maintenance compared to managing separate APIs for each method.
2.3. Native APIs
In-depth overview of native APIs provided by compression methods included in AOCL-Compression are described here.
2.4. Multi-threaded APIs
These APIs are designed to take advantage of multi-core CPUs to improve the performance of compression and decompression. The library needs to be built with AOCL_ENABLE_THREADS=ON for multi-core processing to be enabled.
2.4.1. LZ4
int LZ4_compress_fast(const char *src, char *dst, int srcSize, int dstCapacity, int acceleration)
int LZ4_compress_default(const char *src, char *dst, int srcSize, int dstCapacity)
int LZ4_decompress_safe(const char *src, char *dst, int compressedSize, int dstCapacity)
2.4.2. ZLIB
int compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
int compress2(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)
int compress2_raw(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)
int compress2_gzip(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)
int uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
int uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, uLong *sourceLen)
int uncompress2_raw(Bytef *dest, uLongf *destLen, const Bytef *source, uLong *sourceLen)
int uncompress2_gzip(Bytef *dest, uLongf *destLen, const Bytef *source, uLong *sourceLen)
2.4.3. ZSTD
AOCL Optimized multi-threaded APIs
Native multi-threaded APIs
The library needs to be built with NATIVE_ENABLE_THREADS=ON & AOCL_ENABLE_THREADS=OFF for multi-core processing to be enabled for these APIs.
size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input)
size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output)
size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output)
2.4.4. SNAPPY
2.4.5. LZ4HC
2.4.6. BZIP2
2.4.7. LZMA
2.5. Examples
Example programs illustrating how to use AOCL-Compression APIs are presented here.
Contacts
AOCL-Compression is developed and maintained by AMD. For support, send an email to toolchainsupport@amd.com.