source: thirdparty/SZ/sz/include/pastri.h @ 2c47b73

Revision 2c47b73, 5.2 KB checked in by Hal Finkel <hfinkel@…>, 6 years ago (diff)

more work on adding SZ (latest version)

  • Property mode set to 100644
Line 
1//CHECK:
2//What happens when ECQBits==1, or ECQBits==0 or ECQBits<0?
3//Rounding? Scale originalEb by 0.99?
4
5//Possible improvement: Change GAMESS format: {i i i i d} -> {i}{i}{i}{i}{d}
6//Possible improvement: Optimize bookkeeping bits
7//Possible improvement: Guess the type (C/UC, Sparse/Not)
8//Possible improvement: Get rid of writing/reading some of the indexes to in/out buffers
9//Possible improvement: Get rid of all debug stuff, including Makefile debug flags
10//Possible improvement: Get rid of "compressedBytes"
11//Possible improvement: SparseCompressed, ECQBits=2: 1's and -1's can be represented by just 0 and 1, instead 10 and 11.
12//Possible improvement: SparseCompressed, ECQBits>2: Again: 1: 10, -1:11, Others: 0XX...XX
13//Possible improvement: WriteBitsFast: maybe remove some masks?
14//Possible improvement: WriteBitsFast: Get rid of multiple calls!
15//Possible improvement: UCSparse: Indexes use 64 bits. It can be lowered to _1DIdxBits
16//Possible improvement: Parameters: Smaller data sizes may be possible!
17
18
19
20#ifndef PASTRI_H
21#define PASTRI_H
22
23#include <stdio.h>
24#include <stdlib.h>
25#include <stdint.h>
26#include <string.h>
27#include <math.h>
28#include <assert.h> //Just for debugging purposes!
29
30//#define DATASIZE 8 //Bytes per input data point.
31//We have only 1 double per data point, so it is 8 bytes.
32
33#define MAX_PS_SIZE 100
34#define MAX_BLOCK_SIZE 10000
35#define MAX_BUFSIZE 160000  //Should be a multiple of 8
36#define D_W 0 //Debug switch: Write (input block)
37#define D_R 0 //Debug switch: Read (compressed block)
38#define D_G 0 //Debug switch: General
39#define D_G2 0 //Debug switch: General 2 (a little more detail)
40#define D_C 0 //Debug switch: C
41//#define DEBUG 1 //Debug switch
42
43//#define BOOKKEEPINGBITS 0 //Currently unused
44//#define BOOKKEEPINGBITS 120 //Includes: mode, indexOffsets, compressedBytes, Pb_, ECQBits_ (8+64+32+8+8)
45//BOOKKEEPINGBITS is defined here, because if P & S is going to be used, they appear just after the bookkeeping part.
46//This allows us to write P and S directly onto using outBuf.
47 
48
49// IMPORTANT NOTE:
50//Read/Write up to 56 bits.
51//More than that is not supported!
52
53
54/********************************************************************/
55//Datatype Declarations:
56/********************************************************************/
57typedef struct pastri_params{
58  double originalEb; //Error Bound entered by the user
59  double usedEb; //Error Bound used during compression/deceompression
60 
61  int numBlocks; //Number of blocks to be compressed
62  int dataSize; //8(=Double) or 4(=Float)
63 
64  int bf[4]; //Orbital types (basis function types). Typically in range [0,3]
65  int idxRange[4];  //Ranges of indexes. idxRange[i]=(bf[i]+1)*(bf[i]+2)/2;
66 
67  int sbSize; //=idxRange[2]*idxRange[3];
68  int sbNum;  //=idxRange[0]*idxRange[1];
69  int bSize; //=sbSize*sbNum;
70 
71  //uint16_t idxOffset[4]; //Index offset values. No longer used.
72 
73}pastri_params;
74
75//Block-specific stuff:
76typedef struct pastri_blockParams{
77  uint16_t nonZeros;
78  //int ECQ0s; //= p->bSize - numOutliers //OR: p->bSize=ECQ0s+ECQ1s+ECQOthers
79  int ECQ1s;
80  int ECQOthers;
81  int numOutliers; //=ECQ1s+ECQOthers
82  int patternBits;
83  int scaleBits;
84  double binSize;
85  double scalesBinSize;
86  uint64_t ECQExt;
87  int ECQBits;
88  int _1DIdxBits;
89}pastri_blockParams;
90
91typedef union u_UI64I64D{
92  uint64_t ui64;
93  int64_t i64;
94  double d;
95} u_UI64I64D;
96
97/********************************************************************/
98//Function Prototypes:
99/********************************************************************/
100void SZ_pastriReadParameters(char paramsFilename[512],pastri_params *paramsPtr);
101//Read the basic PaSTRI parameters from a file, speficied by paramsFilename.
102
103void SZ_pastriPreprocessParameters(pastri_params *p);
104//Using basic PaSTRI parameters, generate the others.
105//For example, block and sub-block sizes are generated by using basis function types.
106
107void SZ_pastriCompressBatch(pastri_params *p,unsigned char *originalBuf, unsigned char** compressedBufP,size_t *compressedBytes);
108//INPUTS: p, originalBuf
109//OUTPUTS: compressedBufP, compressedBytes
110//Using the inputs, compressedBufP is allocated and populated by the compressed data. Compressed size is written into compressedBytes.
111//Parameters are also stored at the beginning part of the compressedBuf
112
113void SZ_pastriDecompressBatch(unsigned char*compressedBuf, pastri_params *p, unsigned char** decompressedBufP ,size_t *decompressedBytes);
114//INPUTS: compressedBuf
115//OUTPUTS: p, decompressedBufP, decompressedBytes
116//First, parameters are read from compressedBuf and written into p.
117//Then, decompressedBufP is allocated and populated by the decompressed data. Decompressed size is written into decompressedBytes.
118
119void SZ_pastriCheckBatch(pastri_params *p,unsigned char*originalBuf,unsigned char*decompressedBuf); 
120//INPUTS: p, originalBuf, decompressedBuf
121//OUTPUTS: None (Just some on-screen messages)
122//Compares originalBuf with decompressedBuf. Checks whether the absolute error condition is satisfied or not.
123
124/********************************************************************/
125//Other Includes:
126/********************************************************************/
127
128
129
130#include "pastriGeneral.h"  //General tools
131#include "pastriD.h"  //Compression/Decompression for Double data
132#include "pastriF.h"  //Compression/Decompression for Float data
133
134
135#endif
136
137
138
139
140
Note: See TracBrowser for help on using the repository browser.