45
FRIEDRICH-ALEXANDER-UNIVERSITÄT ERLANGEN-NÜRNBERG TECHNISCHE FAKULTÄT DEPARTMENT INFORMATIK Lehrstuhl für Informatik 10 (Systemsimulation) Data compression for simulation data from Earth mantle convection Lena Leitenmaier Bachelor thesis

Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

FRIEDRICH-ALEXANDER-UNIVERSITÄTERLANGEN-NÜRNBERG

TECHNISCHE FAKULTÄT • DEPARTMENT INFORMATIK

Lehrstuhl für Informatik 10 (Systemsimulation)

Data compression for simulation data from Earth mantleconvection

Lena Leitenmaier

Bachelor thesis

Page 2: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

Data compression for simulation data from Earth mantleconvection

Lena LeitenmaierBachelor thesis

Aufgabensteller: Prof. Dr. U. RüdeBetreuer: Dr. B. GmeinerBearbeitungszeitraum: 1.7.2014 – 30.11.2014

Page 3: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

Erklärung:

Ich versichere, dass ich die Arbeit ohne fremde Hilfe und ohne Benutzung anderer alsder angegebenen Quellen angefertigt habe und dass die Arbeit in gleicher oder ähnlicherForm noch keiner anderen Prüfungsbehörde vorgelegen hat und von dieser als Teil einerPrüfungsleistung angenommen wurde. Alle Ausführungen, die wörtlich oder sinngemäßübernommen wurden, sind als solche gekennzeichnet.

Der Universität Erlangen-Nürnberg, vertreten durch den Lehrstuhl für Systemsimulati-on (Informatik 10), wird für Zwecke der Forschung und Lehre ein einfaches, kostenloses,zeitlich und örtlich unbeschränktes Nutzungsrecht an den Arbeitsergebnissen der Bache-lor thesis einschließlich etwaiger Schutzrechte und Urheberrechte eingeräumt.

Erlangen, den 26. November 2014 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Page 4: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

Abstract

This thesis gives an overview of the effects of diverse compression techniques applied tosimulation data from convection-diffusion problems. Different methods are tested usingexemplary data sets in 1D, both lossless and lossy compression are taken into account.Then the better performing techniques are adopted for two dimensional problems. Theintroduced error and its effects are analyzed in detail.

Page 5: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

Contents

1. Introduction 1

2. Mantle convection simulation 22.1. Governing equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.2. Characteristics of temperature data . . . . . . . . . . . . . . . . . . . . . . 3

3. Data compression terms 3

4. 1D-techniques 44.1. The test data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44.2. Data representations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54.3. Lossless compression techniques . . . . . . . . . . . . . . . . . . . . . . . . 6

4.3.1. Standard compression techniques . . . . . . . . . . . . . . . . . . . 64.3.2. FPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84.3.3. Overview of compression factors . . . . . . . . . . . . . . . . . . . 8

4.4. Lossy compression techniques . . . . . . . . . . . . . . . . . . . . . . . . . 94.4.1. Saving with reduced precision . . . . . . . . . . . . . . . . . . . . . 94.4.2. Transform coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.4.3. Hierarchical data representation . . . . . . . . . . . . . . . . . . . 144.4.4. Difference compression . . . . . . . . . . . . . . . . . . . . . . . . . 16

4.5. Comparison of the different techniques . . . . . . . . . . . . . . . . . . . . 17

5. 2D-techniques 195.1. The test data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195.2. Lossless compression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195.3. Quantization using reduced precision . . . . . . . . . . . . . . . . . . . . . 205.4. Transform coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205.5. Hierarchical difference compression . . . . . . . . . . . . . . . . . . . . . . 215.6. Summary of 2D compression techniques . . . . . . . . . . . . . . . . . . . 23

6. Influence of the introduced error 246.1. 1D error experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246.2. 2D error experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

7. Conclusions 32

A. 1D compression factors 34

ii

Page 6: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

List of Figures

4.1. The 1d test data sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44.2. Entropy of the 1D test data sets computed with binwalk [2] using 512

byte blocks. Graph of text file cut after 8000 byte. . . . . . . . . . . . . . 64.3. GZIP and LZMA compression of text and binary data set 1. . . . . . . . 74.4. Sizes of fft compressed data sets accurate up to 3, 4 and 5 digits in com-

parison to original binary size . . . . . . . . . . . . . . . . . . . . . . . . . 114.5. Euclidean error norm of fft compressed data. . . . . . . . . . . . . . . . . 124.6. Sizes of wavelet compressed data sets accurate up to 3, 4 and 5 digits in

comparison to original binary size. . . . . . . . . . . . . . . . . . . . . . . 134.7. Euclidean error norm of wavelet compressed data plotted against number

of components not set to zero. . . . . . . . . . . . . . . . . . . . . . . . . . 144.8. Scheme of hierarchical data representation method. . . . . . . . . . . . . 144.9. Euclidean error norm of hierarchical saving. Basis points double precision,

differences saved with 1, 2, 4 and 8 byte. . . . . . . . . . . . . . . . . . . 154.10. Sizes of example data set 1 (left) and 2 (right) after different lossy com-

pression techniques. Resulting values accurate up to 3 digits. . . . . . . . 184.11. Sizes of example data set 1 (left) and 2 (right) after different lossy com-

pression techniques. Resulting values accurate up to 5 digits. . . . . . . . 18

5.1. 2D test data. Flowfield with 250 x 257 points. Thermal diffusivity κ =0.003, 20000 timesteps with ∆t = 0.001 [10]. . . . . . . . . . . . . . . . . 19

5.2. Error of wavelet compressed 2D test data. . . . . . . . . . . . . . . . . . 215.3. Sizes of example data saved with reduced precision compared to hierar-

chical saving in combination with difference compression. . . . . . . . . . 22

6.1. Development of error of data rounded to 3, 4 and 5 digits . . . . . . . . . 246.2. Development of error of data rounded and floored to 3 digits . . . . . . . 256.3. Development of error rounded to 3 digits - pure diffusion and convection-

diffusion problem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266.4. Development of 2D error rounded to 3, 4 and 5 digits after 15% of

timesteps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266.5. Development of 2D error rounded to 3 digits at selected points of time . 276.6. 2D error 30000 timesteps after rounding to 3 digits and change in absolute

energy (1% intervals). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286.7. 2D error 30000 timesteps after rounding to 3 digits with and without

change of total energy (2% intervals). . . . . . . . . . . . . . . . . . . . . 28

iii

Page 7: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

6.8. 2D error 30000 timesteps after rounding to 3 digits with different roundingtechniques (2% intervals). . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

6.9. 2D error 30 000 timesteps after rounding to 3 digits and at the end of thesimulation run after 100 000 timesteps. . . . . . . . . . . . . . . . . . . . 30

6.10. 2D error when compression using the hierarchical difference compressionmethod accurate up to 3 digits in comparison to simple rounding . . . . 31

6.11. 2D error 30000 timesteps after rounding to 7 digits. . . . . . . . . . . . . 32

iv

Page 8: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

List of Tables

4.1. Absolute sizes and compression factors of data set 1 using different losslesscompression techniques. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

4.2. Size and precision of different data types together with size and compres-sion factor of the example data saved with that data type. . . . . . . . . 9

