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
|
#include "gtest/gtest.h"
#include "zfp.h"
#include "commonMacros.h"
extern "C" {
#include "utils/genSmoothRandNums.h"
}
#define SCALAR float
#define ZFP_TYPE zfp_type_float
const size_t MIN_TOTAL_ELEMENTS = 1000000;
size_t inputDataSideLen, inputDataTotalLen;
size_t dimLens[4];
float* inputDataArr;
uint64* buffer;
bitstream* bs;
zfp_stream* stream;
zfp_field* field;
class ArrayFloatTestEnv : public ::testing::Environment {
public:
virtual int getDims() = 0;
virtual void SetUp() {
generateSmoothRandFloats(MIN_TOTAL_ELEMENTS, getDims(), &inputDataArr, &inputDataSideLen, &inputDataTotalLen);
for (int i = 0; i < 4; i++) {
dimLens[i] = (i < getDims()) ? inputDataSideLen : 0;
}
size_t num_64bit_entries = DIV_ROUND_UP(ZFP_HEADER_SIZE_BITS, CHAR_BIT * sizeof(uint64));
buffer = new uint64[num_64bit_entries];
bs = stream_open(buffer, num_64bit_entries * sizeof(uint64));
stream = zfp_stream_open(bs);
field = zfp_field_alloc();
}
virtual void TearDown() {
free(inputDataArr);
zfp_field_free(field);
zfp_stream_close(stream);
stream_close(bs);
delete[] buffer;
}
};
|