Skip to content

Commit

Permalink
add ALWAYS_INLINE
Browse files Browse the repository at this point in the history
  • Loading branch information
ayzk committed Dec 11, 2024
1 parent f125844 commit db63591
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions include/SZ3/def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ typedef unsigned char uchar;
"The buffer for compressed data is not large enough."
} // namespace SZ3

#ifdef _MSC_VER
#define ALWAYS_INLINE __forceinline
#else
#define ALWAYS_INLINE __attribute__((always_inline))
#endif

#endif
10 changes: 5 additions & 5 deletions include/SZ3/quantizer/LinearQuantizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LinearQuantizer : public concepts::QuantizerInterface<T, int> {

// quantize the data with a prediction value, and returns the quantization index and the decompressed data
// int quantize(T data, T pred, T& dec_data);
int quantize_and_overwrite(T &data, T pred) override {
int quantize_and_overwrite(T &data, T pred) override ALWAYS_INLINE {
T diff = data - pred;
auto quant_index = static_cast<int64_t>(fabs(diff) * this->error_bound_reciprocal) + 1;
if (quant_index < this->radius * 2) {
Expand Down Expand Up @@ -66,7 +66,7 @@ class LinearQuantizer : public concepts::QuantizerInterface<T, int> {
* @param dest
* @return
*/
int quantize_and_overwrite(T ori, T pred, T &dest) {
int quantize_and_overwrite(T ori, T pred, T &dest) ALWAYS_INLINE {
T diff = ori - pred;
auto quant_index = static_cast<int64_t>(fabs(diff) * this->error_bound_reciprocal) + 1;
if (quant_index < this->radius * 2) {
Expand Down Expand Up @@ -97,17 +97,17 @@ class LinearQuantizer : public concepts::QuantizerInterface<T, int> {
}

// recover the data using the quantization index
T recover(T pred, int quant_index) override {
T recover(T pred, int quant_index) override ALWAYS_INLINE {
if (quant_index) {
return recover_pred(pred, quant_index);
} else {
return recover_unpred();
}
}

T recover_pred(T pred, int quant_index) { return pred + 2 * (quant_index - this->radius) * this->error_bound; }
T recover_pred(T pred, int quant_index) ALWAYS_INLINE { return pred + 2 * (quant_index - this->radius) * this->error_bound; }

T recover_unpred() { return unpred[index++]; }
T recover_unpred() ALWAYS_INLINE { return unpred[index++]; }

size_t size_est() { return unpred.size() * sizeof(T); }

Expand Down

0 comments on commit db63591

Please sign in to comment.