Skip to content

Commit

Permalink
mergew with sz v3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ayzk committed Aug 27, 2024
1 parent dc2b5ea commit 751f41e
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 101 deletions.
59 changes: 59 additions & 0 deletions include/SZ3/api/impl/SZAlgoBioMD.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef SZ3_SZ_BIOMD_HPP
#define SZ3_SZ_BIOMD_HPP

#include "SZ3/quantizer/IntegerQuantizer.hpp"
#include "SZ3/decomposition/SZBioMDXtcDecomposition.hpp"
#include "SZ3/decomposition/SZBioMDDecomposition.hpp"
#include "SZ3/encoder/XtcBasedEncoder.hpp"
#include "SZ3/lossless/Lossless_zstd.hpp"
#include "SZ3/lossless/Lossless_bypass.hpp"
#include "SZ3/utils/Statistic.hpp"
#include "SZ3/utils/Config.hpp"
#include "SZ3/def.hpp"

namespace SZ3 {

template<class T, uint N>
size_t SZ_compress_bioMD(Config &conf, T *data, uchar *cmpData, size_t cmpCap) {
assert(N == conf.N);
assert(conf.cmprAlgo == ALGO_BIOMD);
calAbsErrorBound(conf, data);

auto quantizer = LinearQuantizer<T>(conf.absErrorBound, conf.quantbinCnt / 2);
auto sz = make_compressor_sz_generic<T, N>(make_decomposition_biomd<T, N>(conf, quantizer), HuffmanEncoder<int>(),
Lossless_zstd());
return sz->compress(conf, data, cmpData, cmpCap);
}

template<class T, uint N>
void SZ_decompress_bioMD(const Config &conf, const uchar *cmpData, size_t cmpSize, T *decData) {
assert(conf.cmprAlgo == ALGO_BIOMD);

LinearQuantizer<T> quantizer;
auto sz = make_compressor_sz_generic<T, N>(make_decomposition_biomd<T, N>(conf, quantizer),
HuffmanEncoder<int>(), Lossless_zstd());
sz->decompress(conf, cmpData, cmpSize, decData);
}

template<class T, uint N>
size_t SZ_compress_bioMDXtcBased(Config &conf, T *data, uchar *cmpData, size_t cmpCap) {
assert(N == conf.N);
assert(conf.cmprAlgo == ALGO_BIOMDXTC);
calAbsErrorBound(conf, data);

auto sz = make_compressor_sz_generic<T, N>(SZBioMDXtcDecomposition<T, N>(conf), XtcBasedEncoder<int>(),
Lossless_bypass());
return sz->compress(conf, data, cmpData, cmpCap);
}

template<class T, uint N>
void SZ_decompress_bioMDXtcBased(const Config &conf, const uchar *cmpData, size_t cmpSize, T *decData) {
assert(conf.cmprAlgo == ALGO_BIOMDXTC);

auto sz = make_compressor_sz_generic<T, N>(SZBioMDXtcDecomposition<T, N>(conf),
XtcBasedEncoder<int>(), Lossless_bypass());
sz->decompress(conf, cmpData, cmpSize, decData);
}

}
#endif
75 changes: 0 additions & 75 deletions include/SZ3/api/impl/SZBioMD.hpp

This file was deleted.

6 changes: 3 additions & 3 deletions include/SZ3/api/impl/SZDispatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "SZ3/api/impl/SZAlgoInterp.hpp"
#include "SZ3/api/impl/SZAlgoLorenzoReg.hpp"
#include "SZ3/api/impl/SZAlgo.hpp"
#include "SZ3/api/impl/SZBioMD.hpp"
#include "SZ3/api/impl/SZAlgoBioMD.hpp"
#include <cmath>

