-
Notifications
You must be signed in to change notification settings - Fork 0
/
zfp.h
795 lines (670 loc) · 34.2 KB
/
zfp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
/*
** Copyright (c) 2014-2023, Lawrence Livermore National Security, LLC and
** other zfp project contributors. See the top-level LICENSE file for details.
** SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef ZFP_H
#define ZFP_H
#include "zfp/bitstream.h"
#include "zfp/version.h"
#include "zfp/internal/zfp/system.h"
#include "zfp/internal/zfp/types.h"
/* macros ------------------------------------------------------------------ */
/* default compression parameters */
#define ZFP_MIN_BITS 1 /* minimum number of bits per block */
#define ZFP_MAX_BITS 16658 /* maximum number of bits per block */
#define ZFP_MAX_PREC 64 /* maximum precision supported */
#define ZFP_MIN_EXP -1074 /* minimum floating-point base-2 exponent */
/* header masks (enable via bitwise or; reader must use same mask) */
#define ZFP_HEADER_NONE 0x0u /* no header */
#define ZFP_HEADER_MAGIC 0x1u /* embed 64-bit magic */
#define ZFP_HEADER_META 0x2u /* embed 52-bit field metadata */
#define ZFP_HEADER_MODE 0x4u /* embed 12- or 64-bit compression mode */
#define ZFP_HEADER_FULL 0x7u /* embed all of the above */
/* bit masks for specifying storage class */
#define ZFP_DATA_UNUSED 0x01u /* allocated but unused storage */
#define ZFP_DATA_PADDING 0x02u /* padding for alignment purposes */
#define ZFP_DATA_META 0x04u /* class members and other fixed-size storage */
#define ZFP_DATA_MISC 0x08u /* miscellaneous uncategorized storage */
#define ZFP_DATA_PAYLOAD 0x10u /* compressed data */
#define ZFP_DATA_INDEX 0x20u /* variable-rate block index information */
#define ZFP_DATA_CACHE 0x40u /* uncompressed cached data */
#define ZFP_DATA_HEADER 0x80u /* header information */
#define ZFP_DATA_ALL 0xffu /* all storage */
/* field metadata indeterminate state and error code */
#define ZFP_META_NULL (UINT64C(-1))
/* number of bits per header entry */
#define ZFP_MAGIC_BITS 32 /* number of magic word bits */
#define ZFP_META_BITS 52 /* number of field metadata bits */
#define ZFP_MODE_SHORT_BITS 12 /* number of mode bits in short format */
#define ZFP_MODE_LONG_BITS 64 /* number of mode bits in long format */
#define ZFP_HEADER_MAX_BITS 148 /* max number of header bits */
#define ZFP_MODE_SHORT_MAX ((1u << ZFP_MODE_SHORT_BITS) - 2)
/* rounding mode for reducing bias; see build option ZFP_ROUNDING_MODE */
#define ZFP_ROUND_FIRST (-1) /* round during compression */
#define ZFP_ROUND_NEVER 0 /* never round */
#define ZFP_ROUND_LAST 1 /* round during decompression */
/* types ------------------------------------------------------------------- */
/* Boolean constants */
enum {
zfp_false = 0, /* false */
zfp_true = !zfp_false /* true */
};
typedef int zfp_bool; /* Boolean type */
/* execution policy */
typedef enum {
zfp_exec_serial = 0, /* serial execution (default) */
zfp_exec_omp = 1, /* OpenMP multi-threaded execution */
zfp_exec_cuda = 2 /* CUDA parallel execution */
} zfp_exec_policy;
/* OpenMP execution parameters */
typedef struct {
uint threads; /* number of requested threads */
uint chunk_size; /* number of blocks per chunk (1D only) */
} zfp_exec_params_omp;
typedef struct {
zfp_exec_policy policy; /* execution policy (serial, omp, ...) */
void* params; /* execution parameters */
} zfp_execution;
/* compressed stream; use accessors to get/set members */
typedef struct {
uint minbits; /* minimum number of bits to store per block */
uint maxbits; /* maximum number of bits to store per block */
uint maxprec; /* maximum number of bit planes to store */
int minexp; /* minimum floating point bit plane number to store */
bitstream* stream; /* compressed bit stream */
zfp_execution exec; /* execution policy and parameters */
} zfp_stream;
/* compression mode */
typedef enum {
zfp_mode_null = 0, /* an invalid configuration of the 4 params */
zfp_mode_expert = 1, /* expert mode (4 params set manually) */
zfp_mode_fixed_rate = 2, /* fixed rate mode */
zfp_mode_fixed_precision = 3, /* fixed precision mode */
zfp_mode_fixed_accuracy = 4, /* fixed accuracy mode */
zfp_mode_reversible = 5 /* reversible (lossless) mode */
} zfp_mode;
/* compression mode and parameter settings */
typedef struct {
zfp_mode mode; /* compression mode */
union {
double rate; /* compressed bits/value (negative for word alignment) */
uint precision; /* uncompressed bits/value */
double tolerance; /* absolute error tolerance */
struct {
uint minbits; /* min number of compressed bits/block */
uint maxbits; /* max number of compressed bits/block */
uint maxprec; /* max number of uncompressed bits/value */
int minexp; /* min floating point bit plane number to store */
} expert; /* expert mode arguments */
} arg; /* arguments corresponding to compression mode */
} zfp_config;
/* scalar type */
typedef enum {
zfp_type_none = 0, /* unspecified type */
zfp_type_int32 = 1, /* 32-bit signed integer */
zfp_type_int64 = 2, /* 64-bit signed integer */
zfp_type_float = 3, /* single precision floating point */
zfp_type_double = 4 /* double precision floating point */
} zfp_type;
/* uncompressed array; use accessors to get/set members */
typedef struct {
zfp_type type; /* scalar type (e.g. int32, double) */
size_t nx, ny, nz, nw; /* sizes (zero for unused dimensions) */
ptrdiff_t sx, sy, sz, sw; /* strides (zero for contiguous array a[nw][nz][ny][nx]) */
void* data; /* pointer to array data */
} zfp_field;
#ifdef __cplusplus
extern "C" {
#endif
/* public data ------------------------------------------------------------- */
extern_ const uint zfp_codec_version; /* codec version ZFP_CODEC */
extern_ const uint zfp_library_version; /* library version ZFP_VERSION */
extern_ const char* const zfp_version_string; /* verbose version string */
/* high-level API: utility functions --------------------------------------- */
size_t /* byte size of scalar type */
zfp_type_size(
zfp_type type /* scalar type */
);
/* high-level API: compressed stream construction/destruction -------------- */
/* open compressed stream and associate with bit stream */
zfp_stream* /* allocated compressed stream */
zfp_stream_open(
bitstream* stream /* bit stream to read from and write to (may be NULL) */
);
/* close and deallocate compressed stream (does not affect bit stream) */
void
zfp_stream_close(
zfp_stream* stream /* compressed stream */
);
/* high-level API: compressed stream inspectors ---------------------------- */
/* bit stream associated with compressed stream */
bitstream* /* bit stream associated with compressed stream */
zfp_stream_bit_stream(
const zfp_stream* stream /* compressed stream */
);
/* enumerated compression mode */
zfp_mode /* compression mode or zfp_mode_null if not set */
zfp_stream_compression_mode(
const zfp_stream* stream /* compressed stream */
);
/* rate in compressed bits/scalar (when in fixed-rate mode) */
double /* rate or zero upon failure */
zfp_stream_rate(
const zfp_stream* stream, /* compressed stream */
uint dims /* array dimensionality (1, 2, 3, or 4) */
);
/* precision in uncompressed bits/scalar (when in fixed-precision mode) */
uint /* precision or zero upon failure */
zfp_stream_precision(
const zfp_stream* stream /* compressed stream */
);
/* accuracy as absolute error tolerance (when in fixed-accuracy mode) */
double /* tolerance or zero upon failure */
zfp_stream_accuracy(
const zfp_stream* stream /* compressed stream */
);
/* get all compression parameters in a compact representation */
uint64 /* 12- or 64-bit encoding of parameters */
zfp_stream_mode(
const zfp_stream* stream /* compressed stream */
);
/* get all compression parameters (pointers may be NULL) */
void
zfp_stream_params(
const zfp_stream* stream, /* compressed stream */
uint* minbits, /* minimum number of bits per 4^d block */
uint* maxbits, /* maximum number of bits per 4^d block */
uint* maxprec, /* maximum precision (# bit planes coded) */
int* minexp /* minimum base-2 exponent; error <= 2^minexp */
);
/* byte size of sequentially compressed stream (call after compression) */
size_t /* actual number of bytes of compressed storage */
zfp_stream_compressed_size(
const zfp_stream* stream /* compressed stream */
);
/* conservative estimate of compressed size in bytes */
size_t /* maximum number of bytes of compressed storage */
zfp_stream_maximum_size(
const zfp_stream* stream, /* compressed stream */
const zfp_field* field /* array to compress */
);
/* high-level API: initialization of compressed stream parameters ---------- */
/* rewind bit stream to beginning for compression or decompression */
void
zfp_stream_rewind(
zfp_stream* stream /* compressed bit stream */
);
/* associate bit stream with compressed stream */
void
zfp_stream_set_bit_stream(
zfp_stream* stream, /* compressed stream */
bitstream* bs /* bit stream to read from and write to */
);
/* enable reversible (lossless) compression */
void
zfp_stream_set_reversible(
zfp_stream* stream /* compressed stream */
);
/* set size in compressed bits/scalar (fixed-rate mode) */
double /* actual rate in compressed bits/scalar */
zfp_stream_set_rate(
zfp_stream* stream, /* compressed stream */
double rate, /* desired rate in compressed bits/scalar */
zfp_type type, /* scalar type to compress */
uint dims, /* array dimensionality (1, 2, 3, or 4) */
zfp_bool align /* word-aligned blocks, e.g., for write random access */
);
/* set precision in uncompressed bits/scalar (fixed-precision mode) */
uint /* actual precision */
zfp_stream_set_precision(
zfp_stream* stream, /* compressed stream */
uint precision /* desired precision in uncompressed bits/scalar */
);
/* set accuracy as absolute error tolerance (fixed-accuracy mode) */
double /* actual error tolerance */
zfp_stream_set_accuracy(
zfp_stream* stream, /* compressed stream */
double tolerance /* desired error tolerance */
);
/* set parameters from compact encoding; leaves stream intact on failure */
zfp_mode /* compression mode or zfp_mode_null upon failure */
zfp_stream_set_mode(
zfp_stream* stream, /* compressed stream */
uint64 mode /* 12- or 64-bit encoding of parameters */
);
/* set all parameters (expert mode); leaves stream intact on failure */
zfp_bool /* true upon success */
zfp_stream_set_params(
zfp_stream* stream, /* compressed stream */
uint minbits, /* minimum number of bits per 4^d block */
uint maxbits, /* maximum number of bits per 4^d block */
uint maxprec, /* maximum precision (# bit planes coded) */
int minexp /* minimum base-2 exponent; error <= 2^minexp */
);
/* high-level API: execution policy ---------------------------------------- */
/* current execution policy */
zfp_exec_policy
zfp_stream_execution(
const zfp_stream* stream /* compressed stream */
);
/* number of OpenMP threads to use */
uint /* number of threads (0 for default) */
zfp_stream_omp_threads(
const zfp_stream* stream /* compressed stream */
);
/* number of blocks per OpenMP chunk (1D only) */
uint /* number of blocks per chunk (0 for default) */
zfp_stream_omp_chunk_size(
const zfp_stream* stream /* compressed stream */
);
/* set execution policy */
zfp_bool /* true upon success */
zfp_stream_set_execution(
zfp_stream* stream, /* compressed stream */
zfp_exec_policy policy /* execution policy */
);
/* set OpenMP execution policy and number of threads */
zfp_bool /* true upon success */
zfp_stream_set_omp_threads(
zfp_stream* stream, /* compressed stream */
uint threads /* number of OpenMP threads to use (0 for default) */
);
/* set OpenMP execution policy and number of blocks per chunk (1D only) */
zfp_bool /* true upon success */
zfp_stream_set_omp_chunk_size(
zfp_stream* stream, /* compressed stream */
uint chunk_size /* number of blocks per chunk (0 for default) */
);
/* high-level API: compression mode and parameter settings ----------------- */
/* unspecified configuration */
zfp_config /* compression mode and parameter settings */
zfp_config_none(void);
/* fixed-rate configuration */
zfp_config /* compression mode and parameter settings */
zfp_config_rate(
double rate, /* desired rate in compressed bits/scalar */
zfp_bool align /* word-aligned blocks, e.g., for write random access */
);
/* fixed-precision configuration */
zfp_config /* compression mode and parameter settings */
zfp_config_precision(
uint precision /* desired precision in uncompressed bits/scalar */
);
/* fixed-accuracy configuration */
zfp_config /* compression mode and parameter settings */
zfp_config_accuracy(
double tolerance /* desired error tolerance */
);
/* reversible (lossless) configuration */
zfp_config /* compression mode and parameter settings */
zfp_config_reversible(void);
/* expert configuration */
zfp_config /* compression mode and parameter settings */
zfp_config_expert(
uint minbits, /* minimum number of bits per 4^d block */
uint maxbits, /* maximum number of bits per 4^d block */
uint maxprec, /* maximum precision (# bit planes coded) */
int minexp /* minimum base-2 exponent; error <= 2^minexp */
);
/* high-level API: uncompressed array construction/destruction ------------- */
/* allocate field struct */
zfp_field* /* pointer to default initialized field */
zfp_field_alloc(void);
/* allocate metadata for 1D field f[nx] */
zfp_field* /* allocated field metadata */
zfp_field_1d(
void* pointer, /* pointer to uncompressed scalars (may be NULL) */
zfp_type type, /* scalar type */
size_t nx /* number of scalars */
);
/* allocate metadata for 2D field f[ny][nx] */
zfp_field* /* allocated field metadata */
zfp_field_2d(
void* pointer, /* pointer to uncompressed scalars (may be NULL) */
zfp_type type, /* scalar type */
size_t nx, /* number of scalars in x dimension */
size_t ny /* number of scalars in y dimension */
);
/* allocate metadata for 3D field f[nz][ny][nx] */
zfp_field* /* allocated field metadata */
zfp_field_3d(
void* pointer, /* pointer to uncompressed scalars (may be NULL) */
zfp_type type, /* scalar type */
size_t nx, /* number of scalars in x dimension */
size_t ny, /* number of scalars in y dimension */
size_t nz /* number of scalars in z dimension */
);
/* allocate metadata for 4D field f[nw][nz][ny][nx] */
zfp_field* /* allocated field metadata */
zfp_field_4d(
void* pointer, /* pointer to uncompressed scalars (may be NULL) */
zfp_type type, /* scalar type */
size_t nx, /* number of scalars in x dimension */
size_t ny, /* number of scalars in y dimension */
size_t nz, /* number of scalars in z dimension */
size_t nw /* number of scalars in w dimension */
);
/* deallocate field metadata */
void
zfp_field_free(
zfp_field* field /* field metadata */
);
/* high-level API: uncompressed array inspectors --------------------------- */
/* pointer to first scalar in field */
void* /* array pointer */
zfp_field_pointer(
const zfp_field* field /* field metadata */
);
/* pointer to lowest memory address spanned by field */
void*
zfp_field_begin(
const zfp_field* field /* field metadata */
);
/* field scalar type */
zfp_type /* scalar type */
zfp_field_type(
const zfp_field* field /* field metadata */
);
/* precision of field scalar type */
uint /* scalar type precision in number of bits */
zfp_field_precision(
const zfp_field* field /* field metadata */
);
/* field dimensionality (1, 2, 3, or 4) */
uint /* number of dimensions */
zfp_field_dimensionality(
const zfp_field* field /* field metadata */
);
/* field size in number of scalars */
size_t /* total number of scalars */
zfp_field_size(
const zfp_field* field, /* field metadata */
size_t* size /* number of scalars per dimension (may be NULL) */
);
/* number of bytes spanned by field data including gaps (if any) */
size_t
zfp_field_size_bytes(
const zfp_field* field /* field metadata */
);
/* field size in number of blocks */
size_t /* total number of blocks */
zfp_field_blocks(
const zfp_field* field /* field metadata */
);
/* field strides per dimension */
zfp_bool /* true if array is not contiguous */
zfp_field_stride(
const zfp_field* field, /* field metadata */
ptrdiff_t* stride /* stride in scalars per dimension (may be NULL) */
);
/* field contiguity test */
zfp_bool /* true if field layout is contiguous */
zfp_field_is_contiguous(
const zfp_field* field /* field metadata */
);
/* field scalar type and dimensions */
uint64 /* compact 52-bit encoding of metadata */
zfp_field_metadata(
const zfp_field* field /* field metadata */
);
/* high-level API: uncompressed array specification ------------------------ */
/* set pointer to first scalar in field */
void
zfp_field_set_pointer(
zfp_field* field, /* field metadata */
void* pointer /* pointer to first scalar */
);
/* set field scalar type */
zfp_type /* actual scalar type */
zfp_field_set_type(
zfp_field* field, /* field metadata */
zfp_type type /* desired scalar type */
);
/* set 1D field size */
void
zfp_field_set_size_1d(
zfp_field* field, /* field metadata */
size_t nx /* number of scalars */
);
/* set 2D field size */
void
zfp_field_set_size_2d(
zfp_field* field, /* field metadata */
size_t nx, /* number of scalars in x dimension */
size_t ny /* number of scalars in y dimension */
);
/* set 3D field size */
void
zfp_field_set_size_3d(
zfp_field* field, /* field metadata */
size_t nx, /* number of scalars in x dimension */
size_t ny, /* number of scalars in y dimension */
size_t nz /* number of scalars in z dimension */
);
/* set 4D field size */
void
zfp_field_set_size_4d(
zfp_field* field, /* field metadata */
size_t nx, /* number of scalars in x dimension */
size_t ny, /* number of scalars in y dimension */
size_t nz, /* number of scalars in z dimension */
size_t nw /* number of scalars in w dimension */
);
/* set 1D field stride in number of scalars */
void
zfp_field_set_stride_1d(
zfp_field* field, /* field metadata */
ptrdiff_t sx /* stride in number of scalars: &f[1] - &f[0] */
);
/* set 2D field strides in number of scalars */
void
zfp_field_set_stride_2d(
zfp_field* field, /* field metadata */
ptrdiff_t sx, /* stride in x dimension: &f[0][1] - &f[0][0] */
ptrdiff_t sy /* stride in y dimension: &f[1][0] - &f[0][0] */
);
/* set 3D field strides in number of scalars */
void
zfp_field_set_stride_3d(
zfp_field* field, /* field metadata */
ptrdiff_t sx, /* stride in x dimension: &f[0][0][1] - &f[0][0][0] */
ptrdiff_t sy, /* stride in y dimension: &f[0][1][0] - &f[0][0][0] */
ptrdiff_t sz /* stride in z dimension: &f[1][0][0] - &f[0][0][0] */
);
/* set 4D field strides in number of scalars */
void
zfp_field_set_stride_4d(
zfp_field* field, /* field metadata */
ptrdiff_t sx, /* stride in x dimension: &f[0][0][0][1] - &f[0][0][0][0] */
ptrdiff_t sy, /* stride in y dimension: &f[0][0][1][0] - &f[0][0][0][0] */
ptrdiff_t sz, /* stride in z dimension: &f[0][1][0][0] - &f[0][0][0][0] */
ptrdiff_t sw /* stride in w dimension: &f[1][0][0][0] - &f[0][0][0][0] */
);
/* set field scalar type and dimensions */
zfp_bool /* true upon success */
zfp_field_set_metadata(
zfp_field* field, /* field metadata */
uint64 meta /* compact 52-bit encoding of metadata */
);
/* high-level API: compression and decompression --------------------------- */
/* compress entire field (nonzero return value upon success) */
size_t /* cumulative number of bytes of compressed storage */
zfp_compress(
zfp_stream* stream, /* compressed stream */
const zfp_field* field /* field metadata */
);
/* decompress entire field (nonzero return value upon success) */
size_t /* cumulative number of bytes of compressed storage */
zfp_decompress(
zfp_stream* stream, /* compressed stream */
zfp_field* field /* field metadata */
);
/* write compression parameters and field metadata (optional) */
size_t /* number of bits written or zero upon failure */
zfp_write_header(
zfp_stream* stream, /* compressed stream */
const zfp_field* field, /* field metadata */
uint mask /* information to write */
);
/* read compression parameters and field metadata when previously written */
size_t /* number of bits read or zero upon failure */
zfp_read_header(
zfp_stream* stream, /* compressed stream */
zfp_field* field, /* field metadata */
uint mask /* information to read */
);
/* low-level API: stream manipulation -------------------------------------- */
/* flush bit stream--must be called after last encode call or between seeks */
size_t
zfp_stream_flush(
zfp_stream* stream /* compressed bit stream */
);
/* align bit stream on next word boundary (decoding analogy to flush) */
size_t
zfp_stream_align(
zfp_stream* stream /* compressed bit stream */
);
/* low-level API: encoder -------------------------------------------------- */
/*
The functions below all compress either a complete contiguous d-dimensional
block of 4^d scalars or a complete or partial block assembled from a strided
array. In the latter case, p points to the first scalar; (nx, ny, nz) specify
the size of the block, with 1 <= nx, ny, nz <= 4; and (sx, sy, sz) specify the
strides, i.e. the number of scalars to advance to get to the next scalar along
each dimension. The functions return the number of bits of compressed storage
needed for the compressed block.
*/
/* encode 1D contiguous block of 4 values */
size_t zfp_encode_block_int32_1(zfp_stream* stream, const int32* block);
size_t zfp_encode_block_int64_1(zfp_stream* stream, const int64* block);
size_t zfp_encode_block_float_1(zfp_stream* stream, const float* block);
size_t zfp_encode_block_double_1(zfp_stream* stream, const double* block);
/* encode 1D complete or partial block from strided array */
size_t zfp_encode_block_strided_int32_1(zfp_stream* stream, const int32* p, ptrdiff_t sx);
size_t zfp_encode_block_strided_int64_1(zfp_stream* stream, const int64* p, ptrdiff_t sx);
size_t zfp_encode_block_strided_float_1(zfp_stream* stream, const float* p, ptrdiff_t sx);
size_t zfp_encode_block_strided_double_1(zfp_stream* stream, const double* p, ptrdiff_t sx);
size_t zfp_encode_partial_block_strided_int32_1(zfp_stream* stream, const int32* p, size_t nx, ptrdiff_t sx);
size_t zfp_encode_partial_block_strided_int64_1(zfp_stream* stream, const int64* p, size_t nx, ptrdiff_t sx);
size_t zfp_encode_partial_block_strided_float_1(zfp_stream* stream, const float* p, size_t nx, ptrdiff_t sx);
size_t zfp_encode_partial_block_strided_double_1(zfp_stream* stream, const double* p, size_t nx, ptrdiff_t sx);
/* encode 2D contiguous block of 4x4 values */
size_t zfp_encode_block_int32_2(zfp_stream* stream, const int32* block);
size_t zfp_encode_block_int64_2(zfp_stream* stream, const int64* block);
size_t zfp_encode_block_float_2(zfp_stream* stream, const float* block);
size_t zfp_encode_block_double_2(zfp_stream* stream, const double* block);
/* encode 2D complete or partial block from strided array */
size_t zfp_encode_partial_block_strided_int32_2(zfp_stream* stream, const int32* p, size_t nx, size_t ny, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_encode_partial_block_strided_int64_2(zfp_stream* stream, const int64* p, size_t nx, size_t ny, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_encode_partial_block_strided_float_2(zfp_stream* stream, const float* p, size_t nx, size_t ny, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_encode_partial_block_strided_double_2(zfp_stream* stream, const double* p, size_t nx, size_t ny, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_encode_block_strided_int32_2(zfp_stream* stream, const int32* p, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_encode_block_strided_int64_2(zfp_stream* stream, const int64* p, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_encode_block_strided_float_2(zfp_stream* stream, const float* p, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_encode_block_strided_double_2(zfp_stream* stream, const double* p, ptrdiff_t sx, ptrdiff_t sy);
/* encode 3D contiguous block of 4x4x4 values */
size_t zfp_encode_block_int32_3(zfp_stream* stream, const int32* block);
size_t zfp_encode_block_int64_3(zfp_stream* stream, const int64* block);
size_t zfp_encode_block_float_3(zfp_stream* stream, const float* block);
size_t zfp_encode_block_double_3(zfp_stream* stream, const double* block);
/* encode 3D complete or partial block from strided array */
size_t zfp_encode_block_strided_int32_3(zfp_stream* stream, const int32* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_encode_block_strided_int64_3(zfp_stream* stream, const int64* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_encode_block_strided_float_3(zfp_stream* stream, const float* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_encode_block_strided_double_3(zfp_stream* stream, const double* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_encode_partial_block_strided_int32_3(zfp_stream* stream, const int32* p, size_t nx, size_t ny, size_t nz, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_encode_partial_block_strided_int64_3(zfp_stream* stream, const int64* p, size_t nx, size_t ny, size_t nz, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_encode_partial_block_strided_float_3(zfp_stream* stream, const float* p, size_t nx, size_t ny, size_t nz, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_encode_partial_block_strided_double_3(zfp_stream* stream, const double* p, size_t nx, size_t ny, size_t nz, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
/* encode 4D contiguous block of 4x4x4x4 values */
size_t zfp_encode_block_int32_4(zfp_stream* stream, const int32* block);
size_t zfp_encode_block_int64_4(zfp_stream* stream, const int64* block);
size_t zfp_encode_block_float_4(zfp_stream* stream, const float* block);
size_t zfp_encode_block_double_4(zfp_stream* stream, const double* block);
/* encode 4D complete or partial block from strided array */
size_t zfp_encode_block_strided_int32_4(zfp_stream* stream, const int32* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_encode_block_strided_int64_4(zfp_stream* stream, const int64* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_encode_block_strided_float_4(zfp_stream* stream, const float* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_encode_block_strided_double_4(zfp_stream* stream, const double* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_encode_partial_block_strided_int32_4(zfp_stream* stream, const int32* p, size_t nx, size_t ny, size_t nz, size_t nw, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_encode_partial_block_strided_int64_4(zfp_stream* stream, const int64* p, size_t nx, size_t ny, size_t nz, size_t nw, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_encode_partial_block_strided_float_4(zfp_stream* stream, const float* p, size_t nx, size_t ny, size_t nz, size_t nw, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_encode_partial_block_strided_double_4(zfp_stream* stream, const double* p, size_t nx, size_t ny, size_t nz, size_t nw, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
/* low-level API: decoder -------------------------------------------------- */
/*
Each function below decompresses a single block and returns the number of bits
of compressed storage consumed. See corresponding encoder functions above for
further details.
*/
/* decode 1D contiguous block of 4 values */
size_t zfp_decode_block_int32_1(zfp_stream* stream, int32* block);
size_t zfp_decode_block_int64_1(zfp_stream* stream, int64* block);
size_t zfp_decode_block_float_1(zfp_stream* stream, float* block);
size_t zfp_decode_block_double_1(zfp_stream* stream, double* block);
/* decode 1D complete or partial block from strided array */
size_t zfp_decode_block_strided_int32_1(zfp_stream* stream, int32* p, ptrdiff_t sx);
size_t zfp_decode_block_strided_int64_1(zfp_stream* stream, int64* p, ptrdiff_t sx);
size_t zfp_decode_block_strided_float_1(zfp_stream* stream, float* p, ptrdiff_t sx);
size_t zfp_decode_block_strided_double_1(zfp_stream* stream, double* p, ptrdiff_t sx);
size_t zfp_decode_partial_block_strided_int32_1(zfp_stream* stream, int32* p, size_t nx, ptrdiff_t sx);
size_t zfp_decode_partial_block_strided_int64_1(zfp_stream* stream, int64* p, size_t nx, ptrdiff_t sx);
size_t zfp_decode_partial_block_strided_float_1(zfp_stream* stream, float* p, size_t nx, ptrdiff_t sx);
size_t zfp_decode_partial_block_strided_double_1(zfp_stream* stream, double* p, size_t nx, ptrdiff_t sx);
/* decode 2D contiguous block of 4x4 values */
size_t zfp_decode_block_int32_2(zfp_stream* stream, int32* block);
size_t zfp_decode_block_int64_2(zfp_stream* stream, int64* block);
size_t zfp_decode_block_float_2(zfp_stream* stream, float* block);
size_t zfp_decode_block_double_2(zfp_stream* stream, double* block);
/* decode 2D complete or partial block from strided array */
size_t zfp_decode_block_strided_int32_2(zfp_stream* stream, int32* p, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_decode_block_strided_int64_2(zfp_stream* stream, int64* p, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_decode_block_strided_float_2(zfp_stream* stream, float* p, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_decode_block_strided_double_2(zfp_stream* stream, double* p, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_decode_partial_block_strided_int32_2(zfp_stream* stream, int32* p, size_t nx, size_t ny, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_decode_partial_block_strided_int64_2(zfp_stream* stream, int64* p, size_t nx, size_t ny, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_decode_partial_block_strided_float_2(zfp_stream* stream, float* p, size_t nx, size_t ny, ptrdiff_t sx, ptrdiff_t sy);
size_t zfp_decode_partial_block_strided_double_2(zfp_stream* stream, double* p, size_t nx, size_t ny, ptrdiff_t sx, ptrdiff_t sy);
/* decode 3D contiguous block of 4x4x4 values */
size_t zfp_decode_block_int32_3(zfp_stream* stream, int32* block);
size_t zfp_decode_block_int64_3(zfp_stream* stream, int64* block);
size_t zfp_decode_block_float_3(zfp_stream* stream, float* block);
size_t zfp_decode_block_double_3(zfp_stream* stream, double* block);
/* decode 3D complete or partial block from strided array */
size_t zfp_decode_block_strided_int32_3(zfp_stream* stream, int32* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_decode_block_strided_int64_3(zfp_stream* stream, int64* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_decode_block_strided_float_3(zfp_stream* stream, float* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_decode_block_strided_double_3(zfp_stream* stream, double* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_decode_partial_block_strided_int32_3(zfp_stream* stream, int32* p, size_t nx, size_t ny, size_t nz, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_decode_partial_block_strided_int64_3(zfp_stream* stream, int64* p, size_t nx, size_t ny, size_t nz, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_decode_partial_block_strided_float_3(zfp_stream* stream, float* p, size_t nx, size_t ny, size_t nz, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
size_t zfp_decode_partial_block_strided_double_3(zfp_stream* stream, double* p, size_t nx, size_t ny, size_t nz, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz);
/* decode 4D contiguous block of 4x4x4x4 values */
size_t zfp_decode_block_int32_4(zfp_stream* stream, int32* block);
size_t zfp_decode_block_int64_4(zfp_stream* stream, int64* block);
size_t zfp_decode_block_float_4(zfp_stream* stream, float* block);
size_t zfp_decode_block_double_4(zfp_stream* stream, double* block);
/* decode 4D complete or partial block from strided array */
size_t zfp_decode_block_strided_int32_4(zfp_stream* stream, int32* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_decode_block_strided_int64_4(zfp_stream* stream, int64* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_decode_block_strided_float_4(zfp_stream* stream, float* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_decode_block_strided_double_4(zfp_stream* stream, double* p, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_decode_partial_block_strided_int32_4(zfp_stream* stream, int32* p, size_t nx, size_t ny, size_t nz, size_t nw, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_decode_partial_block_strided_int64_4(zfp_stream* stream, int64* p, size_t nx, size_t ny, size_t nz, size_t nw, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_decode_partial_block_strided_float_4(zfp_stream* stream, float* p, size_t nx, size_t ny, size_t nz, size_t nw, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
size_t zfp_decode_partial_block_strided_double_4(zfp_stream* stream, double* p, size_t nx, size_t ny, size_t nz, size_t nw, ptrdiff_t sx, ptrdiff_t sy, ptrdiff_t sz, ptrdiff_t sw);
/* low-level API: utility functions ---------------------------------------- */
/* convert dims-dimensional contiguous block to 32-bit integer type */
void zfp_promote_int8_to_int32(int32* oblock, const int8* iblock, uint dims);
void zfp_promote_uint8_to_int32(int32* oblock, const uint8* iblock, uint dims);
void zfp_promote_int16_to_int32(int32* oblock, const int16* iblock, uint dims);
void zfp_promote_uint16_to_int32(int32* oblock, const uint16* iblock, uint dims);
/* convert dims-dimensional contiguous block from 32-bit integer type */
void zfp_demote_int32_to_int8(int8* oblock, const int32* iblock, uint dims);
void zfp_demote_int32_to_uint8(uint8* oblock, const int32* iblock, uint dims);
void zfp_demote_int32_to_int16(int16* oblock, const int32* iblock, uint dims);
void zfp_demote_int32_to_uint16(uint16* oblock, const int32* iblock, uint dims);
#ifdef __cplusplus
}
#endif
#endif