#include #include #include #include #include #define ABS 0 #define REL 1 #define NORM2 2 #define PSNR 3 #define LITTLE_ENDIAN_SYSTEM 0 #define BIG_ENDIAN_SYSTEM 1 #define LITTLE_ENDIAN_DATA 0 #define BIG_ENDIAN_DATA 1 int sysEndianType = LITTLE_ENDIAN_SYSTEM; int dataEndianType = LITTLE_ENDIAN_DATA; typedef union ldouble { double value; uint64_t lvalue; unsigned char byte[8]; } ldouble; ldouble buf; void usage() { printf("Usage: print_h5repack_args \n"); printf("Options:\n"); printf(" -M : 10 options as follows. \n"); printf(" ABS (absolute error bound)\n"); printf(" REL (value range based error bound, so a.k.a., VR_REL)\n"); printf(" PSNR (peak signal-to-noise ratio)\n"); printf(" NORM2 (norm2)\n"); printf(" -A : specifying absolute error bound\n"); printf(" -R : specifying relative error bound\n"); printf(" -N : specifying norm2 error bound\n"); printf(" -S : specifying PSNR\n"); printf("* examples: \n"); printf(" print_h5repack_args -M ABS -A 1E-3 (output: -f UD=32024,0,9,0,1062232653,3539053052,0,0,0,0,0,0)\n"); printf(" print_h5repack_args -M REL -R 1E-4 (output: -f UD=32024,0,9,1,0,0,1058682594,3944497965,0,0,0,0)\n"); exit(0); } int bytesToInt32_bigEndian(unsigned char* bytes) { int temp = 0; int res = 0; res <<= 8; temp = bytes[0] & 0xff; res |= temp; res <<= 8; temp = bytes[1] & 0xff; res |= temp; res <<= 8; temp = bytes[2] & 0xff; res |= temp; res <<= 8; temp = bytes[3] & 0xff; res |= temp; return res; } void symTransform_8bytes(unsigned char data[8]) { unsigned char tmp = data[0]; data[0] = data[7]; data[7] = tmp; tmp = data[1]; data[1] = data[6]; data[6] = tmp; tmp = data[2]; data[2] = data[5]; data[5] = tmp; tmp = data[3]; data[3] = data[4]; data[4] = tmp; } void doubleToBytes(unsigned char *b, double num) { ldouble buf; buf.value = num; memcpy(b, buf.byte, 8); if(sysEndianType==LITTLE_ENDIAN_SYSTEM) symTransform_8bytes(b); } int main(int argc, char* argv[]) { char* errBoundMode = NULL; char* absErrorBound = NULL; char* relErrorBound = NULL; char* norm2ErrorBound = NULL; char* psnr_ = NULL; if(argc==1) usage(); int i = 0; for(i=1;i