namespace SZ3 {
Expand All @@ -30,9 +30,9 @@ namespace SZ3 {
} else if (conf.cmprAlgo == ALGO_NOPRED) {
return SZ_compress_nopred<T, N>(conf, data, cmpData, cmpCap);
} else if (conf.cmprAlgo == ALGO_BIOMD) {
cmpData = (char *) SZ_compress_bioMD<T, N>(conf, data, outSize);
return SZ_compress_bioMD<T, N>(conf, data, cmpData, cmpCap);
} else if (conf.cmprAlgo == ALGO_BIOMDXTC) {
cmpData = (char *) SZ_compress_bioMDXtcBased<T, N>(conf, data, outSize);
return SZ_compress_bioMDXtcBased<T, N>(conf, data, cmpData, cmpCap);
}
return 0;
// return cmpData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
/**
*/

#include "Frontend.hpp"
#include "Decomposition.hpp"
//#include "SZ3/utils/MemoryUtil.hpp"
#include "SZ3/utils/Config.hpp"
#include <list>

namespace SZ3 {

template<class T, uint N, class Quantizer>
class SZBioMDFrontend : public concepts::FrontendInterface<T, N> {
class SZBioMDDecomposition : public concepts::DecompositionInterface<T, N> {
public:
SZBioMDFrontend(const Config &conf, Quantizer quantizer) :
SZBioMDDecomposition(const Config &conf, Quantizer quantizer) :
quantizer(quantizer),
conf(conf) {
if (N != 1 && N != 2 && N != 3) {
throw std::invalid_argument("SZBioFront only support 1D, 2D or 3D data");
}
}

~SZBioMDFrontend() {
clear();
~SZBioMDDecomposition() {
// clear();
}

void print() {};
std::vector<int> compress(T *data) {

std::vector<int> compress(const Config &conf, T *data) {
if (N == 1) {
return compress_1d(data);
} else if (N == 2) {
Expand All @@ -37,8 +37,8 @@ namespace SZ3 {
return compress_3d(data);
}
};
T *decompress(std::vector<int> &quant_inds, T *dec_data) {

T *decompress(const Config &conf, std::vector<int> &quant_inds, T *dec_data) {
if (N == 1) {
return decompress_1d(quant_inds, dec_data);
} else if (N == 2) {
Expand All @@ -56,7 +56,7 @@ namespace SZ3 {
}

void load(const uchar *&c, size_t &remaining_length) {
clear();
// clear();
const uchar *c_pos = c;
read(site, c, remaining_length);
read(firstFillFrame_, c, remaining_length);
Expand All @@ -65,9 +65,9 @@ namespace SZ3 {
remaining_length -= c_pos - c;
}

void clear() {
quantizer.clear();
}
// void clear() {
// quantizer.clear();
// }

size_t size_est() {
return quantizer.size_est(); //unpred
Expand Down Expand Up @@ -362,9 +362,9 @@ namespace SZ3 {
};

template<class T, uint N, class Predictor>
SZBioMDFrontend<T, N, Predictor>
make_sz_bio_frontend(const Config &conf, Predictor predictor) {
return SZBioMDFrontend<T, N, Predictor>(conf, predictor);
SZBioMDDecomposition<T, N, Predictor>
make_decomposition_biomd(const Config &conf, Predictor predictor) {
return SZBioMDDecomposition<T, N, Predictor>(conf, predictor);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
/*
* Based on SZBioMDFrontend.hpp
* Based on SZBioMDDecomposition.hpp
* \author: Magnus Lundborg
*/

#ifndef SZ3_SZBIOMDXTCBASED_FRONTEND
#define SZ3_SZBIOMDXTCBASED_FRONTEND

#include "Frontend.hpp"
#include "Decomposition.hpp"
#include "SZ3/utils/Config.hpp"

#include <list>

namespace SZ3 {

template<class T, uint N>
class SZBioMDXtcBasedFrontend : public concepts::FrontendInterface<T, N> {
class SZBioMDXtcDecomposition : public concepts::DecompositionInterface<T, N> {
public:
SZBioMDXtcBasedFrontend(const Config &conf) : conf(conf) {
SZBioMDXtcDecomposition(const Config &conf) : conf(conf) {
if (N != 1 && N != 2 && N != 3) {
throw std::invalid_argument("SZBioFront only support 1D, 2D or 3D data");
}
}

~SZBioMDXtcBasedFrontend() { clear(); }
// ~SZBioMDXtcDecomposition() { clear(); }

void print() {};

std::vector<int> compress(T *data) {
std::vector<int> compress(const Config &conf, T *data) {
if (N <= 2) {
return compressSingleFrame(data);
} else {
return compressMultiFrame(data);
}
};

T *decompress(std::vector<int> &quantData, T *decData) {
T *decompress(const Config &conf, std::vector<int> &quantData, T *decData) {
if (N <= 2) {
return decompressSingleFrame(quantData, decData);
} else {
Expand Down
1 change: 1 addition & 0 deletions include/SZ3/utils/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <cstdint>
#include "SZ3/utils/MemoryUtil.hpp"
#include "SZ3/utils/inih/INIReader.h"
#include "SZ3/version.hpp"

#define SZ_FLOAT 0
#define SZ_DOUBLE 1
Expand Down

0 comments on commit 751f41e

Please sign in to comment.