Skip to content

Commit

Permalink
bugfix 1. long->int64_t 2.uint->SZ::uint
Browse files Browse the repository at this point in the history
  • Loading branch information
ayzk committed Feb 24, 2022
1 parent f5fc429 commit 13b25a5
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 192 deletions.
4 changes: 2 additions & 2 deletions include/SZ3/api/impl/SZDispatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <cmath>


template<class T, uint N>
template<class T, SZ::uint N>
char *SZ_compress_dispatcher(SZ::Config &conf, T *data, size_t &outSize) {

assert(N == conf.N);
Expand All @@ -27,7 +27,7 @@ char *SZ_compress_dispatcher(SZ::Config &conf, T *data, size_t &outSize) {
}


template<class T, uint N>
template<class T, SZ::uint N>
void SZ_decompress_dispatcher(SZ::Config &conf, char *cmpData, size_t cmpSize, T *decData) {
if (conf.cmprAlgo == SZ::ALGO_LORENZO_REG) {
SZ_decompress_LorenzoReg<T, N>(conf, cmpData, cmpSize, decData);
Expand Down
4 changes: 2 additions & 2 deletions include/SZ3/api/impl/SZImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "SZ3/api/impl/SZImplOMP.hpp"
#include <cmath>

template<class T, uint N>
template<class T, SZ::uint N>
char *SZ_compress_impl(SZ::Config &conf, T *data, size_t &outSize) {
#ifndef _OPENMP
conf.openmp=false;
Expand All @@ -19,7 +19,7 @@ char *SZ_compress_impl(SZ::Config &conf, T *data, size_t &outSize) {
}


template<class T, uint N>
template<class T, SZ::uint N>
void SZ_decompress_impl(SZ::Config &conf, char *cmpData, size_t cmpSize, T *decData) {
#ifndef _OPENMP
conf.openmp=false;
Expand Down
4 changes: 2 additions & 2 deletions include/SZ3/api/impl/SZImplOMP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "omp.h"

template<class T, uint N>
template<class T, SZ::uint N>
char *SZ_compress_OMP(SZ::Config &conf, T *data, size_t &outSize) {
#ifdef _OPENMP

Expand Down Expand Up @@ -101,7 +101,7 @@ char *SZ_compress_OMP(SZ::Config &conf, T *data, size_t &outSize) {
}


template<class T, uint N>
template<class T, SZ::uint N>
void SZ_decompress_OMP(const SZ::Config &conf, char *cmpData, size_t cmpSize, T *decData) {
#ifdef _OPENMP

Expand Down
8 changes: 4 additions & 4 deletions include/SZ3/api/impl/SZInterp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <memory>


template<class T, uint N>
template<class T, SZ::uint N>
char *SZ_compress_Interp(SZ::Config &conf, T *data, size_t &outSize) {

// std::cout << "****************** Interp Compression ****************" << std::endl;
Expand All @@ -38,7 +38,7 @@ char *SZ_compress_Interp(SZ::Config &conf, T *data, size_t &outSize) {
}


template<class T, uint N>
template<class T, SZ::uint N>
void SZ_decompress_Interp(const SZ::Config &conf, char *cmpData, size_t cmpSize, T *decData) {
assert(conf.cmprAlgo == SZ::ALGO_INTERP);
SZ::uchar const *cmpDataPos = (SZ::uchar *) cmpData;
Expand All @@ -50,7 +50,7 @@ void SZ_decompress_Interp(const SZ::Config &conf, char *cmpData, size_t cmpSize,
}


template<class T, uint N>
template<class T, SZ::uint N>
double do_not_use_this_interp_compress_block_test(T *data, std::vector<size_t> dims, size_t num,
double eb, int interp_op, int direction_op, int block_size) {

Expand All @@ -73,7 +73,7 @@ double do_not_use_this_interp_compress_block_test(T *data, std::vector<size_t> d
return compression_ratio;
}

template<class T, uint N>
template<class T, SZ::uint N>
char *SZ_compress_Interp_lorenzo(SZ::Config &conf, T *data, size_t &outSize) {
assert(conf.cmprAlgo == SZ::ALGO_INTERP_LORENZO);

Expand Down
7 changes: 4 additions & 3 deletions include/SZ3/api/impl/SZLorenzoReg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
#include "SZ3/utils/Extraction.hpp"
#include "SZ3/utils/QuantOptimizatioin.hpp"
#include "SZ3/utils/Config.hpp"
#include "SZ3/def.hpp"
#include <cmath>
#include <memory>


template<class T, uint N, class Quantizer, class Encoder, class Lossless>
template<class T, SZ::uint N, class Quantizer, class Encoder, class Lossless>
std::shared_ptr<SZ::concepts::CompressorInterface<T>>
make_lorenzo_regression_compressor(const SZ::Config &conf, Quantizer quantizer, Encoder encoder, Lossless lossless) {
std::vector<std::shared_ptr<SZ::concepts::PredictorInterface<T, N>>> predictors;
Expand Down Expand Up @@ -73,7 +74,7 @@ make_lorenzo_regression_compressor(const SZ::Config &conf, Quantizer quantizer,
}


template<class T, uint N>
template<class T, SZ::uint N>
char *SZ_compress_LorenzoReg(SZ::Config &conf, T *data, size_t &outSize) {

assert(N == conf.N);
Expand All @@ -95,7 +96,7 @@ char *SZ_compress_LorenzoReg(SZ::Config &conf, T *data, size_t &outSize) {
}


template<class T, uint N>
template<class T, SZ::uint N>
void SZ_decompress_LorenzoReg(const SZ::Config &conf, char *cmpData, size_t cmpSize, T *decData) {
assert(conf.cmprAlgo == SZ::ALGO_LORENZO_REG);

Expand Down
18 changes: 9 additions & 9 deletions include/SZ3/encoder/HuffmanEncoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ namespace SZ {
//save the huffman Tree in the compressed data
uint save(uchar *&c) {
write(offset, c);
intToBytes_bigEndian(c, nodeCount);
int32ToBytes_bigEndian(c, nodeCount);
c += sizeof(int);
intToBytes_bigEndian(c, huffmanTree->stateNum / 2);
int32ToBytes_bigEndian(c, huffmanTree->stateNum / 2);
c += sizeof(int);
uint totalSize = 0;// = convert_HuffTree_to_bytes_anyStates(nodeCount, c);
// std::cout << "nodeCount = " << nodeCount << std::endl;
Expand Down Expand Up @@ -150,13 +150,13 @@ namespace SZ {
1; //it's equal to the number of bytes involved (for *outSize)
byteSizep = bitSize / 8; //it's used to move the pointer p for next data
if (byteSize <= 8) {
longToBytes_bigEndian(p, (huffmanTree->code[state])[0]);
int64ToBytes_bigEndian(p, (huffmanTree->code[state])[0]);
p += byteSizep;
} else //byteSize>8
{
longToBytes_bigEndian(p, (huffmanTree->code[state])[0]);
int64ToBytes_bigEndian(p, (huffmanTree->code[state])[0]);
p += 8;
longToBytes_bigEndian(p, (huffmanTree->code[state])[1]);
int64ToBytes_bigEndian(p, (huffmanTree->code[state])[1]);
p += (byteSizep - 8);
}
outSize += byteSize;
Expand All @@ -166,7 +166,7 @@ namespace SZ {
if (lackBits < bitSize) {
p++;
long newCode = (huffmanTree->code[state])[0] << lackBits;
longToBytes_bigEndian(p, newCode);
int64ToBytes_bigEndian(p, newCode);

if (bitSize <= 64) {
bitSize -= lackBits;
Expand All @@ -186,7 +186,7 @@ namespace SZ {
*p = (*p) | (unsigned char) ((huffmanTree->code[state])[0] >> (64 - lackBits));
p++;
newCode = (huffmanTree->code[state])[1] << lackBits;
longToBytes_bigEndian(p, newCode);
int64ToBytes_bigEndian(p, newCode);
bitSize -= lackBits;
byteSize = bitSize % 8 == 0 ? bitSize / 8 : bitSize / 8 + 1;
byteSizep = bitSize / 8;
Expand Down Expand Up @@ -261,8 +261,8 @@ namespace SZ {
//load Huffman tree
void load(const uchar *&c, size_t &remaining_length) {
read(offset, c, remaining_length);
nodeCount = bytesToInt_bigEndian(c);
int stateNum = bytesToInt_bigEndian(c + sizeof(int)) * 2;
nodeCount = bytesToInt32_bigEndian(c);
int stateNum = bytesToInt32_bigEndian(c + sizeof(int)) * 2;
size_t encodeStartIndex;
if (nodeCount <= 256)
encodeStartIndex = 1 + 3 * nodeCount * sizeof(unsigned char) + nodeCount * sizeof(T);
Expand Down
Loading

0 comments on commit 13b25a5

Please sign in to comment.