4.3. Size and compression factor of GZIP compressed example data with dif-ferent original data types. . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4.4. Size and compression factor example data set 1 compressed using hierar-chical saving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4.5. Compression factors of difference compression referring to gzipped singleprecision binary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

5.1. Absolute sizes and compression factors of 2D example data using differentlossless compression techniques. . . . . . . . . . . . . . . . . . . . . . . . 20

5.2. Absolute sizes and compression factors of the example data using quanti-zation (left) and hierarchical difference compression (right). . . . . . . . . 23

A.1. Absolute sizes and compression factors of data set 1 . . . . . . . . . . . . 35

v

Page 9: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

1. Introduction

Due to rapidly growing cluster compute power, today big simulation runs that deal withhuge amounts of data are possible. Nevertheless these simulation runs still take a lotof time and in huge cluster systems the probability of problems such as node failuresrises. Therefore it is important to do checkpointing during the run to be able to restartif necessary. Besides, it might be useful to have intermediate results to trace back thedevelopment of errors or other phenomena that might occur over time.

Since writing those intermediate checkpoints is slow this thesis investigates ways ofreducing the size of data and thus the required time by using data compression. Theresults are meant to be especially of use to earth mantle convection simulation usinghierarchical grids. However, the example data used for testing was generated from ageneral convection diffusion problem.

There is a broad variety of image and audio compression techniques, as data compressionis very popular there. Yet many of those techniques are based on the nature of humanperception and include big errors where value conservation is concerned. They aretherefore not suitable for simulation data compression.

As pointed out in [12], lossy compression of simulation data in general is a delicateissue. Therefore different lossless compression schemes have been developed as e.g. in[12], [6] and [13]. However, as will be explained in chapter 3, the compression factorsthat can be achieved using lossless compression techniques are limited. Therefore thereare several approaches of applying lossy compression techniques while still achievingreasonable accuracy.

Which accuracy might be reasonable and whether it is possible to reduce accuracy at alldepends on the application. [11] investigates lossy compression for three specified phys-ical simulation codes and finds that it can be used to different extends. [18] compressesfluid dynamics simulation data using image compression techniques.

Motivated by those approaches, in this thesis different techniques for compressing simu-lation data from convection diffusion problems such as mantle convection will be tested.For reasons of simplicity, at first we will consider a 1D problem. After some generaldeliberations, we will regard a few lossless techniques in section 4.3 and then treat lossy

1

Page 10: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

compression in 4.4. Afterwards the findings from those sections will be transferred to a2D problem in 5.

The aim is to develop a technique that provides good compression while only introducinga very low error. For achieving this goal, the nature of the data and the bigger setup(the HHG [1] project) that the problem is one day meant to be dealt with have to beconsidered.

In chapter 6 we will look more closely at the influence of error introduced to the simu-lation data at different points of time. This allows to make assessments regarding howmuch error can be introduced if a specific precision requirement has to be met at theend of a simulation run.

Finally, in chapter 6.2 some more possibilities for data compression and things that haveyet to be done before the discussed methods can be used efficiently for checkpointingwill be outlined shortly.

2. Mantle convection simulation

2.1. Governing equations

Mantle convection is based on mass, momentum, and energy conservation. To simplifythose one can assume incompressability and the Bossinesq approximation. This statesthat due to slow motion because of large viscous friction forces in comparison to buoyancyforces inertial terms can be neglected [14]. The convection process can then be describedby

−∇ · (η(u + (u)T )) +∇p = RaTer (2.1)

∇ · u = 0 (2.2)δT

δt+ u · ∇T −∇ · (κ∇T ) = γ (2.3)

where η is the viscosity, Ra the Raleigh number, er the unit vector in radial direction.κ is the thermal diffusivity and γ the rate of internal heat generation. All these have tobe given as input parameters and/or are material-dependent [10] [?] [?] .

Furthermore the equations contain three unknown quantities, temperature T , pressure pand velocity u. However, once T is known we can derive the other two measures from it

2

Page 11: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

with comparatively little computational cost. T on the other hand can only be computedby extensive time integration. Therefore this thesis only deals with the compression oftemperature data. We assume that thereby achieved gain outweighs the cost neededto recover pressure and velocity by far. However, this does not necessarily hold for allapplications. Sometimes it might be better to save all three quantities.

2.2. Characteristics of temperature data

Temperature data from earth mantle convection simulation are typically relatively smoothwith only minor changes locally. However, they do contain some quite big differences atplumes. Furthermore when looking at the temperature globally it goes from very hot inthe core to much cooler at the earth crust. This means that the values that have to berepresented vary a lot in total. For this thesis we will assume that the temperature datais non-dimensionalized and thus scaled to the range [0 : 1].

3. Data compression terms

Compression performance can be measured in different ways. On the one hand one canuse the compression ratio on the other hand the compression factor.

compression factor =size of inputsize of output

=1

compression ratio

Good compression means a big compression factor and a small compression ratio, dataexpansion means a compression factor smaller and a ratio bigger than 1. Since thecompression factor seems more natural to many people it will be used in this thesis tomeasure compression performance [15, p.10].

Another important term is that of information content. According to Claude Shannonit is equivalent to the amount of surprise, i.e. unexpected developments in a message. Ifthe probability of an event is low its occurrence contains a lot of information whereas avery probable event is not surprising and contains only little information [17, p.13].

The entropy of data is a measure for the information content and depends on the in-dividual probabilities that a certain symbol ai occurs in that data. For data with n

symbols entropy of is highest if the probabilities for all n symbols are equal, i.e. if theyare uniformly distributed. If this is not the case but some symbols are more probablethan others, the data contains redundancy, which is defined as the difference between a

3

Page 12: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

symbol set’s actual and highest possible entropy [15, p.51].

Data compression aims to remove this redundancy from data. If no more redundancyis contained, the data is fully losslessly compressed. No more compression is possiblewithout loss of information.

Compression techniques that accept a certain loss of information are called lossy com-pression techniques. Usually they can achieve arbitrarily good compression factors,however, the original data cannot fully be recovered. The more information is lost thesmaller the size required to represent the remaining information.

4. 1D-techniques

To get a feeling for diverse compression techniques we will start with one-dimensionalproblems. For those implementation of the different methods is more simple but we canstill get a good indication of their performance.

4.1. The test data

For evaluation of the 1d tests two different data sets will be used as plotted in figure 4.1.To generate them

dT

dt− dxxT + udxT = 0

was discretized using central differences. 13 · 1.000.000 euler steps with δt = 2e−9 were

done. A constant velocity field was used, u = 1 for the left and u = 10 for the rightexample. In both cases the left boundary value was set to 1, the right one to 0.

Fig. 4.1.: The 1d test data sets.

4

Page 13: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

The x-range of the data is [0, 10] discretized by 1000 points. Initial values were randomlygenerated. In the left example this was done using a uniform distribution from theinterval [0.3, 0.6], in the right example a normal distribution N(0.5, 1.5). Additionallythose values were multiplied with (1− 1

10x) to get a decline from left to right.

Data set number 1 contains (neglecting boundaries) only small differences between thevalues at the single points. The second data set contains bigger differences. In additiondue to the higher velocity there is a considerable region at the beginning that is almost 1.Together those two data sets contain all the characteristics of temperature data specifiedin chapter 2.2.

