diff options
author | Daniel Spangberg <daniels@kemi.uu.se> | 2013-05-16 15:22:04 (GMT) |
---|---|---|
committer | Daniel Spangberg <daniels@kemi.uu.se> | 2013-05-16 15:22:04 (GMT) |
commit | 6ae393dbe7ffda9c2340503c82d062cb8d7c6f41 (patch) | |
tree | c1c5fe83bba773ac457a991a4c4c12b8b95d58ae | |
parent | 3fed6f767da30a5436c3667576eb9e4f5fa24f6d (diff) |
Several changes to get the compression testsuite working for recompression tests.
-rw-r--r-- | src/tests/compression/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/tests/compression/test58.h | 2 | ||||
-rw-r--r-- | src/tests/compression/test59.h | 2 | ||||
-rw-r--r-- | src/tests/compression/test60.h | 28 | ||||
-rw-r--r-- | src/tests/compression/test61.h | 25 | ||||
-rw-r--r-- | src/tests/compression/test62.h | 26 | ||||
-rw-r--r-- | src/tests/compression/testsuite.c | 75 |
7 files changed, 157 insertions, 3 deletions
diff --git a/src/tests/compression/CMakeLists.txt b/src/tests/compression/CMakeLists.txt index 15b059b..39c2078 100644 --- a/src/tests/compression/CMakeLists.txt +++ b/src/tests/compression/CMakeLists.txt @@ -9,7 +9,7 @@ include_directories(${CMAKE_SOURCE_DIR}/include/compression) include_directories(${CMAKE_BINARY_DIR}/generated/) set(number 0) -set(numtests 59) +set(numtests 62) while( number LESS ${numtests}) diff --git a/src/tests/compression/test58.h b/src/tests/compression/test58.h index 18be47f..9988106 100644 --- a/src/tests/compression/test58.h +++ b/src/tests/compression/test58.h @@ -23,4 +23,4 @@ #define INTMAX3 10000 #define NFRAMES 1000 #define TEST_FLOAT -#define EXPECTED_FILESIZE 7237102. +#define EXPECTED_FILESIZE 6986313. diff --git a/src/tests/compression/test59.h b/src/tests/compression/test59.h index 0b6079e..9817976 100644 --- a/src/tests/compression/test59.h +++ b/src/tests/compression/test59.h @@ -25,4 +25,4 @@ #ifdef GEN #define TEST_FLOAT #endif -#define EXPECTED_FILESIZE 7237102. +#define EXPECTED_FILESIZE 6986313. diff --git a/src/tests/compression/test60.h b/src/tests/compression/test60.h new file mode 100644 index 0000000..cf94e3b --- /dev/null +++ b/src/tests/compression/test60.h @@ -0,0 +1,28 @@ +#define TESTNAME "Coding. Test write double, read float." +#define FILENAME "test60.tng_compress" +#define ALGOTEST +#define NATOMS 1000 +#define CHUNKY 100 +#define SCALE 0.1 +#define PRECISION 0.01 +#define WRITEVEL 1 +#define VELPRECISION 0.1 +#define INITIALCODING 5 +#define INITIALCODINGPARAMETER 0 +#define CODING 5 +#define CODINGPARAMETER 0 +#define INITIALVELCODING 3 +#define INITIALVELCODINGPARAMETER -1 +#define VELCODING 3 +#define VELCODINGPARAMETER -1 +#define INTMIN1 0 +#define INTMIN2 0 +#define INTMIN3 0 +#define INTMAX1 10000 +#define INTMAX2 10000 +#define INTMAX3 10000 +#define NFRAMES 1000 +#ifndef GEN +#define TEST_FLOAT +#endif +#define EXPECTED_FILESIZE 6986313. diff --git a/src/tests/compression/test61.h b/src/tests/compression/test61.h new file mode 100644 index 0000000..2b71cc8 --- /dev/null +++ b/src/tests/compression/test61.h @@ -0,0 +1,25 @@ +#define TESTNAME "Coding. Recompression test. Stage 1: Generate" +#define FILENAME "test61.tng_compress" +#define ALGOTEST +#define NATOMS 1000 +#define CHUNKY 100 +#define SCALE 0.1 +#define PRECISION 0.01 +#define WRITEVEL 1 +#define VELPRECISION 0.1 +#define INITIALCODING 5 +#define INITIALCODINGPARAMETER 0 +#define CODING 5 +#define CODINGPARAMETER 0 +#define INITIALVELCODING 3 +#define INITIALVELCODINGPARAMETER -1 +#define VELCODING 3 +#define VELCODINGPARAMETER -1 +#define INTMIN1 0 +#define INTMIN2 0 +#define INTMIN3 0 +#define INTMAX1 10000 +#define INTMAX2 10000 +#define INTMAX3 10000 +#define NFRAMES 1000 +#define EXPECTED_FILESIZE 6986313. diff --git a/src/tests/compression/test62.h b/src/tests/compression/test62.h new file mode 100644 index 0000000..4b9e122 --- /dev/null +++ b/src/tests/compression/test62.h @@ -0,0 +1,26 @@ +#define TESTNAME "Coding. Recompression test. Stage 2: Recompress" +#define FILENAME "test62.tng_compress" +#define RECOMPRESS "test61.tng_compress" +#define ALGOTEST +#define NATOMS 1000 +#define CHUNKY 100 +#define SCALE 0.01 /* Changed on purpose. */ +#define PRECISION 0.01 +#define WRITEVEL 1 +#define VELPRECISION 0.1 +#define INITIALCODING -1 +#define INITIALCODINGPARAMETER -1 +#define CODING -1 +#define CODINGPARAMETER -1 +#define INITIALVELCODING -1 +#define INITIALVELCODINGPARAMETER -1 +#define VELCODING -1 +#define VELCODINGPARAMETER -1 +#define INTMIN1 0 +#define INTMIN2 0 +#define INTMIN3 0 +#define INTMAX1 10000 +#define INTMAX2 10000 +#define INTMAX3 10000 +#define NFRAMES 1000 +#define EXPECTED_FILESIZE 6986313. diff --git a/src/tests/compression/testsuite.c b/src/tests/compression/testsuite.c index cc38cb6..e1b9710 100644 --- a/src/tests/compression/testsuite.c +++ b/src/tests/compression/testsuite.c @@ -284,6 +284,8 @@ struct tng_file int writevel; REAL *pos; REAL *vel; + int *ipos; + int *ivel; }; static size_t fwrite_int_le(int *x,FILE *f) @@ -328,6 +330,51 @@ static struct tng_file *open_tng_file_write(char *filename, struct tng_file *tng_file=malloc(sizeof *tng_file); tng_file->pos=NULL; tng_file->vel=NULL; + tng_file->ipos=NULL; + tng_file->ivel=NULL; + tng_file->nframes=0; + tng_file->chunky=chunky; + tng_file->precision=precision; + tng_file->natoms=natoms; + tng_file->writevel=writevel; + tng_file->velprecision=velprecision; + tng_file->initial_coding=initial_coding; + tng_file->initial_coding_parameter=initial_coding_parameter; + tng_file->coding=coding; + tng_file->coding_parameter=coding_parameter; + tng_file->initial_velcoding=initial_velcoding; + tng_file->initial_velcoding_parameter=initial_velcoding_parameter; + tng_file->velcoding=velcoding; + tng_file->velcoding_parameter=velcoding_parameter; + tng_file->speed=speed; + tng_file->pos=malloc(natoms*chunky*3*sizeof *tng_file->pos); + tng_file->f=fopen(filename,"wb"); + if (writevel) + tng_file->vel=malloc(natoms*chunky*3*sizeof *tng_file->vel); + fwrite_int_le(&natoms,tng_file->f); + return tng_file; +} + +static struct tng_file *open_tng_file_write_int(char *filename, + int natoms,int chunky, + unsigned long prec_hi, unsigned long prec_lo, + int writevel, + unsigned long velprec_hi, unsigned long velprec_lo, + int initial_coding, + int initial_coding_parameter, + int coding, + int coding_parameter, + int initial_velcoding, + int initial_velcoding_parameter, + int velcoding, + int velcoding_parameter, + int speed) +{ + struct tng_file *tng_file=malloc(sizeof *tng_file); + tng_file->pos=NULL; + tng_file->vel=NULL; + tng_file->ipos=NULL; + tng_file->ivel=NULL; tng_file->nframes=0; tng_file->chunky=chunky; tng_file->precision=precision; @@ -437,6 +484,8 @@ static struct tng_file *open_tng_file_read(char *filename, int writevel) struct tng_file *tng_file=malloc(sizeof *tng_file); tng_file->pos=NULL; tng_file->vel=NULL; + tng_file->ipos=NULL; + tng_file->ivel=NULL; tng_file->f=fopen(filename,"rb"); tng_file->nframes=0; tng_file->nframes_delivered=0; @@ -561,6 +610,10 @@ static int algotest() int i; int *intbox=malloc(NATOMS*3*sizeof *intbox); int *intvelbox=malloc(NATOMS*3*sizeof *intvelbox); +#ifdef RECOMPRESS + unsigned long pos_prec_hi,pos_prec_lo; + unsigned long vel_prec_hi,vel_prec_lo; +#endif REAL *box1=malloc(NATOMS*STRIDE1*sizeof *box1); REAL *velbox1=malloc(NATOMS*STRIDE1*sizeof *velbox1); REAL time1, lambda1; @@ -588,6 +641,11 @@ static int algotest() #else void *dumpfile=open_tng_file_read(TNG_COMPRESS_FILES_DIR FILENAME,WRITEVEL); #endif +#ifdef RECOMPRESS + void *dumpfile_recompress=open_tng_file_read_int(TNG_COMPRESS_FILES_DIR RECOMPRESS,WRITEVEL); + if (!dumpfile_recompress) + return 1; +#endif if (!dumpfile) return 1; for (i=0; i<9; i++) @@ -597,16 +655,30 @@ static int algotest() H1[8]=INTMAX3*PRECISION*SCALE; for (i=startframe; i<endframe; i++) { +#ifndef RECOMPRES genibox(intbox,i); realbox(intbox,box1,STRIDE1); #if WRITEVEL genivelbox(intvelbox,i); realvelbox(intvelbox,velbox1,STRIDE1); #endif +#else +#ifdef GEN + if (read_tng_file_int(dumpfile_recompress,intbox,intvelbox)) + return 1; +#else + if (read_tng_file(dumpfile_recompress,box1,velbox1)) + return 1; +#endif +#endif time1=(REAL)i; lambda1=(REAL)(i+100); #ifdef GEN +#ifdef RECOMPRESS + write_tng_file_int(dumpfile,intbox,intvelbox); +#else write_tng_file(dumpfile,box1,velbox1); +#endif #else readreturn=read_tng_file(dumpfile,box2,velbox2); if (readreturn==1) /* general read error */ @@ -627,6 +699,9 @@ static int algotest() #else close_tng_file_read(dumpfile); #endif +#ifdef RECOMPRESS + close_tng_file_read(dumpfile_recompress); +#endif #ifdef GEN /* Check against expected filesize for this test. */ if (!(file=fopen(TNG_COMPRESS_FILES_DIR FILENAME,"rb"))) |