Method and apparatus for high speed lossless compression - Patents.com
The method addresses the inefficiencies in existing lossless compression algorithms by using non-uniform bit lengths and morphological wavelet transforms to optimize compression speed and ratio, enhancing data processing efficiency for large data sets.
Patent Information
- Application Number
- JP2022562540
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2020-04-14
- Publication Date
- 2024-09-12
- Estimated Expiration
- 2040-04-14
AI Technical Summary
Existing lossless compression algorithms for large data sets, such as those generated by astroparticle physics experiments, are insufficient in terms of speed and efficiency, leading to bottlenecks in data processing and storage, particularly when dealing with high data rates and the need to retain data for recalibration.
A method and system for compressing digital data by mapping sequences of digital values into codewords with non-uniform bit lengths, using morphological wavelet transforms and bitmasks to optimize compression speed and ratio, while ensuring alignment with memory word boundaries, and employing parallel processing with AVX2 instructions.
The method achieves high compression ratios and fast compression speeds, significantly improving input/output speeds and enabling efficient data processing, even in parallel environments, while maintaining lossless data integrity.
Smart Images

Figure 0007550236000019 
Figure 0007550236000020 
Figure 0007550236000014
Abstract
Description
[Technical field]
[0001] The present invention relates to a method and apparatus for fast lossless compression of data, in particular, to fast lossless compression of 16-bit integers. [Background technology]
[0002] Many scientific experiments measure data and convert analog signals to 12-bit digital data (numbers between 0 and 4095), which are then stored as 16-bit unsigned integers. This is because the smallest data type supported by most computers is 12 bits or more. Usually, the measured data is noisy only due to occasional signals, and samples are highly correlated, so the difference between samples is small.
[0003] For example, FlashCam is a digital high-performance camera for ground-based imaging atmospheric Cherenkov telescopes. Arrays of telescopes, such as the Hess Gamma Ray Telescope (HESS) experiment or the future Cherenkov telescope array (CTA), are used to search for astrophysical sources of very high energy gamma rays.
[0004] The main functional component of the FlashCam design is a photodetector surface with an area of almost 4 square meters and a high-performance, fully digital trigger and readout system. The photodetector surface consists of 147 modules, each containing 12 photomultiplier tubes (PMTs) with a peak quantum efficiency of more than 40 percent. The analog signals of the photomultiplier tubes are continuously digitized at a sampling rate of 250 million samples per second at 12-bit resolution. The data stream of the digitized signals is processed in real time by 96 field-programmable gate array (FPGA)-based processors working in parallel. Using digital filter techniques implemented on the FPGA, it is possible to identify the coincidence of weak, nanosecond-long flashes of light caused by air showers and to record the corresponding sequence of images with a repetition time of 4 nanoseconds. Depending on the configuration, such "nanomovies" can be recorded with a duration of up to about 16 microseconds. The image data is then transferred to a high-performance server via an Ethernet-based front-end readout. Using the optimized scheme, more than 3 gigabytes per second can be transferred without packet loss, so that more than 30,000 image sequences can be acquired per second with a duration of about 100 nanoseconds and no dead time.
[0005] The huge data rates of such experiments require compression, not only to conserve disk space, but also to increase input / output (I / O) speed. In many cases, signal extraction and noise reduction cannot be performed immediately, since the complete data set is needed for subsequent calibration. Even after calibration, there is often a desire to retain as much data as possible in order to recalibrate and reanalyze the data when errors are found in the original algorithms.
[0006] Disk space has become cheap, but the time it takes to read and write data (I / O) is often the bottleneck.
[0007] Hard disk drives (HDDs) offer input / output (I / O) speeds of ≈0.1 gigabytes per second, and solid-state drives (SSDs) offer speeds of ≈1 gigabyte per second. This is simply not enough to handle the data streams of large experiments. The solution is to implement disk arrays, which can achieve total speeds of the order of gigabytes per second. However, the larger these arrays are, the more expensive they are, not to mention the network interfaces. Furthermore, experiments, especially in astrophysics, need to be far from cities and therefore far from power plants, computing centers and high-speed communication lines, making the problem of efficient data processing even more important.
[0008] Compressing data can help improve input / output (I / O) speed because the amount of data to be read from or written to disk is reduced by a factor r, where r is the compression ratio. However, the compression speed vc and decompression speed vd should not be neglected when optimizing a compression algorithm for low r. If r x v does not significantly exceed the disk I / O speed, there may be no benefit to compressing.
[0009] It is important that the compression algorithm is lossless, since during data acquisition it is not always possible to distinguish between signal and noise, so using lossy compression algorithms is risky as it can result in losing important parts of the data.
[0010] Most general-purpose lossless compression algorithms, such as gzip, achieve good compression ratios and decompression speeds, but the compression speed is not sufficient. However, there may be time constraints during data acquisition due to high data rates, so a fast compression speed would be very useful.
[0011] For example, if the data rate of the input stream is 2 gigabytes per second, the compression ratio is r=0.3, the compression speed is 1 gigabyte per second, and the disk write speed is 1 gigabyte per second. If the compression speed is fast enough, the input stream can be compressed to 0.6 gigabytes per second, and the disk could easily store it. However, since the compression speed is only 1 gigabyte per second, this is not possible. In addition, when the input stream and the disk are the same, but a different compression algorithm is used, which compresses worse (r=0.4), but faster (3 gigabytes per second), the input stream is compressed to 0.8 gigabytes per second, and since the compression speed exceeds the input data rate, it is possible to store it on the disk. Furthermore, if the (de)compression is done quickly, there is more time for data analysis. Summary of the Invention
[0012] SUMMARY OF THE PRESENT EMBODIMENT It is therefore an object of the present invention to provide a more efficient method and system for compressing digital data.
[0013] This object is achieved by a method and an arrangement according to the independent claims. Advantageous embodiments are defined in the dependent claims.
[0014] According to a first aspect, the invention comprises a computer implemented method of compressing digital data comprising obtaining a sequence of digital data values, mapping the sequence of digital data values to a sequence of code words, packing the sequence of code words into a sequence of memory words having uniform bit lengths, and outputting the sequence of memory words, according to the invention further comprising outputting information indicative of the bit length of each of the code words.
[0015] A memory word may correspond to a fixed size of data that is treated as a unit by the instruction set or processor hardware. The number of bits per word (bit length, word size, word width, or word length) is reflected in many aspects of the structure and operation of a computer. Most of the registers in a processor are usually word sized.
[0016] In many architectures, the maximum amount of data that can be transferred to and from working memory in a single operation is one word. Most advantageously, the bit length of the codewords is therefore required such that the (end of) the packed sequence of codewords is aligned to a word boundary of the memory word, i.e., the packed sequence completely occupies a given storage area.
[0017] In order to provide very compact information, the information indicative of the bit length of each codeword may be a first bit mask, which may comprise, for each codeword, one or more bits indicative of the bit length of the codeword.
[0018] To make compression data-adaptive, but at the expense of minimal compression speed, the method may further include selecting one or more bit lengths of codewords based on the sequence of digital data values, the sequence of digital data values being mapped to a sequence of codewords, each of the codewords having one of the selected bit lengths. The selection may be made by comparing storage space requirements resulting from different codeword bit lengths or combinations of codeword bit lengths. In particular, the selection based on storage space requirements may be made using a binary search procedure, thereby eliminating one or more redundant explicit comparisons. Most particularly, the one or more bit lengths may be selected from 0 bits, 1 bit, 2 bits, 3 bits, 4 bits, 2 or 5 bits, 5 bits, 3 or 6 bits, 6 bits, 4 or 8 bits, 8 bits, 6 or 12 bits, 12 bits, 6 or 16 bits, 8 or 16 bits, 16 bits or any subset thereof, or a combination of bit lengths, which have been shown by experiments by the inventors to simultaneously provide a high compression ratio and a fast compression speed.
[0019] The codewords may be restricted to have unequal bit lengths, meaning that for a given block of digital data values, some but not all codewords have the same bit length. The unequal bit lengths of the codewords may be at least two of 4, 6, 8 and 16 bits. Alternatively, the codewords may have only two different bit lengths. In particular, the two different bit lengths of the codewords may be one of the following combinations: 2 / 5 bits, 3 / 6 bits, 4 / 8 bits, 6 / 12 bits, 6 / 16 bits, or 8 / 16 bits.
[0020] To further reduce the storage area required when using combinations of bit lengths, packing the sequence of codewords may include first packing a sequence of l1 bits of each codeword into the memory word, where l1 corresponds to a minimum bit length of the codeword, and then packing the remaining bits of the codewords having a bit length greater than l1 into the remaining memory word. Packing the remaining bits of the codewords having a bit length greater than l1 may include first packing a sequence of l2-l1 bits of each remaining codeword into the remaining memory word, where l2 corresponds to a second smallest bit length of the codeword, and then subsequently packing the remaining bits of the codewords having a bit length greater than l2 into the remaining memory word.
[0021] Only the absolute values of the digital data values may be mapped to code words and the signs are coded separately. In particular, the method may further comprise outputting, for each digital data value, information indicative of its sign, preferably in the form of a second bit mask.
[0022] Most advantageously, the invention may be applied in the context of a so-called residual transformation, which reduces an initial block of data based on a selected data model. Here, obtaining the digital data values may comprise receiving a block of original digital data and transforming the block of original digital data to obtain the digital data values as a residual. Advantageously, the transformation approximates the original data according to a selected model, resulting in a so-called residual, which may be understood as the difference between the original data and the approximation. For example, the transformation may comprise subtracting from the original data the minimum value of the original data block (to be coded separately) in order to reduce the residual. Other types of residuals may be obtained by methods known in the field of predictive coding, in particular audio and image coding, where signal components are predicted according to an image or audio model. Most especially, the block of original digital data may be transformed using a wavelet transform. The wavelet transform may be a morphological wavelet transform or an iterated wavelet transform. The wavelet transform may be iterated four times.
[0023] According to a second aspect, the invention also provides a method for decoding data encoded according to the previous method based on the bit length indicator(s) and the encoded data.
[0024] Most advantageously, due to the relative simplicity of the methods of the present invention, they are implemented with significant parallelism and / or using AVX2 or similar specialized processor instructions.
[0025] The various embodiments of the invention described herein offer a trade-off between speed and compression ratio. They do not provide the greatest possible compression, but are very fast, thus greatly improving I / O speed. They are based on the assumption that the input data consists of consecutive unsigned 16-bit integers, with small integer differences. Furthermore, even if some of the input values are not bound by this constraint, effective compression is still possible. [Brief description of the drawings]
[0026] [Figure 1] FIG. 1 shows a flow diagram of a method for compressing digital data according to an embodiment of the present invention. [Diagram 2] FIG. 2 shows a more detailed flow diagram of step 120 of the iterated morphological wavelet transform in FIG. [Diagram 3] FIG. 3 shows a possible implementation of the method shown in FIG. [Figure 4] FIG. 4 shows a method for determining the bit range (combination). [Diagram 5] FIG. 5 shows an alternative method for determining the bit ranges (combinations). [Figure 6] FIG. 6 illustrates the layout of a block of digital data compressed according to an embodiment of the present invention. [Figure 7] Figure 7 shows an example of 2 / 5 bit encoding of 16 values: in the encoded stream, the bitmask is sent first (2 bytes), followed by 10 2-bit values (20 bits -> 3 bytes), then 6 5-bit values (30 bits -> 4 bytes). [Figure 8] FIG. 8 shows the results of a comparison of the method of the present invention with known compression methods. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0027] FIG. 1 shows a flow diagram of a method 100 for compressing digital data according to a further embodiment of the present invention.
[0028] A block 111 of unsigned 16-bit integers is read in step 110. In step 120, one or more so-called morphological wavelet transforms, which will be explained in more detail in connection with FIG. 2, are applied to the block 111 in order to obtain one or more minimum values 121 and one or more residuals 122. Based on the residuals 122, one or more bit ranges to be used for coding the residuals are selected in step 130. An indicator, for example a bit mask 131, is output, which indicates the bit range(s) that have been selected. In step 140, the residuals are then coded based on the one or more selected bit range(s) to obtain coded residuals 141. In step 150, the minimum values 121 (not shown), the coded residuals 141 and the bit mask(s) 131, which may also have been coded, are then combined and output in step 106.
[0029] Thereafter, if there are more than 256 values remaining to compress, the method returns to the beginning at step 110 (not shown), otherwise the remaining values are copied to the output and the method returns to step 110.
[0030] Parallelization of this algorithm is possible since larger blocks can be processed independently.
[0031] FIG. 2 shows a more detailed flow diagram of the iterative morphological wavelet transform step 120 in FIG.
[0032] Mathematical morphology is the theory for the analysis of geometric structures. The basic concept is to traverse a structure X by a structuring element B and modify each of its points according to a desired operation.
[0033]
number
[0034] This concept can be extended from bit masks to grayscale images and other signals. Let f be the input signal and b be a structure function with support B. Then dilation and erosion are defined as follows:
[0035]
number
[0036] For a one-dimensional, 16-bit unsigned integer input stream to be compressed, the structuring element is chosen to be only two pixels wide. If the erosion is then used as a low-pass filter, and the difference between the eroded and original signal is used as a high-pass filter, the morphological wavelet transform can be defined as follows:
number
[0037] The inverse transformation is as follows:
number
[0038] The minimum values are guaranteed to stay in the range of unsigned short integers (0, . . . , 65535), but the differences may exceed that range; they are in the interval [-65535, . . . , 65535]. Extracting and storing the sign of the difference prevents such overflows. In addition, because the input data is noisy, the sign of the difference is mostly random and therefore has no adverse effect on the compression ratio.
[0039] In contrast to other wavelets, which usually use the mean as a low-pass filter, morphological wavelets do not merge spikes into the subsampled signal, which results in smaller differences at the next decomposition level and therefore improves the compression ratio.
[0040] For example, suppose an input signal v has occasional spikes in addition to a noisy baseline. Let M(v) be the pairwise mean of v, m(v) be the pairwise minimum of v, and d(v) be the pairwise absolute difference of v.
number
[0041] When using the average, the residuals we encode are 1,2,96,3,2,50,26,14, but when using the minimum, the residuals we encode are 1,2,96,3,1,3,0,1. In this example, we can see that the average propagates the spikes to lower wavelet levels, resulting in a larger overall residual, whereas the minimum removes the spikes themselves faster, resulting in a smaller residual. The worst case for this wavelet transform is when there is a high baseline with occasional descending spikes, in which case the maximum of the pairwise samples is a better low-pass filter in the wavelet decomposition. However, in most data sets, the baseline is below the signal, and recording whether the maximum or minimum was used would consume extra header space.
[0042] These calculations can be efficiently performed with AVX2 instructions, using only one cycle per difference of 16 or minimum of 16 calculation, but much more time is spent rearranging and preparing the data inside the registers.
[0043] FIG. 3 shows an example implementation in which 32 unsigned short integers are read from memory and transformed using the morphological wavelets discussed above.
[0044] In the compression algorithm, a block of 256 values is transformed into 128 minimum values and 128 differences. Although the differences are usually small, the minimum values need to be transformed again to obtain 64 minimum values and 64 differences. This recursive process continues until only one minimum value and 255 differences remain, at which point it stops at the fourth level, resulting in 240 differences and 16 minimum values. Further decomposition would not fully exploit the parallelism offered by AVX2, since the last 16 minimum values at the fourth level would have to be split into two half-filled AVX2 registers.
[0045] FIG. 4 shows a flow diagram of a method for selection of a bitmask, which may be used in step 130 of FIG.
[0046] The residuals generated by the wavelet transform are all in the interval [0, . . . , 65535] because the codes are stored separately. Usually they are very small, so they can be stored using many fewer bits than the 16 used for the original numbers. However, if we only use range coding on a block of 16 residuals (as in the first embodiment), even a single large input value would force the other 15 values in the block to be coded with many more bits.
[0047] To handle such outliers, it is proposed to use a bitmask to identify the different ranges, and then store the values with the required number of bits. For example, if the two ranges are 4 bits and 16 bits, and 11 numbers are 4 bits and 5 numbers are 16 bits, then there is an overhead of 11*4 bits + 5*16 bits for the values, in addition to the 16 bits for the mask. An additional 4 bits are lost because 44 bits of the 4-bit value are not byte-aligned. This makes it 16+44+80+4=144 bits in total, compared to the original 256 bits. If there are 11*4 bits and 5*12 bits to store, 2*4 bits are lost due to byte alignment. It is possible to concatenate the two bitstreams before storing them in memory, but such bit processing is expensive and complex in AVX2.
[0048] The problem with a single bit mask is that it only provides for two ranges, and it is not clear which range to choose. 4 bits and 16 bits may be accurate values for some data, while for other data, 2 bits and 8 bits may be more accurate. The 4, 6, 8 and 16 bit ranges are chosen to be flexible for different noise levels and outliers. Marking the required range requires 2 bits of overhead per number for the four possibilities of 4, 6, 8 and 16 bits.
[0049] The lowest 4 bits (bits 0-3) of all 16 numbers are always stored. Then the next 2 bits (bits 4 and 5) are stored for all numbers that do not fit in the 4-bit range. Then the next 2 bits (bits 6 and 7) are stored for all numbers that do not fit in the 6-bit range. Finally, the last 8 bits (bits 8-15) are stored for all numbers that do not fit in the 8-bit range.
[0050] Thus, for a block v of 16 unsigned short integers, three bitmasks are generated as follows:
number
[0051] A small improvement in the compression ratio can be achieved by exploiting the fact that the bitmask already excludes some ranges. For example, if the bitmask indicates that a number requires 6 bits to be stored, then it cannot be a number 0,...,15. So the range for 6-bit numbers can be shifted from 0,...,15 to 0,...,79. The same applies to the 8-bit range, which can be shifted from 0,...,255 to 80,...,335. These optimizations are made in the algorithm, but are not done here for clarity of the following example.
[0052] Although having these three masks is convenient for the algorithm, it would not be appropriate to store them as they are, as they would be redundant. This is easily understood because two bits are sufficient to store a number, since each number exists in only one of four ranges. The following transformation combines the three masks into two masks:
number
[0053] The inverse transformation is as follows:
number
[0054] For the following example of a block v of 16 unsigned short integers, Bi is the number of bits required to store Vi, b4, b6 and b8 are bitmasks that define which of the range (4,6,8,16) needs to be used to store the number, and x and y are the transformed bitmasks. v=(0,20,2,1,19023,550,128,127,255,256,60,70,14,102,22,62) B=(0,5,2,1,15,10,8,7,8,9,6,7,4,7,5,6) b4=(0,1,0,0,1,1,1,1,1,1,1,1,0,1,1,1) b6=(0,0,0,0,1,1,1,1,1,1,0,1,0,1,0,0) b8=(0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0) x=(0,1,0,0,1,1,0,0,0,1,1,0,0,0,1,1) y=(0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0) The output of this bitmask encoding is:
[0055] Bit masks x and y bits 0-3 of all values in v bits 4-5 of all vi where b4i=1 All bits 6-7 of vi with b6i=1 All vi bits 8-15 with b8i=1 The algorithm is robust to outliers and noisy data, and achieves good compression ratios and speeds of 1.8GB / s per core for typical data. However, after several tests on different datasets, it turns out that the compression ratios are not always as expected.
[0056] To further improve the compression ratio, a further embodiment of the invention proposes not to hard-code the ranges (4, 6, 8 and 16 bits) but to use the dynamic range instead.
[0057] FIG. 5 shows a flow diagram of an alternative method for range / bitmask selection that may be used in step 130 of FIG.
[0058] According to this embodiment, the final encoding, instead of using one fixed 2-bit mask as in the previous method, selects from 16 different ranges and range combinations the one that results in the best compression ratio. On the one hand, the bit mask indicating which of the 16 encodings was the best consumes an additional 4 header bits, but on the other hand, the 32-bit overhead required for the 4-6-8-16-bit encoding of the previous method is eliminated. However, as shown here, some of the 16 encodings also use bit masks, but these only consume 1 bit per value, since they only distinguish between two ranges, and for the entire block of 16 values only 16 bits of overhead are lost.
[0059] More specifically, 16 unsigned 16-bit values (i.e., 16 numbers from 0 to 65535) need to be stored in memory time-efficiently. Since the values are residuals (the difference limits of the wavelet decomposition), they are usually small and noisy, so it is not worth compressing them further. Because they are small, we do not need to use 16 bits for each value, and we could try to compress them in fewer bits. We could simply find the largest number of the 16 numbers and store all the values in the bit range of that number. However, if the numbers are outliers, it would be better to store most of the numbers in the smaller bit range and separate the outliers in the larger bit range.
[0060] When searching for the optimal bit range or combination of bit ranges, the following aspects should be taken into consideration:
[0061] 1. If bit ranges are stored, only the header needs to contain the bit range selected, and all numbers are stored with that bit range. Example: 1 0 3 2 1 3. In this case, 2 bits are enough. But if many of the numbers can be stored with fewer bits, it may be convenient to store the numbers as a combination of bit ranges. For example, in 1 0 3 200 1 3, all numbers are stored with 2 bits, and 200 is stored with 8 bits. The drawback of bit range combinations is that a bit mask is needed to indicate where (in this example) 2-bit numbers and 8-bit numbers are stored. The mask then looks like 000100, and the 16 numbers are 16 bits long. The best tradeoff between "bit ranges" and "bit mask + bit range combinations" must be found.
[0062] 2. The bit range or combination of bit ranges should match the numbers being stored as closely as possible so that no memory space is wasted.
[0063] 3. The search for the best bit range combination should be fast, so not too many bit range combinations should be tested.
[0064] 4. Bit range combinations should be chosen so that they are fast to store. For example, with 7-bit and 15-bit bit range combinations (i.e. each of the 16 numbers is encoded in either 7-bit or 15-bit), many bits have to be shifted and word (byte) boundaries have to be taken into account. For example, a bit range combination of 8-bit and 16-bit is much faster.
[0065] In an embodiment of the present invention, the following 16-bit ranges and bit range combinations are proposed: 0, 1, 2, 3, 4, 2 / 5, 5, 3 / 6, 6, 4 / 8, 8, 6 / 12, 12, 6 / 16, 8 / 16, 16. For each block of 16 numbers, 2 44 bits must be used to indicate which of the 16 bit ranges (combinations) were used.
[0066] For a block of 16 unsigned short integers, first it is checked how many of them need how many bits for encoding. Based on the distribution of the required bit range it is decided whether all of them are stored as n-bit values or a bitmask encoding is used and some of them are stored as n-bit values and the rest are stored as m-bit values.
[0067] 0-bit range: all values are 0, write nothing.
[0068] 1-bit range: each value can be encoded using 1 bit, and 16 x 1 bits are stored.
[0069] 2-bit range: each value can be encoded using 2 bits, and 16 x 2 bits are stored.
[0070] 3-bit range: each value can be encoded using 3 bits, and 16 x 3 bits are stored.
[0071] 4-bit range: each value can be encoded using 4 bits, and 16 x 4 bits are stored.
[0072] 2 / 5 Bitmask: No value is more than 5 bits, and there are enough 2-bit values that the bitmask encoding is worthwhile compared to storing every value in 5 bits. The bitmask stores the lowest 2 bits of every value and the highest 3 bits of every 5-bit value.
[0073] 5-bit range: each value can be encoded using 5 bits, and 16 x 5 bits are stored.
[0074] 3 / 6 Bit Mask: No value is more than 6 bits, and there are enough 3-bit values that the bitmask encoding is worthwhile compared to storing every value in 6 bits. The bitmask stores the lowest 3 bits of every value and the highest 3 bits of every 6-bit value.
[0075] 6-bit range: each value can be encoded using 6 bits, and 16 x 6 bits are stored.
[0076] 4 / 8 Bit Mask: No value is more than 8 bits, and there are enough 4-bit values that the bitmask encoding is worthwhile compared to storing every value in 8 bits. The bitmask stores the lowest 4 bits of every value and the highest 4 bits of every 8-bit value.
[0077] 8-bit range: each value can be encoded using 8 bits, and 16 x 8 bits are stored.
[0078] 6 / 12 Bit Mask: No value is more than 12 bits, and there are enough 6-bit values that the bitmask encoding is worthwhile compared to storing every value in 12 bits. The bitmask stores the lowest 6 bits of every value and the highest 6 bits of every 12-bit value.
[0079] 12-bit range: each value can be encoded using 12 bits, and 16 x 12 bits are stored.
[0080] 6 / 16 Bit Mask: There are enough 6-bit values that bitmask encoding is worthwhile compared to storing every value in 16 bits, and the bitmask stores the lowest 6 bits of every value and the highest 10 bits of every 16-bit value.
[0081] 8 / 16 Bit Mask: There are enough 8-bit values that bitmask encoding is worthwhile compared to storing every value in 16 bits, so we store the bitmask, the lowest 8 bits of every value, and the most significant 8 bits of every 16-bit value.
[0082] 16-bit range: 16 x 16 bits are stored.
[0083] For each block of 16 unsigned short integers, the encoding that uses the smallest number of bits is selected.
[0084] Figure 6 shows a binary search method (in pseudocode) for determining suitable bit ranges (combinations). In the pseudocode in Figure 6, the "space" function measures the space requirement using a particular encoding scheme, for example using 6 / 16 combinations.
[0085] Similar schemes can be constructed for 8-bit, 32-bit or 64-bit data. For example, 8 bits of data can be encoded using the following bit ranges: 0, 1, 2, 4, 2 / 6, 4 / 6, 4 / 8 and 8.
[0086] Since there are 16 different encodings, four header bits are needed to communicate which encoding was selected. Being able to choose from more than these 16 possibilities would certainly help to better encode the numbers, but it would require more than four header bits, and more encodings would require more range tests, which would slow down the algorithm. The above combinations are a compromise between compression ratio and speed, since they cover many noise levels, signal strengths, and yet do not require too many checks. Most importantly, they are simple enough to be programmed with AVX2 instructions, which is usually not the case for more complex algorithms, especially those using Huffman trees and bitstreams.
[0087] The layout of the compressed block of 16x16 values is as follows:
[0088] [Table 1]
[0089] The 16 4-bit range specifiers are stored contiguously as a 64-bit number, so that if the data is incompressible it is possible to check using only one if instruction. As seen in the encoding listing above, if a block of 16 values is not compressible and can only be stored by copying them, then its 4-bit header is 15, which in binary is 1111. If all 16 blocks are stored like that, then the 64-bit number has all bits set, which can be checked with if(x==-1), where x is a 64-bit integer containing the 16 4-bit range specifiers.
[0090] Uncompressed data normally has all header bits set to 1. However, compressible 16-bit data will also have all header bits set to 1 if it is not exactly aligned on a 16-bit boundary in memory, which will happen if the file whose data is to be compressed has an odd number of header bytes. Here are two examples showing the importance of precise alignment for compressing 16-bit unsigned integers:
[0091] [Table 2]
[0092] In example 1, the data is 16-bit aligned so the algorithm will be able to store the numbers at least as 8-bit values rather than 16-bit values. In the next example, the numbers are the same but a header byte has been added, which causes the numbers to be unaligned.
[0093] [Table 3]
[0094] In example 2, the data is no longer 16-bit aligned, so the lower byte becomes the higher byte and the data becomes incompressible for that range encoder.
[0095] In such a case, all 64 header bits are set to 1, indicating that the data is unaligned (or indeed not compressible). The block of 256 values is not reread, instead it is simply written uncompressed. But then the next byte from the input stream is simply copied (to the output stream), so the input stream is 16-bit aligned. If the data is uncompressible, this doesn't make anything better, but it doesn't make anything worse either.
[0096] Figure 7 shows an example of 2 / 5 bit encoding of 16 values: in the encoded stream, the bitmask is sent first (2 bytes), followed by 10 2-bit values (20 bits -> 3 bytes), then 6 5-bit values (30 bits -> 4 bytes).
[0097] Optionally, a heuristic check (not shown) may be performed during the initial read step 120 to catch long sequences of constant or incompressible data.
[0098] [benchmark] Figure 8 shows the results of comparing the method of the present invention with known compression methods, where the method described in connection with Figure 1 (hereinafter referred to as fc16) is compared with state-of-the-art compression programs in the table below.
[0099] [Table 4]
[0100] Compared to the various compression algorithms offered by libraries density and TurboPFor, the ones mentioned in this table performed best on this benchmark dataset.
[0101] Some programs allow you to control the compression ratio, trading compression speed. Usually this is done through command line switches -1 (fastest speed) and -9 (maximum compression). This benchmark was run on a 20-core Intel® Xeon® CPU E5-2698 v4 @ 2.20GHz with 512GB RAM, 32KB LI cache per core, 256KB L2 cache per core, and a disk I / O rate of ≈1GB per second. All programs in this benchmark were run in a single thread, without any other resource-consuming programs running on the machine. Since the compression (decompression) speed can approach or exceed the disk I / O rate, all benchmarks are run in-memory using programs provided by each author, so disk I / O is not a bottleneck for the algorithms. For gzip and lzma, there is no in-memory benchmark mode, but their bottleneck is not input / output (I / O), so they simply read the test file from disk and write the compressed output to / dev / null, which means that the output is discarded and no time is spent writing anything to disk. Algorithms 1-3 are not part of this benchmark because they are inferior to algorithm 4 (fc16) in every aspect. There are many other compressors, but the list above covers everything from best compression ratio to fastest compression. It is unfair to compare with lzma, gzip, zstd, snappy and density, but that is because they are general-purpose compressors, which means that, like TurboPFor and fc16, they can compress any kind of data, not just integers. However, many scientists use them on their data, so it may be interesting for them to know how the compression ratio and speed change if they use TurboPFor or fc16. The compression suites TurboPFor and density offer several compression programs, so the best three are included in this benchmark.
[0102] This test data set comprises the following files (ordered from least noisy to most noisy): hawc.dat (HAWC data), gerda.dat (GERDA data), ctamc.dat (CTA prod3 Monte Carlo simulations), fc_300MHz.dat (FlashCam data artificially fired at a photon rate of 300 MHz / pixel), fc_1200MHz.dat (FlashCam data artificially fired at a photon rate of 1200 MHz / pixel), chec.dat (CHEC-S data not 16-bit aligned), and chec_aligned.dat (same as check.data, but the first byte of the file has been removed so the data is 16-bit aligned).
[0103] [result] As seen in Figure 8, fc16 compresses almost as well as the most powerful compression algorithm (lzma), but is three orders of magnitude faster. Its closest competitor in compression speed (vbzenc16) has a much worse compression ratio and is significantly slower to decompress. Also, when the data is not so simple to compress (CHEC and ctamc), its compression speed drops to half that of fc16. Its closest competitors in decompression speed and compression ratio (p4nzenc16 and p4nzenc128v16) compress 80% slower than fc16. They have slightly better compression ratios than fc16, but are slower to decompress in almost all cases. Furthermore, they cannot handle unaligned data.
[0104] When compared to other fast integer compression algorithms, p4nzenc16 and p4nzenc128v16, the method of the present invention is almost always the fastest compressor and decompressor. General-purpose compressors snappy, chameleon, cheetah, lion, and lz4 lose to fc16 due to their slow compression speed and poor compression ratios. Other general-purpose compressors, lzma, gzip, and zstd, are comparable to fc16 in compression ratio, but are orders of magnitude slower.
[0105] The two top plots in Figure 8 show the average ratio of compression (decompression) speed and compression ratio for all data sets. These numbers are important because they tell the user how much uncompressed data can be processed ("written compressed" or "read decompressed"). The bottom plot is a combination of compression speed, decompression speed and compression ratio. It shows the average compression and decompression speed divided by the compression ratio, which is the average speed at which uncompressed data can be processed.
[0106] p4nzenc16 and p4nzenc128v16 have been unified since they have the same compression ratio and compression speed. The same is done for gzip-1, gzip-9 and zstd-9.
[0107] [Parallel processing] Since the independently processed blocks are only 512 bytes in size, the method of the present invention can be parallelized very easily. Such a small block size also simplifies the implementation in hardware.
[0108] This parallelizability is also reflected in the implementation of fc16. To use multiple threads, the input stream is split into blocks of typically about 1MB, and then each block is processed in a separate thread. Compression speeds of 2-3GB / s and decompression speeds of 2-3GB / s per thread are achieved on a typical desktop PC. The speed increases with the number of threads, but is not linear. In in-memory tests, multiple threads on a Xeon processor achieved compression speeds of over 10GB / s.
[0109] This algorithm was also specifically designed to run fast on CPUs with vector instructions. For the AVX2 implementation, a block size of 16 16-bit numbers was used, since AVX2 registers are 256-bits large.
[0110] Parallelization at this smallest level works by applying one arithmetic operation to all 16 numbers simultaneously. For example, if you have 16 numbers x[0], x[1], ..., x
[15] in an AVX2 register from which you want to subtract one number n, AVX2 can in principle work like y=vector_subtract(x,n) and take only one processor clock cycle. Using serial programming, you would have to use a loop like (i=0;i<16;i++){y[i]=x[i]-n}, which would take more clock cycles. Our fc16 algorithm is kept particularly simple to consist mostly of only simple operations like addition, subtraction, comparison, etc., which exist as vector instructions and usually require only one clock cycle.
[0111] When designing an algorithm to be parallelized with AVX2, the algorithm is very limited because it has fewer arithmetic operations at its disposal, and (more importantly) all numbers in registers are treated equally.
[0112] In conclusion, the reasons why the method of the present invention is suitable for parallelization are as follows.
[0113] The algorithm itself (and the corresponding hard-coded dictionary) produces only simple arithmetic operations, which are the same for any number in the registers.
[0114] Small block size of 256 numbers (-->512 bytes), these are processed independently.
[0115] [Energy efficiency] This algorithm is more energy efficient than conventional algorithms that must first build a Huffman tree or similar.
[0116] [Application example] The algorithm is also suitable for image compression, so there are many possible applications. For example, during a self-driving test drive, all sensor data (more than 90 percent 12-bit RGB (red-green-blue) raw streams, as in the benchmark above) is recorded so that it can be understood later why and how the system reacted. 50-100 terabytes of data per car per day are stored during such a test drive. All data is recorded losslessly, so data recording becomes the limiting factor. There are companies that specialize in selling such recording boxes to car manufacturers. With the method of the present invention, the data acquisition speed or data capacity can be doubled.
[0117] As a further example, when a professional photographer takes continuous photos with a single-lens reflex camera, for example at 50 megapixels and 8 frame rate in RAW format, the SD card cannot keep up with the writes and the photos have to be stored in a cache. This is why the maximum continuous shooting speed or the time that photos are taken continuously is limited. Also, the SD card fills up quickly. Using the method of the present invention in a camera (in an FPGA or chip) allows for more than twice the continuous shooting and allows twice as many images to be stored on the SD card.
[0118] In a further example, when a large movie is edited in a video editor, the video must often be written to the hard disk and then read again each time. This is done in RAW format, because compression takes too long. Using the method of the present invention, the input / output can be accelerated. The amount of data per second of a 4k movie at 30Hz and 8-bit color depth is only 700MB, but soon an 8k movie at 60Hz and 12-bit color depth will appear, which is already 8GB / s. Using fc16 as a plug-in for a video editor, customers can get faster input / output.
[0119] Finally, the method of the present invention can also be used to compress the display stream from a graphics card to a monitor.
[0120] [Conclusion] The compression ratio can be improved by making the algorithm stateful. A larger set of possible encodings can be defined, from which a subset can be selected for encoding of a block of 256 values. Depending on the frequency with which each encoding is used, different subsets can be selected from the larger set. For example, if the data is very noisy, it is not necessary to include the first 8 encodings in the above list, but instead they can be replaced by other encodings that are suitable for larger numbers, such as the 10-bit range or the 10-14 bit mask encoding. It is also possible to reduce the header size from 4 bits to 2 or 3 bits and include only the encodings that are useful for that kind of data.
Claims
1. 1. A computer-implemented method for lossless compression of digital data values, the method comprising: Obtaining a sequence of digital data values; selecting a bit length of a codeword; mapping the sequence of digital data values into a sequence of code words, each codeword having one of the selected bit lengths; a mapping of the sequence of codewords to a sequence of codewords; packing the sequence of code words into a sequence of memory words having a uniform bit length and corresponding to a fixed size of data treated as a unit by an instruction set or processor hardware; outputting the sequence of memory words along with a first bit mask indicating the bit length of each code word; Including, The method, wherein the method is performed using vector instructions.
2. one or more bit lengths are selected from the following bit lengths or combinations of bit lengths: 0, 1, 2, 3, 4, 2 / 5, 5, 3 / 6, 6, 4 / 8, 8, 6 / 12, 12, 6 / 16, 8 / 16, 16; 2. The method according to claim 1 .
3. the codewords have non-uniform bit lengths; The method according to claim 1 or 2.
4. the bit length of the codeword is at least two of 4, 6, 8 and 16 bits; The method according to any one of claims 1 to 3.
5. The codewords have only two different bit lengths. The method according to claim 3 or 4.
6. the two different bit lengths of the codewords are one of the following combinations: 2 / 5 bits, 3 / 6 bits, 4 / 8 bits, 6 / 12 bits, 6 / 16 bits, or 8 / 16 bits; The method according to claim 5.
7. Packing the sequence of codewords comprises: First, packing a sequence of 11 bits of each codeword into said memory word, l1 corresponds to the minimum bit length of the codeword; Packing a sequence of l1 bits; then packing remaining bits of said codewords having a bit length greater than l1 into said remaining memory words; Includes The method according to any one of claims 1 to 6.
8. Packing the remaining bits of the codeword having a bit length greater than l1 may include: first packing a sequence of 12-11 bits of each remaining codeword into said remaining memory word; The l2 corresponds to the second smallest bit length of the codeword. packing a sequence of l2-l1 bits; then subsequently packing the remaining bits of the codewords having a bit length greater than l2 into the remaining memory words; Including, The method according to claim 7.
9. only the absolute values of the digital data values are mapped to code words; The method according to any one of claims 1 to 8.
10. and outputting, for each digital data value, information indicative of its sign.
10. The method of claim 9.
11. Obtaining the digital data values includes: receiving a block of original digital data values; transforming the original block of digital data values to obtain the digital data values; Including, The method according to any one of claims 1 to 10.
12. the transform approximating the original data values in the block and outputting residual values; The residual values represent the differences between the original data values and their approximations. The method of claim 11.
13. the blocks of original digital data are transformed using a wavelet transform; 13. The method according to claim 11 or 12.
14. The wavelet transform is a morphological wavelet transform. The method of claim 13.
15. The wavelet transform is an iterated wavelet transform.
15. The method according to claim 13 or 14.
16. The wavelet transform is repeated four times. The method of claim 15.
17. The method is implemented using AVX2 instructions.
17. The method according to any one of claims 1 to 16.
Citation Information
Patent Citations
Data processing method and data processor
WO2005079076A1
Encoding device and method, composite device and method, and transmission system
WO2007058296A1