4.2. Data representations

Before one can really deal with compression techniques a short consideration of datarepresentations is necessary. There are two common ways to save data: in text files orin binary files.

The advantage of text files is that in contrast to binaries they are human readable.However, for checkpointing applications this is not a very important point as for restartsor postprocessing the data has to be read by another program anyway. Binaries aretypically written faster than text files which is a plus, but what matters from the currentpoint of view is the number of bytes that is needed to represent a number. This varieswith the number of decimal digits. If we have very short numbers like for example 0.1

it is better to save them in text (1 byte for each symbol, i.e. 3 bytes) than as a binary(4 bytes for single- and 8 bytes for double-precision).

Additionally, if the numbers are scaled to the range [0 : 1[ the 0. could be skipped as allpossible numbers have it in common. However, as soon as we have more than two digitswe want to represent it is more effective to use an appropriate binary data representationthan text. Which representation might be appropriate for a certain number of digits istreated in more detail in section 4.4.1.

For now we will assume that data with full double precision are necessary. As a IEEE 754double precision number has at least 15 significant digits 15 non-leading-zero numberswould need to be saved in a text file. Using C++-scientific standard additionally theletter “e” for exponential and 2 or 3 exponential digits and - at the end of the number -a space have to be saved [5]. In total that makes at least 20 symbols and thus 20 bytesneeded to represent one number with 8 byte binary description.

5

Page 14: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

4.3. Lossless compression techniques

Losslessly compressed data can exactly be recovered, therefore lossless compression tech-niques have to be used wherever no difference between original and compressed data istolerable [17, p.4]. However, as pointed out in section 3 lossless compression is limitedby the redundancy contained in the data. As simulation data from earth mantle convec-tion as in the used examples typically does not contain very much redundancy, losslesscompression techniques cannot perform very well. Considering one byte a symbol andcomputing the entropy for blocks of 512 symbols results in entropy values as plotted infigure 4.2. The entropy of the binary test data is about 83% for data set 1 and about87% for data set 2 in the regions where the data is not very close to 1 and thus veryrepetitive. The same data in text representation has naturally a much lower entropy(43% and 44%). The text files have a much bigger original size though. Note that thevalues for both example data sets are very similar. The amount of redundancy does notincrease a lot due to the much smaller variations of values in data set 1.

Fig. 4.2.: Entropy of the 1D test data sets computed with binwalk [2] using 512 byteblocks. Graph of text file cut after 8000 byte. .

4.3.1. Standard compression techniques

The first lossless methods to be considered are the so-called standard compression tech-niques, i.e. methods that are commonly used to compress data. They are for examplepart of UNIX-based operating systems by default.

4.3.1.1. GZIP

GZIP uses the compression algorithm DEFLATE, which is made up by two strategies:Huffman coding and LZ77 compression. Huffman coding substitutes fixed-length sym-bols by representations who’s length depends on their statistical probability. The moreoften a symbol occurs in a file the shorter the code it is replaced by. LZ77 replaces

6

Page 15: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

reappearing sequences of data by pointers to the prior occurrence. For this DEFLATEuses a 32-Kb-long sliding window as a dictionary and a 258 byte look-ahead buffer. Thesearch buffer is searched for the longest sequence that matches the look-ahead buffer. Ifno match is found for a sequence its first symbol is written to the output as a literal [7][15, p.243, p.1047].

For integration of GZIP into the project code gzstream [9] was used. When compressingthe test data with GZIP the effects expected from entropy considerations appear clearly.For both data sets we get compression factors of approximately 1.1 for binary and 2.2

for text representation. The total binary GZIP compression factor, i.e. original textrepresentation to compressed data is 2.4. This means that the compressed text data isalmost as small as the compressed binary data (see figure 4.3). The reason for this isthat text data contains much less different symbols and therefore is a lot more suitablefor the DEFLATE algorithm.

4.3.1.2. LZMA

Another LZ77 variant is LZMA (Lempel-Ziv-Markov chain-Algorithm). It uses a largersearch buffer than GZIP and range encoding instead of Huffman coding. The LZMAencoder is more complicated than the GZIP one, but usually results in better compression[15, p.241-243].

Fig. 4.3.: GZIP and LZMA compression of text and binary data set 1.

When comparing the sizes of LZMA compressed and GZIP compressed test data asdisplayed in figure 4.3 we can easily see that the LZMA compressed files are considerablysmaller. Again text files with a compression factor of 2.8 compress much better than

7

Page 16: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

binaries (1.3). However, in the end the binary file is still a little smaller.

4.3.2. FPC

A different kind of lossless compression technique is FPC [13]. This algorithm is meantto generate high throughput while also compressing well [3]. It is based on a predictionscheme, i.e. it uses two different predictors, fcm and dfcm from CPU branch predictionto guess the next value [4, p.20]. The better one of those guesses is xored with the truevalue, which results for a good guess in many leading zeros. The number of leadingzero bytes is then encoded using 3 bits plus 1 bit that represents which predictor wasused. This code block and all following non-zero digits are then written to the output.Decompression can reconstruct the original values from the 4-bit code and the remainingdigits since xor is reversible [4, p.19].

When using FPC for compressing the test data sets we get a compression factor of 1.3from the not compressed binary. The FPC compressed data has almost the same sizeas LZMA compressed data (see figure 4.1). This means a total compression factor of2.8. As FPC only works for binary files no comparison with the text representation ispossible.

4.3.3. Overview of compression factors

Table 4.1 offers an overview of the resulting sizes and compression factors when thecompression techniques introduced above are applied to the first data set. The sizes forthe second data set differ only slightly.

absolute size compression factor

original text 17848 1

original binary 8000 2.23

GZIP text 8029 2.22

GZIP binary 7294 2.45

LZMA text 6470 2.76

LZMA binary 6287 2.83

FPC binary 6310 2.83

Table 4.1.: Absolute sizes and compression factors of data set 1 using different losslesscompression techniques.

8

Page 17: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

As can be seen, best compression factors are achieved using LZMA or FPC on binarydata. However, when using runtime as a measure for computational cost, LZMA andFPC also take significantly longer then GZIP. The default variant lzma -6 takes morethan 6 times, fpc 20 about 4 times as long as gzip. Different compression options canachieve better runtimes but then compression gets worse.

Considering those runtime differences, GZIP was included into the implementation andused as a lossless compression technique from here on.

4.4. Lossy compression techniques

As pointed out in chapter 3 the performance of lossless compression techniques is limitedby the redundancy in data. To get better compression factors there are a variety of lossycompression techniques. We will now take a closer look at some of those methods.

4.4.1. Saving with reduced precision

Probably the most effortless way to diminish file sizes when loss of information is accept-able is to simply save data with reduced precision. This results in a simple quantizationand works for both ways of saving data. For text representations we simply store lessdecimal digits, for binary representations different data types have to be chosen. Table4.2 gives an overview of some obvious data types and the compression factors achievedthereby.

Data type bytes sig. digits example size comp. factor

double 8 min. 15 8000 1

float 4 min. 6 4000 2

half 2 min. 3 2000 4

int16_t 2 min. 4 2000 4

int8_t 1 min. 2 1000 8

Table 4.2.: Size and precision of different data types together with size and compressionfactor of the example data saved with that data type.

double, float and half are IEEE 754 standard data types. Numbers saved usingint16_t and int8_t first have to be scaled to a suitable data range and are then savedas integer types. This approach is very similar to [18, p. 1023f]. The precision attainedwith integer types depends on the range of the original data, here a necessary data rangeof [−1; 1] is assumed.

9

Page 18: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

As can easily seen by comparing one byte per digit with the data type sizes in table4.2, pure text representations are always bigger then corresponding binary representa-tions providing the same accuracy. However, in combination with a lossless compressiontechnique like GZIP they give better results for very few digits in most situations.

In general, combining a lossy and a lossless compression technique is a good way toimprove compression factors. As a lossless technique GZIP was chosen here due to goodintegrability into the code and (most) uncomplicated algorithm. In combination with itthe distinct data types show different compressability. As the integer types are used intheir whole range due to the required scaling of the original data they compress relativelybad. That can be seen well if one compares the compressed sizes of half and int16_tin table 4.3, especially for data set 1.

Data type size data 1 compr.factor 1

size data 2 compr.factor 2

double 7294 1.10 7297 1.10

float 3335 2.40 3359 2.38

half 1213 6.60 1619 4.94

int16_t 1648 4.85 1833 4.36

int8_t 211 37.9 575 13.9

Table 4.3.: Size and compression factor of GZIP compressed example data with differentoriginal data types. Compression factors refer to double binary.

An interesting observation is that while the two data sets have almost the same size fordouble and single precision, for smaller types the first data set is compressed significantlybetter. The reason for this is that when it comes down to only very few decimals the firstdata set becomes very homogeneous while the second one keeps more of its differences.

Very important is to also consider the error introduced by saving the data with the newtypes. It is crucial to see that when compressing by reducing precision every reductionof size is paid for by a higher error. This means that although saving the data as anint8_t would give great compression factors it is useless in practice. A more detailedexamination of errors and their influence in a restarted simulation will take place inchapter 6.

10

Page 19: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

4.4.2. Transform coding

Transform coding methods apply some kind of transform to describe the original data bymeans of coefficients. These coefficients can then be saved efficiently. If transform codingis used as a lossy compression technique the least important of the coefficients are set tozero until the desired compression rate is achieved. For reconstruction of the data theinverse transform has to be applied [17, p.413f.]. Transform coding is especially popularfor image compression. For example the widely used JPEG standard is based on theDiscrete Cosine Transform, a variant of the Discrete Fourier transform [15, p.1047].

In the implementation of the following methods the GNU Scientific Library (GSL) [8]was used for realization of the transforms.

4.4.2.1. Fourier Transform

The first transform coding method applied to the example data was the Fast FourierTransform (FFT). The resulting coefficients were stored using the different data typesdescribed above. To profit from zeroing coefficients the resulting file was gzipped.

To be able to compare the resulting sizes of different methods a common requirementhad to be set. We will use the absolute number of accurate digits measured using theinfinity error norm for this purpose. This will be meant whenever there are statementsabout accuracy in the following.

For FFT coding, sizes for 3, 4 and 5 accurate decimal digits are displayed in figure 4.4.

Fig. 4.4.: Sizes of fft compressed data sets accurate up to 3, 4 and 5 digits in comparisonto original binary size. Left: data set 1, right: data set 2.

11

Page 20: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

For three accurate digits the coefficients could be saved using IEEE 754 half precision.Due to a few very high coefficients compared to the other ones integer representationsdo not make sense. For more then three digits half precision is not sufficient anymore,single precision has to be used. This results in more then doubling of final size fromthree to four digits accuracy.

Another important observation is that for the example data sets almost no coefficientscould be set to zero while still meeting the accuracy requirement. Figure 4.5 additionallyshows the euclidean error norms for both example data sets. It can be found that thereis a very steep slope at the end of the plot, i.e. when only very few coefficients are setto zero. Zeroing more coefficients results only in a moderate increase of error, however,the infinity norm is then already too high to meet the requirements.

Fig. 4.5.: Euclidean error norm of fft compressed data plotted against number of com-ponents not set to zero. Half and single precision representation of numbers.Left: data set 1, right: data set 2.

This means that for the example data sets we cannot achieve reduction of file sizes bysetting coefficients to zero. Compression happens only due to the reduced precision datatypes and GZIP. This also explains why accuracy requirements of 4 and 5 digits resultin the same final size and why the difference between the data sets is very small.

When testing with different data sets one finds that FFT transform coding works wellfor very high frequent data. For other setups, like both example data sets, one can onlyachieve marginal improvements of file sizes.

4.4.2.2. Wavelet Transform

A different kind of transform coding uses the Discrete Wavelet Transform (DWT). This isthe transform also used in the JPEG2000 standard [18, p.1026]. While Fourier transforms

12

Page 21: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

use sine and cosine, which are global, as basis functions, wavelet basis functions aredefined locally [20, p.289]. They originate from a mother wavelet, “a compact supportfunction which satisfies

∫∞−∞Φ(t)dt = 0 ”[16, p.1251]. Those local basis functions deal

better than global ones with confined functions that only appear in a short interval oftime or space [20, p.289].

Fig. 4.6.: Sizes of wavelet compressed data accurate up to 3, 4 and 5 digits in comparisonto original binary size. Left: data set 1, right: data set 2.

When implementing this method different kinds of wavelets (haar, daubechies, b-spline)were tested. Biorthogonal B-spline wavelets turned out to provide the best results for thetested data sets. After applying the wavelet transform, coefficients up to the accuracythreshold are set to zero. Again the file has to be gzipped to profit from this. Theremaining coefficients can be saved as IEEE 754 half precision values if accuracy up to3 digits is required, for 5 digits we need single precision. 4 digit accurate values canbe represented with half precision for data set 1, for the second data set we need singleprecision. The according file sizes are displayed in figure 4.6.

When comparing sizes between the two example data sets it can be seen that the firstdata set is compressed significantly better than the second one. Further tests showedthat wavelet compression profits a lot from smooth data and low absolute differences.

Figure 4.7 shows that in comparison to FFT the wavelet compression error ascends moreslowly and is overall smaller. This also means that much more coefficients can be set tozero until the accuracy threshold is reached. For half precision representations the erroris very long not bound by the number of zeroed coefficients but by the accuracy of halfprecision.

Compared to FFT compression the compression factor achieved using wavelets is up to

13

Page 22: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

Fig. 4.7.: Euclidean error norm of wavelet compressed data plotted against number ofcomponents not set to zero. Half and float representation of numbers. Left:data set 1, right: data set 2.

3.6 times higher (3 digits accuracy, first data set). However, for 5 digit representationsit is only 1.03 times higher. Anyway, wavelet compression worked better in all cases forthe example data sets.

4.4.3. Hierarchical data representation

The idea to use hierarchical data representations for lossy data compression is closelyrelated to the background this thesis is originated from. When we consider a projectthat already includes a multigrid structure of hierarchical grids as the HHG framework[1] it seems natural to think of a compression approach using that.

The method that was developed here assumes that there is a multigrid algorithm usingsimple pointwise restriction and prolongation. Values are simply copied from the finegrid to the coarse one and back again. For the values at the points that are not part ofthe coarser grid the difference to their preceding neighbor point is computed and storedseparately. Schematically this is shown in figure 4.8.

Fig. 4.8.: Scheme of hierarchical data representation method.

The thought behind this approach is that the differences should be smaller absolutevalues with less digits significant for accuracy than the original values. Thus they can bestored with reduced precision which diminishes file sizes. In the following the hierarchical

14

Page 23: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

grids will be called levels. The numbering is as displayed in figure 4.8, i.e. one level meansno coarsening, two levels mean one coarsening and so on.

For saving the differences single and half precision values as well as int16_t and int8_twere tried. The values at the remaining points were saved with single or double precision.The resulting errors can be compared in figure 4.9.

Fig. 4.9.: Euclidean error norm of hierarchical saving. Basis points double precision,differences saved with 1, 2, 4 and 8 byte.

It turned out that to get results in the desired accuracy region the differences had tobe saved with at least 2 bytes per value. There int16_t provides better accuracy andresults when gzipped in sizes only a little larger then using IEEE half. For the remainingpoints in the end single precision was used to get better compression.

After adding the differences to the resumed points again the single precision values werestill more accurate than most of the difference points. This can after a simulation restarthelp to re-balance the overall accuracy.

The compression factor of this method depends on the number of levels used. WithoutGZIP the size of originally n numbers on level l is theoretically given by

n

2l−1· 4 + n

(1− 1

2l−1

)· 2

In practice implementation problems occur if not n = 2a + 1 with arbitrary a. To avoidthose problems for other n the grid sizes have to be expanded, which results in biggersizes. For example data set 2 those are displayed in table 4.4. Additionally the resulting

15

Page 24: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

sizes of gzipped files are given.

levels size size withGZIP

compr. factor

1 4000 3359 1

2 3094 2701 1.24

3 2592 2354 1.43

4 2346 2180 1.54

5 2228 2065 1.63

6 2174 2011 1.67

7 2152 1987 1.69

Table 4.4.: Size in bytes and compression factor of example data set 1 compressed usinghierarchical saving with different numbers of levels. Compression factors referto gzipped single precision binary.

Absolute file size reduction decreases with every additional level, while the error in-creases. Therefore for the example data sets no more than 4 or 5 levels are reasonable.

Problems of this hierarchical data representation method are that the differences that arestored for correction are computed regarding the original values and their neighboringpoints, but in the end they are added to reconstructed values that already includesome error. Thus at the corrected points those errors add up with the errors that areintroduced by saving the corrections with reduced precision. Additionally, depending onthe data set, the differences between values, especially on coarser grids, might not bethat small after all. Saving them with reduced precision might therefore not be fitting.

4.4.4. Difference compression

Taking the problems of hierarchical saving into account leads to the difference compres-sion approach. Here the first value is chosen as a reference value. For the next valuesthe difference to this reference point is computed. This is a form of residual coding asdescribed in [17].

If the difference is smaller than a threshold it is encoded using an appropriate num-ber of bits. To determine which number of bits is necessary, in practice several limitsfor different numbers of bits (4, 6, 8, 10, 12, 16, 24) and accuracy requirements wereimplemented. Values that are smaller then a specific limit value can be encoded usingthe corresponding number of bits such that they provide the required accuracy. If the

16

Page 25: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

difference is bigger than the highest limit it it chosen as the new reference point.

Additionally it has to be stored which number of bits was used for each value. This wasrealized using a simple gzipped text file that contains integer values from ±2 to ±9.

accurate decimals comp. factor dataset 1

comp. factor dataset 2

3 2.95 2.95

4 2.06 2.05

5 1.72 1.19

Table 4.5.: Compression factors of difference compression referring to gzipped single pre-cision binary.

The resulting compression factors with regard to the binary gzipped single precisionfile are listed in table 4.5. It can be observed that the method profits a lot from thelower absolute differences in data set 1 when it comes to 5 decimals accuracy, as thenumber of absolute and not significant decimal digits is enforced by the used accuracyrequirement.

4.5. Comparison of the different techniques

In this section we will briefly compare all the lossy compression techniques introducedso far. For comparison values accurate up to 3 and 5 digits will be used. The sizes forFFT, wavelet and difference compression are created to exactly fit those requirements.Comparison with reduced precision values is less compatible. The values for half areaccurate for approximately 3.3 digits. float however gives at least 6 digits accuracy butis used here anyway as there is no standard data type that provides 5 accurate digits.

The displayed levels sizes in figure 4.10 and 4.11 are the ones that best meet the require-ments. For 3 digits accuracy that means that the differences were saved using IEEE halfprecision and 3 coarsening (“levels 4”), 5 digit accurate numbers can be achieved usingint16_t representation and only 1 coarsening (“levels 2”).

As can be seen in figure 4.10 for values accurate up to 3 digits wavelet compression worksbest, followed by difference compression. For 5 digits of accuracy however wavelets don’tperform very good anymore, now difference compression and hierarchical representationusing only two levels give the best results as figure 4.11 shows.

However, those methods perform better for the smoother data in example 1. For data

17

Page 26: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

Fig. 4.10.: Sizes of example data set 1 (left) and 2 (right) after different lossy compressiontechniques. Resulting values accurate up to 3 digits.

Fig. 4.11.: Sizes of example data set 1 (left) and 2 (right) after different lossy compressiontechniques. Resulting values accurate up to 5 digits.

set 2 it is worth considering whether avoiding the effort and simply saving the dataas gzipped single precision values (which gives 6 digits accuracy) might be the betteroption.

When comparing runtimes of the different techniques as implemented, wavelet compres-sion, hierarchical representation and difference compression take about the same amountof time. The example data sets are too small to say whether time differences are reallysignificant. Furthermore all implementations still contain a lot of optimization potential.Quantization by saving with reduce precision, however, is as expected a lot faster.

A complete list of both lossless and lossy compression factors with regard to the originaltext file achieved for the first data set can be found in appendix A.

18

Page 27: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

5. 2D-techniques

5.1. The test data

The example data for the two-dimensional case was generated using the flowfield codeStefan Henneking generated for his bachelor thesis [10]. This means now the energyequation as stated in section 2.1 is being solved. A relatively small resolution of 250×257

points was chosen to get fast results. Thermal diffusivity κ was set to 0.003 to havemoderately fast propagation of information. The resulting temperature field after 20000timesteps is displayed in figure 5.1.

Fig. 5.1.: 2D test data. Flowfield with 250 x 257 points. Thermal diffusivity κ = 0.003,20000 timesteps with ∆t = 0.001 [10].

The size of the resulting temperature data file was about 1,1 MByte, approximately 64times the size of the 1D data sets. This influences runtimes as well as the behavior ofthe applied methods.

5.2. Lossless compression

In comparison to the 1D data sets lossless standard compression techniques performbetter for the 2D example data (c.f. table 5.1). One reason for this is that the 2D

19

Page 28: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

test data contains big regions with very similar data both at the boundaries and in thecenters of the two halves. Another reason is that the 1D data sets were to small to fullyutilize the search buffers. LZMA compresses clearly better than gzip now, however, italso takes more then 3 times as long even when running LZMA with fastest (and thusworst) compression level. The default level which yields the compression factor 4.6 asstated in table 5.1 takes even more than 5 times as long. This phenomenon alreadyshowed in 1D, but with growing data sets it becomes more important.

FPC does not profit from the new and bigger 2D data set and will therefore not beconsidered any more.

absolute size compression factor

original text 1142225 1

original binary 514000 2.22

GZIP binary 309509 3.69

LZMA binary 248464 4.60

FPC binary 411270 2.78

Table 5.1.: Absolute sizes and compression factors of 2D example data using differentlossless compression techniques.

5.3. Quantization using reduced precision

Saving the data with reduced precision works for 2D data just as it did for 1D, no specialadaptions have to be made. In combination with GZIP good compression factors can beachieved, as can be seen from table 5.2.

However, this method does not profit (much) from the 2D dependencies, it compressesthe data as if it were linear which is a disadvantage in comparison to other methods.

5.4. Transform coding

As FFT compression didn’t perform well in the 1D case, for 2 dimensions only waveletcompression was adapted.

However, for the 2D example data wavelets didn’t perform well either. GZIP compressedwavelet coefficients result in a size corresponding to a compression factor of 4.75 for3 digits accuracy. This is about the size of the LZMA compressed binary with fullaccuracy.

20

Page 29: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

In 2D haar wavelets performed better then the bspline wavelets that worked best in the1D case. The coefficients had to be saved with single precision, half precision did notprovide sufficient accuracy.

The DWT provided by the GSL [8] that was used for testing can only deal with square2n × 2n matrices. Other matrices have to be padded to meet this requirement. Thissignificantly worsens results when the additional values are not saved in the output file.Therefore the example setup was changed to 250× 256 points for wavelet compression,as a dimension of 257 is a worst case scenario with regard to padding.

This means that the example setup originally contained 64000 values. For 3 digitsprecision using wavelet compression 64335 single precision numbers had to be saved,i.e. more than the original values. The resulting Euclidean error norm was about 0.014as can be observed in figure 5.2. As the coefficients contain bigger variations than theoriginal data they are less suitable for GZIP-compression.

Therefore wavelet compression does not make sense for this or comparable data sets.Simply saving the original values as gzipped binary single precision numbers results inan error norm of about 7.2e-06 and a size which is more then a factor of 2 smaller thanusing wavelet compression.

Fig. 5.2.: Error of wavelet compressed 2D test data.

Furthermore, compared with the other methods the implementation of this techniqueperformed very slowly. For bigger matrix sizes it was practically unusable.

5.5. Hierarchical difference compression

Taking in account the advantages and disadvantages of hierarchical data representa-tion and difference compression as used for the 1D case, a new, combined method was

21

Page 30: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

developed.

This method uses hierarchies and computes the difference from points that are notpart of the coarser grid to the remaining points as explained in 4.4.3. In 2D the ratio ofremaining to removed points is 1:3. Now the differences for three points to one remainingpoint have to be computed.

These differences are then saved using different numbers of bits depending on the size ofthe value that has to be saved as in 4.4.4. In comparison to 1D, the values were not cutafter the required number of decimals but rounded. This improves energy conservationand leads to much better decay of the resulting error as will be showed in chapter 6.

Furthermore, if two subsequent values are the same for the second one no value is saved.There is only an entry in the precision file to indicate the identity. To gain more fromthis difference numbers that only differ by a value smaller then a threshold are equalizedbefore saving.

Fig. 5.3.: Sizes of example data saved with reduced precision compared to hierarchicalsaving in combination with difference compression.

This method results in good compression for 3, 4 and 5 decimal digits required accuracyas can be seen in figure 5.3. Note that the compared original size this time is the non-gzipped single precision binary. Plotted against the sizes achieved with this method arethe sizes of gzipped half, int16_t and single precision files that provide approximatelythe same precision. While 3 digits hierarchical difference compression needs only abouthalf the size of a gzipped IEEE754 half precision file, for numbers accurate up to 7decimal digits the sizes are almost the same. One reason for this is that for this accuracyrequirement almost all numbers have to be saved with at least 24 bits. If a finer stepping

22

Page 31: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

was implemented for high numbers of bits - currently only 16, 24 and 32 bits are possible- the hierarchical difference compression size for high accuracy requirements might beimproved.

5.6. Summary of 2D compression techniques

In summary it can be said that by combining lossless and lossy compression really goodcompression factors can be achieved. As shown in table 5.2, hierarchical differencecompression as implemented gives about twice the factor as simple quantization for lowaccuracy requirements in the infinity norm. For higher requirements the compressionfactors of two methods are about the same, then quantization should be preferred dueto lower computational cost. However, part of this effect might be due to non-optimalimplementation of the hierarchical difference compression method for high accuracy.The implemented transform coding methods did not work well in 2D for any accuracyrequirement.

sizequantization

compressionfactor

size hier.diffcomp.

compressionfactor

original text 1142225 1 1142225 1

orig. binary 514000 2.22 514000 2.22

7 digits 164279 6.95 158903 7.12

5 digits 87596 13.04

4 digits 103310 11.06 65566 17.42

3 digits 78506 14.55 37555 30.41

Table 5.2.: Absolute sizes and compression factors of the example data using quantiza-tion (left) and hierarchical difference compression (right).

The question how the loss of information introduced by the compression techniquesdiscussed here influences simulation results after a restart will be treated in the nextchapter. Different numbers of accurate digits will be covered. Then the possible com-pression factors showed here can be classified according to practical use.

23

Page 32: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

6. Influence of the introduced error

As pointed out in [11], “that lossy compression may change simulation results is notnecessarily a showstopper - many decisions made in setting up a simulation also changethe answer.” Those decisions are usually “based on the desired accuracy of variousintegral physical quantities, not by comparing per-grid-point differences like the meansquare error between two proposed simulations.” Therefore they “propose using thesame integral physical quantities to assess the impact of compression.” Regarding this,in the following chapter the effects of errors as introduced by lossy compression will beevaluated using the discrete L2 norm rather then the infinity norm.

6.1. 1D error experiments

For first error examinations a very simple setup was chosen. The second 1D exampleproblem but without convection term was run, once without disruption and once witha break after 1

10 of the timesteps. During this break all values were rounded to 3, 4 or5 digits respectively, then the simulation was restarted. The resulting error comparedto the original simulation run is displayed in figure 6.1. We can observe that afterthe restart the error decays rather quickly and then consolidates about one order ofmagnitude smaller than the error that occurs directly after the break.

Fig. 6.1.: Development of error of data rounded to 3, 4 and 5 digits

24

Page 33: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

Using a typical error measurement setup and setting both boundary values to zero givesessentially the same results.

However, as figure 6.2 shows this rapid decay depends on the nature of the error. If thevalues are not rounded to the required number of digits during the break but are cutafter this number, the error stays almost constant. As all cut values are smaller thanthe original ones they can not rebalance each other. The introduced error has a lowfrequency that does not get damped well.

Fig. 6.2.: Development of error of data rounded and floored to 3 digits

Another factor that influences the occurring error seems to be the point of time at whichthe simulation is stopped. This effect shows even stronger in 2D, there possible causeswill be analyzed.

In practice we do not only want to treat pure diffusion problems. For comparing thoseto convection-diffusion problems runs of both kinds of problems were disrupted after 1

10

of the timesteps and the intermediate results were rounded. The resulting errors canbe compared in figure 6.3. They show approximately the same behavior for a long timeinterval. The convection-diffusion error is a little higher in this example, however, whenrunning different tests this does not hold necessarily.

This means that conclusions derived for diffusion problems should also hold for convec-tion diffusion in a certain time frame. When running a longer simulation though, thecurves start to differ. After approximately 2.400.000 timesteps the convection diffusionerror drops and finally vanishes.

The reason for this is that after enough time all points of the convection diffusion problemreach a constant value, in this cases zero due to the chosen boundary conditions. Thenthe error introduced in the beginning does not matter anymore.

25

Page 34: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

Fig. 6.3.: Development of error rounded to 3 digits - pure diffusion and convection-diffusion problem.

6.2. 2D error experiments

In 2D there was no special diffusion-only error examination, the example problem asintroduced in chapter 5 was used. After 15% of the timesteps all values were roundedto 3, 4 or 5 digits respectively. The resulting error is displayed in figure 6.4.

Fig. 6.4.: Development of 2D error rounded to 3, 4 and 5 digits after 15% of timesteps

Its general behavior is similar to the 1D case, however, the graphs contain more variationsthan before. Furthermore it is noticeable that the lines for the different numbers of digitsdo not look as if they were simply shifted between orders of magnitude anymore, as theywere in 1D. They now show different developments.

26

Page 35: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

For this example the error does reduce by more then 2 orders of magnitude when roundingto three digits, for five digits it reduces by approximately 1.5 orders. When testing moreone comes to the conclusion that the error cancellation seems to be better in 2D thenin 1D. The initial errors are also smaller than before, which is mostly due to the highernumber of zeros contained in the example data.

An interesting fact is that the point of time of the error introduction seems to influenceits development. This effect already showed in the 1D case, but is more distinct now.We can observe it in figure 6.5. There the development of the error after rounding to3 digits at selected points of time is displayed. Error decay varies from not even oneorder of magnitude for error introduction at 10% of timesteps to almost three orders at15%.

Fig. 6.5.: Development of 2D error rounded to 3 digits at selected points of time

To examine this in more detail we have to look at figure 6.6. This graph shows thesize of the error 30000 timesteps after its introduction for varying disruption points(green line). Error values for disruption points advancing in 1% steps were measuredand plotted. Errors that are introduced very shortly before the end of a simulation willnot have time to reduce and thus have a bigger influence to the final result. Thereforeonly error introduction points up to 75% of the total time were considered here.

In figure 6.6 we can not see any clear trend with advancing time of error causation. Thisshows that not really time, but only the state of the simulation at the different pointsof time influences the error behavior.

When looking for reasons for the varying error sizes, different quantities describing thesimulation were considered. However, only the amount of energy that is lost or addedwhen rounding the values to the required number of digits seems to be considerablycorrelated to the error development. This energy difference is displayed by the red line

27

Page 36: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

Fig. 6.6.: 2D error 30000 timesteps after rounding to 3 digits and change in absoluteenergy (1% intervals).

in figure 6.6. Removing the change of energy does not smooth the resulting error much,though, as can we can see in figure 6.7. This figure shows the error with loss of energy(green) in comparison to the error after a simulation run that do not loose energy. Thegraphs now show error introduction points advancing in 2% steps.

Fig. 6.7.: 2D error 30000 timesteps after rounding to 3 digits with and without changeof total energy (2% intervals).

The red line in figure 6.7 plots the error that results when multiplying the values afterrounding with a factor such that the original energy is conserved. The yellow linedisplays the error when adding a small quantity to the rounded values to prevent changesof energy. Both lines behave very similarly but the error is only improved a little -

28

Page 37: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

sometimes even not at all - compared to the version without energy conservation. Onereason for this might be that even then only a very low percentage of energy, less then0.005%, is lost.

Total variation as another system describing quantity is also influenced only slightly byrounding of the values. It typically varies by less then 0.001% after some timesteps.

The remaining variations in error sizes do not seem to depend on system quantities butsimply on the different rounding relationships of the values at the individual points oftime. There is the danger of creating step functions when rounding in regions with verysimilar values. If a series of the same value is created it will be very hard to reducethe error contained in this region later. Therefore random containing alternatives toclassic rounding were considered. We now will regard rounding a number x to d digitsrepresented by

bx · 10d + ac/10d

For classic rounding the additional factor a is 0.5. If we instead chose a to randomly be0 or 1 we get poor results as displayed by the line for total random in figure 6.8. Ignoringthe values’ bias completely is not a good idea. But if we choose a to be a random valuefrom the interval [0.4; 0.6] the outcome improves, for a few points of error introductionthe results are better than with classic rounding. This shows that the remaining errorvariations with time are indeed based on the relations of the variables when rounding.However, general improvement of this factor is not easily possible. The influence of the

Fig. 6.8.: 2D error 30000 timesteps after rounding to 3 digits with different roundingtechniques (2% intervals).

relations of variable at varying states of time also explains the dissimilar behaviors of the

29

Page 38: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

lines related to rounding to 3, 4 or 5 accurate digits in figure 6.4. As different numbersof digits are preserved the decimals that define the relationship between the variablesare also different ones.

Disruptions around 10% of time result in especially bad errors. A reason for this is thatin contrast to earlier error introduction the system does already contain many non-zerovalues then but does still change a lot. Therefore errors do have a bigger influence thenerrors introduced later on.

Finally we will now look again at the influence of time. Before we considered the er-ror 30000 timesteps after its introduction. This allows to compare error decay values,however, the errors reduce longer then this. Figure 6.9 shows the error considered up tonow in comparison to the error introduced at the same point of time but measured atthe end of the simulation after 100 000 timesteps. There are two effects observable.

Fig. 6.9.: 2D error 30 000 timesteps after rounding to 3 digits and at the end of thesimulation run after 100 000 timesteps.

Even though the initial error of the run without changes in energy is almost constant theresulting error is very oscillatory since rounding effects are not easily eliminated. Thoseoscillations are even more distinct at the end of the simulation run.

Disregarding this we see that errors introduced in the first 40% of time have reducedmuch more in the time exceeding 30000 timesteps after the interference than thoseintroduced later. This shows that neglecting the rounding effects it is - as one wouldexpect - better if the error occurs early on and has more time to reduce. However, withregard to rounding problems that does not hold anymore.

30

Page 39: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

Error introduced by the hierarchical difference compression method

The error introduction that was used up to now resembles saving with reduced precision,i.e. quantization. Now we will look at the error generated when compression usingthe hierarchical difference method introduced in section 5.5. Figure 6.10 shows thiserror when compressing using 4 levels after 10, 20 or 30 % of a total 100000 timestepsrespectively. The lighter lines show the development of the error when using the previousscaled rounding method at the same points of time for comparison.

We see that the general behavior of both hierarchical difference compression and simplerounding is approximately the same. However, the rounding error develops better. Forsome points like the bad error introduction point at 10 % this improvement is almostnegligible, for other cases, e.g. for 30%, it makes a bigger difference.

Fig. 6.10.: 2D error when compression using the hierarchical difference compressionmethod accurate up to 3 digits in comparison to simple rounding

A reason for this better development is that while both methods are created to fulfillthe same infinity norm requirement the hierarchical difference method tries to get theaccuracy of all values close to the required threshold. Quantization in contrast providesmore variety in the range of accuracy. Therefore in many cases the L2-error of quantiza-tion is lower from the beginning and additionally has more re-balance potential. Overallthough the hierarchical difference compression does perform well, too. The previousfindings of this chapter also apply for this method for low numbers of accurate digits.For higher numbers the hierarchical difference compression method cannot re-balanceanymore and the error consolidates at a much higher level than with rounding. This canalso be observed in figure 6.11.

31

Page 40: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

Findings of the error experiments

The size and behavior of the errors in the example problems do seem to justify lossycompression for that kind of problems for certain applications. Especially when savingwith 5 digits accuracy only small errors in the order of 1e-8 occur. But also errors around1e-6 to 1e-7 that can be achieved with only 3 digits might be legitimate for many tasks.However, varying errors at different points of time are a problem as they make it difficultto give definite statements about the magnitudes of the error.

For applications with very high accuracy requirements those errors are not tolerablethough. There one can consider using quantization with 7 digits accuracy which 30000after the disruption results in errors smaller then 1e-10 as displayed in figure 6.11. Forhierarchical difference compression using more digits does not help much.

Fig. 6.11.: 2D error 30000 timesteps after rounding to 7 digits.

7. Conclusions

In the context of this thesis a collection of different compression techniques was imple-mented that can be applied to different kinds of simulation data. Both lossless and lossycompression were taken into account. For different kinds of data the achievable compres-sion factors may vary, especially for data that does not show the same characteristics asthe example data used here and is for e.g. very high frequent.

For the used example data, lossless compression techniques could only achieve compres-

32

Page 41: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

sion factors up to 4.6 in 2D as they are limited by the contained redundancy. Lossymethods could achieve factors up to 6 times higher while still obtaining some accuracy.However, which amount of error introduction is acceptable depends on the applicationand the purpose of the data. For lossy compression both quantization by simply savingthe data with reduced precision and a hierarchical difference compression method gavenice results. The latter compresses better, but this advantage comes at higher compu-tational cost and is sometimes only marginal. For low accuracy requirements the errorsintroduced by both methods are mostly in the same range. Higher accuracy can onlybe achieved using saving with reduced precision, the hierarchical difference compressionmethod fails there.

The methods as implemented are not yet suitable to be applied for any bigger purpose.For completeness the methods would need to be expanded to three dimensions. Thisshould not change the general behavior of the different methods but will have greatinfluence on computational complexity and cost.

In this thesis we focused on the compressing properties of different methods, compu-tational cost was only considered very briefly. However, for practical usage this wouldalso be a very important factor. Therefore a chosen method would have to be optimizedto improve time and memory requirements. Additionally MPI parallelization of bothcomputation and writing process are necessary for application in big simulations. Thereasynchronous writing as introduced for example in [19] should be considered.

33

Page 42: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

A. 1D compression factors

Complete listing of compression factors for 1D data set 1:

absolute size compression factor

original text 17848 1

original binary 8000 2.23

Lossless techniques

GZIP text 8029 2.22

GZIP binary 7294 2.45

LZMA text 6470 2.76

LZMA binary 6287 2.83

FPC binary 6310 2.83

Quantization

double 7294 2.44

float 3335 5.35

half 1213 14.71

int16_t 1648 10.83

int8_t 211 84.58

Transform coding

FFT 3 digits 1582 11.28

FFT 4 digits 3744 4.77

FFT 5 digits 3744 4.77

Wavelet 3 digits 436 40.94

Wavelet 4 digits 1709 10.44

Wavelet 5 digits 3529 5.06

34

Page 43: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

absolute size compression factor

Hierarchical saving

1 level 3359 5.31

2 level 2701 6.61

3 level 2354 7.58

4 level 2180 8.19

5 level 2065 8.64

6 level 2011 8.87

7 level 1987 8.98

Difference compression

3 digits 1137 15.79

4 digits 1631 10.94

5 digits 1954 9.13

Table A.1.: Absolute sizes and compression factors of data set 1

35

Page 44: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

Bibliography

[1] Benjamin Bergen, Tobias Gradl, Ulrich Rüde, and Frank Hülsemann. A massivelyparallel multigrid method for finite elements. Computing in science & engineering,8(6):56–62, 2006.

[2] http://binwalk.org/.

[3] Martin Burtscher and Paruj Ratanaworabhan. High throughput compression ofdouble-precision floating-point data. In Data Compression Conference, 2007.DCC’07, pages 293–302. IEEE, 2007.

[4] Martin Burtscher and Paruj Ratanaworabhan. Fpc: A high-speed compressor fordouble-precision floating-point data. Computers, IEEE Transactions on, 58(1):18–31, 2009.

[5] http://www.cplusplus.com/reference/ios/scientific/.

[6] Vadim Engelson, Dag Fritzson, and Peter Fritzson. Lossless compression of high-volume numerical data from simulations. In Data Compression Conference, page574. Citeseer, 2000.

[7] Antaeus Feldspar. An explanation of the deflate algorithm, 1997.

[8] http://www.gnu.org/software/gsl/.

[9] http://www.cs.unc.edu/Research/compgeom/gzstream/.

[10] Stefan Henneking. Evaluation of time discretization methods for mantle convectionsimulation. Bachelor thesis, 2014.

[11] Daniel Laney, Steven Langer, Christopher Weber, Peter Lindstrom, and Al We-gener. Assessing the effects of data compression in simulations using physicallymotivated metrics. Scientific Programming, 22(2):141–155, 2014.

[12] Peter Lindstrom and Martin Isenburg. Fast and efficient compression of floating-point data. Visualization and Computer Graphics, IEEE Transactions on,12(5):1245–1250, 2006.

36

Page 45: Data compression for simulation data from Earth mantle … · 2015. 5. 13. · from the not compressed binary. The FPC compressed data has almost the same size as LZMA compressed

[13] Paruj Ratanaworabhan Martin Burtscher. The fpc double-precision floating-pointcompression algorithm and its implementation. 2008.

[14] Wolfgang Bangerth Martin Kronbichler, Timo Heister. High accuracy mantle con-vection simulation through modern numerical methods. Geophisical Journal Inter-national, 2012.

[15] David Salomon. Data Compression - The Complete Reference. Springer, 4th edition,2007.

[16] Surya Santoso, Edward J Powers, and WM Grady. Power quality disturbance datacompression using wavelet transform methods. Power Delivery, IEEE Transactionson, 12(3):1250–1257, 1997.

[17] Khalid Sayood. Introduction to DATA COMPRESSION. Morgan Kaufmann, 4thedition, 2012.

[18] Jörg Schmalzl. Using standard image compression algorithms to store data fromcomputational fluid dynamics. Computers & geosciences, 29(8):1021–1031, 2003.

[19] Faisal Shahzad, Markus Wittmann, Thomas Zeiser, and Gerhard Wellein. Asyn-chronous checkpointing by dedicated checkpoint threads. Springer, 2012.

[20] Gilbert Strang. Wavelet transforms versus fourier transforms. Bulletin of the Amer-ican Mathematical Society, 28(2):288–305, 1993.

37