diff --git a/icapp.c b/icapp.c index 310ceaf..83a0ffb 100644 --- a/icapp.c +++ b/icapp.c @@ -20,9 +20,9 @@ - github : https://github.com/powturbo - homepage : https://sites.google.com/site/powturbo/ - twitter : https://twitter.com/powturbo - - TurboPFor - "Benchmark demo application" **/ +// TurboPFor - "IcApp: Benchmark application" + #include #include #include @@ -44,20 +44,96 @@ #define __off64_t _off64_t #endif #include // pow +#include #include "conf.h" #include "time_.h" -//--------------------------------------- Zipfian generator -------------------------------------------------------- -static double a = 1.5; -static unsigned xbits[65],verbose; -void stprint(char *s) { - int m; - uint64_t t=0; - for(m = 0; m <= 64; m++) - t += xbits[m]; - printf("\n%s bits histogram:",s); - for(m = 0; m <= 64; m++) - if(xbits[m]) printf("%d:%.2f%% ", m, (double)xbits[m]*100/t); printf("\n"); + +#ifndef min +#define min(x,y) (((x)<(y)) ? (x) : (y)) +#define max(x,y) (((x)>(y)) ? (x) : (y)) +#endif + +int verbose = 1; +//------------------------------ bits statistics -------------------------------------------------- +static unsigned xbits[65],tbits[65]; +void histl8( uint8_t *in, unsigned n) { unsigned i; for(i = 0; i < n; i++) xbits[bsr8( in[i])]++; } +void histl16(uint16_t *in, unsigned n) { unsigned i; for(i = 0; i < n; i++) xbits[bsr16(in[i])]++; } +void histl32(uint32_t *in, unsigned n) { unsigned i; for(i = 0; i < n; i++) xbits[bsr32(in[i])]++; } +void histl64(uint64_t *in, unsigned n) { unsigned i; for(i = 0; i < n; i++) xbits[bsr64(in[i])]++; } + +void histt8( uint8_t *in, unsigned n) { unsigned i; for(i = 0; i < n; i++) tbits[in[i]?ctz8( in[i]): 8]++; } +void histt16(uint16_t *in, unsigned n) { unsigned i; for(i = 0; i < n; i++) tbits[in[i]?ctz16(in[i]):16]++; } +void histt32(uint32_t *in, unsigned n) { unsigned i; for(i = 0; i < n; i++) tbits[in[i]?ctz32(in[i]):32]++; } +void histt64(uint64_t *in, unsigned n) { unsigned i; for(i = 0; i < n; i++) tbits[in[i]?ctz64(in[i]):64]++; } + +//----------------------------- Convert iso-8601 and similar formats to timestamp ------------------------- +// Date separator : '.'. '/' or '-' +// Hour separator : ':' +// Fraction sep.: '.' or ',' +// examples: "2020" "20211203" "20211022 11:09:45.1234", +uint64_t strtots(char *p, char **pq, int type) { // string to timestamp + struct tm tm; + uint64_t u; + char *s=p; + int frac = 0,c; + + memset(&tm, 0, sizeof(tm)); tm.tm_mday = 1; + while(!isdigit(*p)) p++; + u = strtoull(p, &p, 10); // first number + + if( u <= 99) u += 2000; // year "yy": 00-99 -> 2000-2099 + else if(u >= 19710101 && u < 20381212) { // date: "yyyymmdd" + tm.tm_year = u/10000; + tm.tm_mon = (u%10000)/100; if(!tm.tm_mon || tm.tm_mon > 12) goto a; tm.tm_mon--; + tm.tm_mday = u%10; if(!tm.tm_mday || tm.tm_mday > 31) goto a; + goto h; + } else if(u < 1971 || u > 2099) goto a; // invalid + tm.tm_year = u; // year "yyyy" + c = *p; // month,day: "mm.dd", "mm-dd", "mm/dd" + if(c != '.' && c != '-' && c != '/') goto b; tm.tm_mon = strtoul(p+1, &p, 10); if(!tm.tm_mon || tm.tm_mon > 12) goto a; tm.tm_mon--; + if(c != '.' && c != '-' && c != '/') goto b; tm.tm_mday = strtoul(p+1, &p, 10); if(!tm.tm_mday || tm.tm_mday > 31) goto a; + if(c != '.' && c != '-' && c != '/') goto b; h:tm.tm_hour = strtoul(p+1, &p, 10); + if(tm.tm_hour <= 24 && *p == ':') { // time ":hh:mm:ss.frac", ":hh:mm:ss,frac" + tm.tm_min = strtoul(p+1, &p, 10); if(tm.tm_min > 60) tm.tm_hour = tm.tm_min = 0; + tm.tm_sec = strtoul(p+1, &p, 10); if(tm.tm_sec > 60) tm.tm_hour = tm.tm_min = tm.tm_sec = 0; + if(type > 0 && (*p == '.' || *p == ',')) { frac = strtoul(p+1, &p, 10); if((c=p-(p+1)) > 6) frac /= 1000000;else if(c > 3) frac /= 1000; } + } else tm.tm_hour = 0; + b:u = mktime(&tm); + u = u * 1000 + frac; // milliseconds + a:*pq = p; //if(verbose >= 9) printf("[%d-%d-%d %.2d:%.2d:%.2d.%d]\n", tm.tm_year, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, frac, u);exit(0); + return u; +} + +//----------------------------- Zipfian + Timestamps generator -------------------------------------------------------- +static double a = 1.5; + +void stprint(char *s, unsigned *xbits) { + int i; + uint64_t t = 0; + for(i = 0; i <= 64; i++) + t += xbits[i]; + printf("%s bits histogram:",s); + /*for(i = 0; i <= 64; i++) { + double f = (double)xbits[i]*100/t; //if(f > m) m = f; + if(xbits[i]) { + if (f > 10) printf("%d:%.0f%% ", i, f); + else if(f > 0.1) printf("%d:%.1f%% ", i, f); + else printf("%d:%.3f%% ", i, f); + } + } + */ + printf("\n"); + for(i = 0; i <= 64; i++) + if(xbits[i]) { + double f = (double)xbits[i]*100/(double)t; + unsigned u = round(f); + printf("%.2d:", i); for(int j=0; j < u; j++) printf("#"); + if (f > 10) printf(" %.0f%% ", f); + else if(f > 0.1) printf(" %.1f%% ", f); + else printf(" %.3f%% ", f); + printf("\n"); + } } int dcmp(double *a, double *b) { @@ -66,10 +142,73 @@ int dcmp(double *a, double *b) { return 0; } +void zipu8(uint8_t *a, unsigned n, double alpha, unsigned x1, unsigned x2) { + int i; + double prob, cum, *zmap; + x2 = x2>0xffu?0xffu:x2; if(x1 > x2) x1 = x2; + unsigned m = x2 - x1 + 1; + if(!(zmap = malloc(m*sizeof(zmap[0])))) die("mallo error %d\n", m); + + // generate initial sample (slow) + srand48(1); + if(alpha > 0) { + for(cum = 0.0,i = 0; i < m; i++) + cum += 1.0 / pow(i+1, alpha); + cum = 1.0 / cum; + for(zmap[0] = prob = cum,i = 1; i < m; i++) zmap[i] = (prob += (cum / pow(i+1, alpha))); + } else for(i = 0; i < m; i++) zmap[i] = 1.0 / m; + + // use binary search to speed up zipfgen + qsort(zmap, m, sizeof(zmap[0]), (int(*)(const void*,const void*))dcmp); + for(i = 0; i < n; i++) { + double r = drand48(); + int l = 0, h = m-1; + while(l < h) { + int k = (l + h) >> 1; + if(r >= zmap[k]) l = k + 1; + else h = k; + } + a[i] = x1 + l; if(a[i]>x2) a[i]=x2; + } + free(zmap); +} + +void zipu16(uint16_t *a, unsigned n, double alpha, unsigned x1, unsigned x2) { + int i; + double prob, cum, *zmap; + x2 = x2>0xffffu?0xffffu:x2; if(x1 > x2) x1 = x2; + unsigned m = x2 - x1 + 1; + if(!(zmap = malloc(m*sizeof(zmap[0])))) die("mallo error %d\n", m); + + // generate initial sample (slow) + srand48(1); + if(alpha > 0) { + for(cum = 0.0,i = 0; i < m; i++) + cum += 1.0 / pow(i+1, alpha); + cum = 1.0 / cum; + for(zmap[0] = prob = cum,i = 1; i < m; i++) zmap[i] = (prob += (cum / pow(i+1, alpha))); + } else for(i = 0; i < m; i++) zmap[i] = 1.0 / m; + + // use binary search to speed up zipfgen + qsort(zmap, m, sizeof(zmap[0]), (int(*)(const void*,const void*))dcmp); + for(i = 0; i < n; i++) { + double r = drand48(); + int l = 0, h = m-1; + while(l < h) { + int k = (l + h) >> 1; + if(r >= zmap[k]) l = k + 1; + else h = k; + } + a[i] = x1 + l; + } + free(zmap); +} + void zipu32(unsigned *a, unsigned n, double alpha, unsigned x1, unsigned x2) { int i; - unsigned m = x2 - x1 + 1; double prob, cum, *zmap; + if(x1 > x2) x1 = x2; + unsigned m = x2 - x1 + 1; if(!(zmap = malloc(m*sizeof(zmap[0])))) die("mallo error %d\n", m); // generate initial sample (slow) @@ -96,7 +235,70 @@ void zipu32(unsigned *a, unsigned n, double alpha, unsigned x1, unsigned x2) { free(zmap); } -void zipu64(uint64_t *a, unsigned n, double alpha, unsigned x1, unsigned x2) { +void zipf32(float *a, unsigned n, double alpha, unsigned x1, unsigned x2) { + int i; + double prob, cum, *zmap; + if(x1 > x2) x1 = x2; + unsigned m = x2 - x1 + 1; + if(!(zmap = malloc(m*sizeof(zmap[0])))) die("mallo error %d\n", m); + + // generate initial sample (slow) + srand48(1); + if(alpha > 0) { + for(cum = 0.0,i = 0; i < m; i++) + cum += 1.0 / pow(i+1, alpha); + cum = 1.0 / cum; + for(zmap[0] = prob = cum,i = 1; i < m; i++) zmap[i] = (prob += (cum / pow(i+1, alpha))); + } else for(i = 0; i < m; i++) zmap[i] = 1.0 / m; + + // use binary search to speed up zipfgen + qsort(zmap, m, sizeof(zmap[0]), (int(*)(const void*,const void*))dcmp); + for(i = 0; i < n; i++) { + double r = drand48(); + int l = 0, h = m-1; + while(l < h) { + int k = (l + h) >> 1; + if(r >= zmap[k]) l = k + 1; + else h = k; + } + a[i] = x1 + l; + } + free(zmap); +} + + +void zipu64(uint64_t *a, unsigned n, double alpha, uint64_t x1, uint64_t x2) { + int i; + double prob, cum, *zmap; + if(x1 > x2) x1 = x2; + unsigned m = x2 - x1 + 1; + if(!(zmap = malloc(m*sizeof(zmap[0])))) die("mallo error %d\n", m); + + // generate initial sample (slow) + srand48(1); + if(alpha > 0) { + for(cum = 0.0,i = 0; i < m; i++) + cum += 1.0 / pow(i+1, alpha); + cum = 1.0 / cum; + for(zmap[0] = prob = cum,i = 1; i < m; i++) zmap[i] = (prob += (cum / pow(i+1, alpha))); + } else for(i = 0; i < m; i++) zmap[i] = 1.0 / m; + + // use binary search to speed up zipfgen + qsort(zmap, m, sizeof(zmap[0]), (int(*)(const void*,const void*))dcmp); + for(i = 0; i < n; i++) { + double r = drand48(); + int l = 0, h = m-1; + while(l < h) { + int k = (l + h) >> 1; + if(r >= zmap[k]) l = k + 1; + else h = k; + } + a[i] = x1 + l; + } + free(zmap); +} + +void zipf64(double *a, unsigned n, double alpha, unsigned x1, unsigned x2) { int i; unsigned m = x2 - x1 + 1; double prob, cum, *zmap; @@ -126,76 +328,64 @@ void zipu64(uint64_t *a, unsigned n, double alpha, unsigned x1, unsigned x2) { free(zmap); } -void zipd64(double *a, unsigned n, double alpha, unsigned x1, unsigned x2) { - int i; - unsigned m = x2 - x1 + 1; - double prob, cum, *zmap; - if(!(zmap = malloc(m*sizeof(zmap[0])))) die("mallo error %d\n", m); - - // generate initial sample (slow) +void tms64(uint64_t *a, unsigned n, unsigned x1, unsigned x2, double z) { // generator for timestamps srand48(1); - if(alpha > 0) { - for(cum = 0.0,i = 0; i < m; i++) - cum += 1.0 / pow(i+1, alpha); - cum = 1.0 / cum; - for(zmap[0] = prob = cum,i = 1; i < m; i++) zmap[i] = (prob += (cum / pow(i+1, alpha))); - } else for(i = 0; i < m; i++) zmap[i] = 1.0 / m; - - // use binary search to speed up zipfgen - qsort(zmap, m, sizeof(zmap[0]), (int(*)(const void*,const void*))dcmp); - for(i = 0; i < n; i++) { - double r = drand48(); - int l = 0, h = m-1; - while(l < h) { - int k = (l + h) >> 1; - if(r >= zmap[k]) l = k + 1; - else h = k; - } - a[i] = x1 + l; - } - free(zmap); -} - -void tms64(double *a, unsigned n, unsigned x1, unsigned x2) { - double freq = drand48()*0.5 + 0.1, amp = drand48()+ 0.5; - int i; for(i=0; i < n; i++) a[i] = x1 + sin(i * freq) * amp; + double freq = drand48()*0.5 + 0.1, amp = (drand48()*z + 0.5); + int i; + for(i = 0; i < n; i++) { + double x = x1 + sin(i * freq) * amp; + a[i] = x>x2?x2:x; + } } #define OVD (10*MB) -static unsigned rm=0,rx=255; +static unsigned rm = 0, rx = 255; unsigned datagen(unsigned char *in, unsigned n, int isize, double be_mindelta) { - unsigned char *ip; printf("zipf alpha=%.2f range[%u..%u].n=%u\n ", a, rm, rx, n); - int mindelta = be_mindelta,i; - //in = malloc(n*isize+OVD); if(!in) die("malloc err=%u", n*isize); + unsigned char *ip; printf("zipf alpha=%.2f range[%u..%u].n=%u\n ", a, rm, rx, n); + int mindelta = be_mindelta,i; //in = malloc(n*isize+OVD); if(!in) die("malloc err=%u", n*isize); switch(isize) { + case 1: zipu8((uint8_t *)in, n, a, rm, rx); //{ int i; for(i = 0; i < n; i++) in[i] = i; } // + for(i = 1; i <= n; i++) xbits[bsr32(ctou8(in+i))]++; + if(mindelta == 0 || mindelta == 1) { + uint8_t *ip = (uint8_t *)in, v; stprint("delta", xbits); + for(ip[0]=0,v = 1; v < n; v++) { + ip[v] += ip[v-1] + mindelta; if(ip[v]>=(1u<<8)) die("overflow generating sorted array %d\n", ip[v]); + } + } else stprint("",xbits); + break; + case 2: zipu16((unsigned short *)in, n, a, rm, rx); //{ int i; for(i = 0; i < n; i++) in[i] = i; } // + for(i = 1; i <= n; i++) xbits[bsr32(ctou16(in+i*2))]++; + if(mindelta == 0 || mindelta == 1) { + unsigned short *ip = (unsigned short *)in, v; stprint("delta", xbits); + for(ip[0]=0,v = 1; v < n; v++) { + ip[v] += ip[v-1] + mindelta; if(ip[v]>=(1u<<16)) die("overflow generating sorted array %d\n", ip[v]); + } + } else stprint("",xbits); + break; case 4: zipu32((unsigned *)in, n, a, rm, rx); //{ int i; for(i = 0; i < n; i++) in[i] = i; } // for(i = 1; i <= n; i++) xbits[bsr32(ctou32(in+i*4))]++; if(mindelta == 0 || mindelta == 1) { - unsigned *ip = (unsigned *)in, v; stprint("delta"); + unsigned *ip = (unsigned *)in, v; stprint("delta", xbits); for(ip[0]=0,v = 1; v < n; v++) { - ip[v] += ip[v-1] + mindelta; if(ip[v]>=(1u<<31)) die("overflow generating sorted array %d\n", ip[v]); + ip[v] += ip[v-1] + mindelta; if(ip[v]>=(1u<<31)) die("overflow generating sorted array %d\n", ip[v]); } - } else stprint(""); + } else stprint("",xbits); break; case 8: zipu64((uint64_t *)in, n, a, rm, rx); //{ int i; for(i = 0; i < n; i++) in[i] = i; } // - for(i = 1; i <= n; i++) xbits[bsr64(ctou64(in+i*8))]++; + for(i = 1; i <= n; i++) xbits[bsr64(ctou64(in+i*8))]++; if(mindelta == 0 || mindelta == 1) { - uint64_t *ip = (uint64_t *)in, v; stprint("delta"); + uint64_t *ip = (uint64_t *)in, v; stprint("delta", xbits); for(ip[0]=0,v = 1; v < n; v++) { - ip[v] += ip[v-1] + mindelta; if(ip[v]>=(1u<<31)) die("overflow generating sorted array %llu\n", ip[v]); + ip[v] += ip[v-1] + mindelta; if(ip[v]>=(1u<<31)) die("overflow generating sorted array %lld\n", ip[v]); } - } else stprint(""); + } else stprint("",xbits); break; - case -8: zipd64((double *)in, n, a, rm, rx); //{ int i; for(i = 0; i < n; i++) in[i] = i; } // - for(i = 1; i <= n; i++) xbits[bsr64(ctou64(in+i*8))]++; - /*if(be_mindelta >= 0 && be_mindelta <= 1) { - double *ip = (double *)in, v; stprint("delta"); - for(ip[0]=0,v = 1; v < n; v++) { - ip[v] = ip[v]+ip[v-1] + be_mindelta; //if(ip[v]>=(double)(1u<<31)) die("overflow generating sorted array %.2f\n", ip[v]); - } - } else*/ - stprint(""); + case -4: zipf32((float *)in, n, a, rm, rx); + stprint("", xbits); + break; + case -8: zipf64((double *)in, n, a, rm, rx); + stprint("", xbits); break; } return n*abs(isize); @@ -203,49 +393,19 @@ unsigned datagen(unsigned char *in, unsigned n, int isize, double be_mindelta) { // 0 1 2 3 4 5 6 7, 8 9 10 11 12 13 14 enum { T_0, T_UINT8, T_UINT16, T_UINT24, T_UINT32, T_UINT40, T_UINT48, T_UINT56, T_UINT64, T_FLOAT, T_DOUBLE, T_CHAR, T_TXT, T_TIM32, T_TIM64, T_TST }; -#define IPUSH(in,n,isize, nmax,u) { if(n >= nmax) { nmax = nmax?(nmax << 1):(1<<20); in = realloc(in, nmax*isize+OVD); if(!in) die("malloc err=%u", nmax); }\ - ctou64(in+n*isize) = u; n++;\ - } + +#define IPUSH(in,n,isize, nmax,u) { \ + if(n >= nmax) { nmax = nmax?(nmax << 1):(1<<20);\ + in = realloc(in, nmax*isize+OVD); if(!in) die("malloc err=%u", nmax); }\ + ctou64(in+n*isize) = u; n++;\ +} int mdelta; char *keysep; -uint64_t strtots(char *p, char **pq, int type) { - struct tm tm; - uint64_t u; - char *s=p; - int frac = 0,c; - - memset(&tm, 0, sizeof(tm)); tm.tm_mday = 1; - while(!isdigit(*p)) p++; - u = strtoull(p, &p, 10); - - if( u <= 99) u += 2000; - else if(u >= 19710101 && u < 20381212) { - tm.tm_year = u/10000; - tm.tm_mon = (u%10000)/100; if(!tm.tm_mon || tm.tm_mon > 12) goto a; tm.tm_mon--; - tm.tm_mday = u%10; if(!tm.tm_mday || tm.tm_mday > 31) goto a; - goto h; - } else if(u < 1971 || u > 2099) goto a; - tm.tm_year = u; - c = *p; - if(c != '.' && c != '-' && c != '/') goto b; tm.tm_mon = strtoul(p+1, &p, 10); if(!tm.tm_mon || tm.tm_mon > 12) goto a; tm.tm_mon--; - if(c != '.' && c != '-' && c != '/') goto b; tm.tm_mday = strtoul(p+1, &p, 10); if(!tm.tm_mday || tm.tm_mday > 31) goto a; - if(c != '.' && c != '-' && c != '/') goto b; h:tm.tm_hour = strtoul(p+1, &p, 10); - if(tm.tm_hour <= 24 && *p == ':') { - tm.tm_min = strtoul(p+1, &p, 10); if(tm.tm_min > 60) tm.tm_hour = tm.tm_min = 0; - tm.tm_sec = strtoul(p+1, &p, 10); if(tm.tm_sec > 60) tm.tm_hour = tm.tm_min = tm.tm_sec = 0; - if(type > 0 && (*p == '.' || *p == ',')) { frac = strtoul(p+1, &p, 10); if((c=p-(p+1)) > 6) frac /= 1000000;else if(c > 3) frac /= 1000; } - } else tm.tm_hour = 0; - b:u = mktime(&tm); - u = u * 1000 + frac; // Milliseconds - a:*pq = p; //if(verbose >= 9) printf("[%d-%d-%d %.2d:%.2d:%.2d.%d]\n", tm.tm_year, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, frac, u);exit(0); - return u; -} - unsigned befgen(unsigned char **_in, unsigned n, int fmt, int isize, FILE *fi, int kid, int skiph, int decs, int divs, int mdelta) { unsigned char *in = *_in,*ip; - unsigned nmax = 0; + unsigned nmax = 0, ovf=0; #define LSIZE (1024*16) char s[LSIZE+1]; double pre; @@ -261,7 +421,7 @@ unsigned befgen(unsigned char **_in, unsigned n, int fmt, int isize, FILE *fi, i switch(fmt) { case T_TXT: case T_TIM32: - case T_TIM64: if(verbose) printf("reading text lines. pre=%.2f, col=%d, sep=%s\n", pre, kid, keysep?keysep:""); + case T_TIM64: if(verbose>1) printf("reading text lines. pre=%.2f, col=%d, sep=%s\n", pre, kid, keysep?keysep:""); while(fgets(s, LSIZE, fi)) { unsigned char *p = s,*q; int k = 0, keyid = 1, c; @@ -282,18 +442,23 @@ unsigned befgen(unsigned char **_in, unsigned n, int fmt, int isize, FILE *fi, i while(!isdigit(*p) && *p != '-' && *p != '+') p++; uint64_t u = strtoll(p, &q, 10)*pre - mdelta; if(*q == '.') - u = pre>1.0?round(strtod(p, &q)*pre):strtod(p, &q) - mdelta; - IPUSH(in,n,isize,nmax,u); c=*q; *q=0; if(verbose>=5 && n < 100 || verbose>=9) printf("\'%s\'->%lld ", p, u, c); *q = c; + u = pre>1.0?round(strtod(p, &q)*pre):strtod(p, &q) - mdelta; + switch(isize) { + case 1: if(u > 0xffu) ovf++; break; + case 2: if(u > 0xffffu) ovf++; break; + case 4: if(u > 0xffffffffu) ovf++; break; + } + IPUSH(in,n,isize,nmax,u); c=*q; *q=0; if(verbose>=5 && n < 100 || verbose>=9) printf("\'%s\'->%lld ", p, u, c); *q = c; } else { - while(*p && !isdigit(*p) && *p != '-' && *p != '.' && *p != '+') { if(keysep && strchr(keysep,*p)) keyid++; p++; } + while(*p && !isdigit(*p) && *p != '-' && *p != '.' && *p != '+') { if(keysep && strchr(keysep,*p)) keyid++; p++; } double d = strtod(p, &q) - mdelta; uint64_t u; memcpy(&u,&d,sizeof(u)); - IPUSH(in,n,-isize,nmax,u); if(verbose>=5 && n < 100 || verbose>=9) { c=*q; *q=0; double d; memcpy(&d,&u,sizeof(d)); printf("\'%s\'->%f ", p, d); *q = c; } + IPUSH(in,n,-isize,nmax,u); if(verbose>=5 && n < 100 || verbose>=9) { c=*q; *q=0; double d; memcpy(&d,&u,sizeof(d)); printf("\'%s\'->%f ", p, d); *q = c; } } } break; - case T_CHAR: if(verbose) printf("reading char file. pre=%.2f\n", pre); + case T_CHAR: if(verbose>1) printf("reading char file. pre=%.2f\n", pre); for(;;) { char *p = s,*q; int c; @@ -311,7 +476,7 @@ unsigned befgen(unsigned char **_in, unsigned n, int fmt, int isize, FILE *fi, i *p = 0; u = strtoll(s, &p, 10) - mdelta; } - IPUSH(in,n,isize,nmax,u); if(verbose>=5 && n < 100 || verbose>=9) printf("%s->%lld ", s, (int64_t)u); + IPUSH(in,n,isize,nmax,u); if(verbose>=5 && n < 100 || verbose>=9) printf("%s->%lld ", s, (int64_t)u); } else { while((c = getc(fi)) >= '0' && c <= '9' || c == '-') if(p - s < LSIZE) *p++ = c; @@ -321,7 +486,7 @@ unsigned befgen(unsigned char **_in, unsigned n, int fmt, int isize, FILE *fi, i *p = 0; double d = strtod(s, &p) - mdelta; uint64_t u; - memcpy(&u,&d,sizeof(u)); if(verbose>=5 && n < 100 || verbose>=9) { double d; memcpy(&d,&u,sizeof(u)); printf("\'%s\'->%f ", s, d); } + memcpy(&u,&d,sizeof(u)); if(verbose>=5 && n < 100 || verbose>=9) { double d; memcpy(&d,&u,sizeof(u)); printf("\'%s\'->%e ", s, d); } IPUSH(in,n,-isize,nmax,u); } if(c == EOF) break; @@ -331,19 +496,34 @@ unsigned befgen(unsigned char **_in, unsigned n, int fmt, int isize, FILE *fi, i } if(verbose>=5) printf("\n"); *_in = in; + if(ovf) printf("number of items truncated=%d\n", ovf); return n*abs(isize); } -//--------------------------------------------------------------------------------------------------------------------------------------------------------- + +//-------------------------------------------- memcheck : buffer compare for equality --------------------------------------------------------------- static int mcpy=1, cmp=2; -#define CBUF(_n_) (((size_t)(_n_))*5/3+1024) +#define CBUF(_n_) (((size_t)(_n_))*5/3+1024/*1024*/) int memcheck(unsigned char *in, unsigned n, unsigned char *cpy) { int i; if(cmp <= 1) return 0; for(i = 0; i < n; i++) if(in[i] != cpy[i]) { if(cmp > 3) abort(); // crash (AFL) fuzzing - printf("ERROR at %d:in=%x,%x dec=%x,%x cmp=%d\n", i, in[i], in[i+1], cpy[i],cpy[i+1], cmp); + printf("ERROR at %d:in=%x,%x,%x,%x dec=%x,%x,%x,%x cmp=%d\n", i, in[i], in[i+1], in[i+2], in[i+3], cpy[i],cpy[i+1],cpy[i+2],cpy[i+3], cmp); + if(cmp > 2) exit(EXIT_FAILURE); + return i+1; + } + return 0; +} + +int memcheck32(unsigned *in, unsigned n, unsigned *cpy) { + int i; + if(cmp <= 1) return 0; + for(i = 0; i < n; i++) + if(in[i] != cpy[i]) { + if(cmp > 3) abort(); // crash (AFL) fuzzing + printf("ERROR at %d:in=%x,%x,%x,%x dec=%x,%x,%x,%x cmp=%d\n", i, in[i], in[i+1], in[i+2], in[i+3], cpy[i],cpy[i+1],cpy[i+2],cpy[i+3], cmp); if(cmp > 2) exit(EXIT_FAILURE); return i+1; } @@ -357,8 +537,8 @@ void libmemcpy(unsigned char *dst, unsigned char *src, int len) { memcpy_ptr(dst, src, len); } -void pr(unsigned l, unsigned n) { double r = (double)l*100.0/n; if(r>0.1) printf("%10u %6.2f%% ", l, r);else printf("%10u %7.3f%%", l, r); fflush(stdout); } -//------------------------------------- +//---------------------------------------- IcApp: Benchmark -------------------------------------------------------------------------- +#define BITUTIL_IN #include "bitutil.h" #include "bitpack.h" #include "vp4.h" @@ -368,18 +548,31 @@ void pr(unsigned l, unsigned n) { double r = (double)l*100.0/n; if(r>0.1) printf #include "vsimple.h" #include "transpose.h" #include "trle.h" - - #ifdef CODEC1 -#include "streamvbyte/include/streamvbyte.h" -#include "streamvbyte/include/streamvbytedelta.h" -#undef VARINTDECODE_H_ - #endif - + #ifdef CODEC1 #define LZ4 #define BITSHUFFLE #endif + #ifdef CODEC1 +#include "streamvbyte/include/streamvbyte.h" +#include "streamvbyte/include/streamvbytedelta.h" +static size_t streamvbyte_zzag_encode(const uint32_t *in, uint32_t length, uint8_t *out, uint32_t prev, uint8_t *tmp) { + zigzag_delta_encode(in, tmp, length, prev); + return streamvbyte_encode(tmp, length, out); +} +static size_t streamvbyte_zzag_decode(const uint8_t *in, uint32_t *out, uint32_t length, uint32_t prev, uint8_t *tmp) { + streamvbyte_decode(in, tmp, length); + zigzag_delta_decode(tmp, out, length, prev); + return length; +} +#undef VARINTDECODE_H_ +#include "ext/fastpfor.h" +#include "MaskedVByte/include/varintencode.h" + #undef VARINTDECODE_H_ +#include "MaskedVByte/include/varintdecode.h" + #endif + #ifdef BITSHUFFLE #include "bitshuffle/src/bitshuffle.h" #ifndef LZ4 @@ -396,10 +589,38 @@ void pr(unsigned l, unsigned n) { double r = (double)l*100.0/n; if(r>0.1) printf #ifdef LZTURBO #include "lzt.c" #endif + +void pr(unsigned l, unsigned n) { double r = (double)l*100.0/n; if(r>0.1) printf("%10u %6.2f%% ", l, r);else printf("%10u %7.3f%%", l, r); fflush(stdout); } #define CPYR(in,n,esize,out) memcpy(out+((n)&(~(esize-1))),in+((n)&(~(esize-1))),(n)&(esize-1)) //, out+((n)&(8*esize-1)) +/*unsigned char *p4menc32(uint32_t *in, unsigned n, unsigned char *out, uint32_t start, unsigned char *tmp) { + uint32_t x, mdelta,*pa = (unsigned *)tmp; + bitfm32(in, n, &x); // determine minimum value + mdelta = bitdi32(in, n, x); if(mdelta>(1<<27)) mdelta=1<<27; // determine minimum delta + bitdienc32(in, n, pa, x, mdelta); // delta transform + mdelta = mdelta<<5|(x&31); x>>=5; vbxput32(out, x); vbput32(out, mdelta); + return p4nenc32(pa, n, out); +}*/ -//----------------- vsimple --------------------------- +#if 0 //def __AVX2__ +void ictste32(uint32_t *in, size_t _n, uint32_t *out) { uint32_t *ip,*op,n=_n/4; + for(ip = in,op=out; ip != in+(n&~(8-1)); ip += 8, op += 8) { + __m256i vi = _mm256_loadu_si256((__m256i *)ip); + vi = mm256_zzage_epi32(vi); + _mm256_storeu_si256((__m256i *)op, vi); + } +} + +void ictstd32(uint32_t *in, size_t _n, uint32_t *out) { uint32_t *ip,*op,n=_n/4; + for(ip = in,op=out; ip != in+(n&~(8-1)); ip += 8, op += 8) { + __m256i vi = _mm256_loadu_si256((__m256i *)ip); + vi = mm256_zzagd_epi32(vi); + _mm256_storeu_si256((__m256i *)op,vi); + } +} +#endif + +//------------------ TurboVSsimple zigzag------------------------------------------ unsigned char *vszenc8( uint8_t *in, unsigned n, unsigned char *out, unsigned char *tmp) { bitzenc8( in, n, tmp, 0, 0); return vsenc8( tmp, n, out); } unsigned char *vszenc16(uint16_t *in, unsigned n, unsigned char *out, unsigned char *tmp) { bitzenc16(in, n, tmp, 0, 0); return vsenc16(tmp, n, out); } unsigned char *vszenc32(uint32_t *in, unsigned n, unsigned char *out, unsigned char *tmp) { bitzenc32(in, n, tmp, 0, 0); return vsenc32(tmp, n, out); } @@ -410,7 +631,7 @@ unsigned char *vszdec16(unsigned char *in, unsigned n, unsigned char *out) { uns unsigned char *vszdec32(unsigned char *in, unsigned n, unsigned char *out) { unsigned char *p = vsdec32(in,n,out); bitzdec32(out, n, 0); return p; } unsigned char *vszdec64(unsigned char *in, unsigned n, unsigned char *out) { unsigned char *p = vsdec64(in,n,out); bitzdec64(out, n, 0); return p; } -//------------------ RLE ------------------------- +//------------------ TurboRLE (Run Length Encoding) + zigzag/xor ------------------------- #define RLE8 0xdau #define RLE16 0xdadau #define RLE32 0xdadadadau @@ -418,6 +639,9 @@ unsigned char *vszdec64(unsigned char *in, unsigned n, unsigned char *out) { uns unsigned trlezc( uint8_t *in, unsigned n, unsigned char *out, unsigned char *tmp) { bitzenc8(in, n, tmp, 0, 0); unsigned rc = trlec(tmp, n, out); if(rc >=n) { rc = n; memcpy(out,in,n); } return rc; } unsigned trlezd(unsigned char *in, unsigned inlen, uint8_t *out, unsigned n) { if(inlen >= n) { memcpy(out,in,n); return inlen; } trled(in, inlen, out, n); bitzdec8(out, n, 0); return n; } +unsigned trlexc( uint8_t *in, unsigned n, unsigned char *out, unsigned char *tmp) { bitxenc8(in, n, tmp, 0); unsigned rc = trlec(tmp, n, out); if(rc >=n) { rc = n; memcpy(out,in,n); } return rc; } +unsigned trlexd(unsigned char *in, unsigned inlen, uint8_t *out, unsigned n) { if(inlen >= n) { memcpy(out,in,n); return inlen; } trled(in, inlen, out, n); bitxdec8(out, n, 0); return n; } + unsigned srlezc8( uint8_t *in, unsigned n, unsigned char *out, unsigned char *tmp, uint8_t e) { bitzenc8( in, n/( 8/8), tmp, 0, 0); return srlec8( tmp, n, out, e); } unsigned srlezc16(uint16_t *in, unsigned n, unsigned char *out, unsigned char *tmp, uint16_t e) { bitzenc16(in, n/(16/8), tmp, 0, 0); return srlec16(tmp, n, out, e); } unsigned srlezc32(uint32_t *in, unsigned n, unsigned char *out, unsigned char *tmp, uint32_t e) { bitzenc32(in, n/(32/8), tmp, 0, 0); return srlec32(tmp, n, out, e); } @@ -428,7 +652,17 @@ unsigned srlezd16(unsigned char *in, unsigned inlen, unsigned char *out, unsigne unsigned srlezd32(unsigned char *in, unsigned inlen, unsigned char *out, unsigned n, uint32_t e) { srled32(in,inlen,out, n, e); bitzdec32(out, n/(32/8), 0); return n; } unsigned srlezd64(unsigned char *in, unsigned inlen, unsigned char *out, unsigned n, uint64_t e) { srled64(in,inlen,out, n, e); bitzdec64(out, n/(64/8), 0); return n; } -//------------------- LZ -------------------------------------------------- +unsigned srlexc8( uint8_t *in, unsigned n, unsigned char *out, unsigned char *tmp, uint8_t e) { bitxenc8( in, n/( 8/8), tmp, 0); return srlec8( tmp, n, out, e); } +unsigned srlexc16(uint16_t *in, unsigned n, unsigned char *out, unsigned char *tmp, uint16_t e) { bitxenc16(in, n/(16/8), tmp, 0); return srlec16(tmp, n, out, e); } +unsigned srlexc32(uint32_t *in, unsigned n, unsigned char *out, unsigned char *tmp, uint32_t e) { bitxenc32(in, n/(32/8), tmp, 0); return srlec32(tmp, n, out, e); } +unsigned srlexc64(uint64_t *in, unsigned n, unsigned char *out, unsigned char *tmp, uint64_t e) { bitxenc64(in, n/(64/8), tmp, 0); return srlec64(tmp, n, out, e); } + +unsigned srlexd8( unsigned char *in, unsigned inlen, unsigned char *out, unsigned n, uint8_t e) { srled8(in,inlen,out, n, e); bitxdec8( out, n/(8/8), 0); return n; } +unsigned srlexd16(unsigned char *in, unsigned inlen, unsigned char *out, unsigned n, uint16_t e) { srled16(in,inlen,out, n, e); bitxdec16(out, n/(16/8), 0); return n; } +unsigned srlexd32(unsigned char *in, unsigned inlen, unsigned char *out, unsigned n, uint32_t e) { srled32(in,inlen,out, n, e); bitxdec32(out, n/(32/8), 0); return n; } +unsigned srlexd64(unsigned char *in, unsigned inlen, unsigned char *out, unsigned n, uint64_t e) { srled64(in,inlen,out, n, e); bitxdec64(out, n/(64/8), 0); return n; } + +//------------------- LZ compression -------------------------------------------------- #ifdef USE_LZ unsigned lzcomp(unsigned char *in, unsigned n, unsigned char *out, int lev) { if(!n) return 0; unsigned outsize = CBUF(n); @@ -454,157 +688,384 @@ unsigned lzdecomp(unsigned char *in, unsigned n, unsigned char *out) { if(!n) re #endif } - #ifdef USE_SSE -unsigned tp4lzenc(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { - tp4enc(in, n, tmp, esize); +//------------------- TurboByte + lz ---------------------------- +unsigned v8lzenc(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { unsigned l = esize==2?v8enc16(in, (n+1)/2, tmp):v8enc32(in, (n+3)/4, tmp)-tmp; return lzcomp(tmp, l, out, lev); } +unsigned v8lzdec(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp) { lzdecomp(in,n,tmp); esize==2?v8dec16(tmp,(n+1)/2, (unsigned char *)out):v8dec32(tmp,(n+3)/4, (unsigned char *)out); return n; } + +unsigned v8lzxenc(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { + switch(esize) { + case 1 : bitxenc8( in, n/1, out, 0); break; + case 2 : bitxenc16(in, n/2, out, 0); break; + case 4 : bitxenc32(in, n/4, out, 0); break; + case 8 : bitxenc64(in, n/8, out, 0); break; + } CPYR(in,n,esize,out); + esize==2?v8enc16(out, n, tmp):v8enc32(out, n, tmp); return lzcomp(tmp, n, out, lev); } - -unsigned tp4lzdec(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp) { +unsigned v8lzxdec(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp) { lzdecomp(in,n,tmp); - tp4dec(tmp, n, (unsigned char *)out, esize); - return n; -} -//----------- -unsigned tp4lzzenc16(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp, int lev) { - bitzenc16(in, n/2, out, 0, 0); CPYR(in,n,2,out); - tp4enc(out, n, tmp, 2); - return lzcomp(tmp, n, out, lev); -} - -unsigned tp4lzzdec16(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp) { - lzdecomp(in,n,tmp); - tp4dec(tmp, n, (unsigned char *)out, 2); - bitzdec16(out, n/2, 0); + esize==2?v8dec16(tmp, n, (unsigned char *)out):v8dec32(tmp, n, (unsigned char *)out); + switch(esize) { + case 1: bitxdec8( out, n/1, 0);break; + case 2: bitxdec16(out, n/2, 0);break; + case 4: bitxdec32(out, n/4, 0);break; + case 8: bitxdec64(out, n/8, 0);break; + } return n; } -unsigned tp4lzxenc16(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp, int lev) { - bitxenc16(in, n/2, out, 0); CPYR(in,n,2,out); - tp4enc(out, n, tmp, 2); +unsigned v8lzzenc(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { // TurboVByte + switch(esize) { + case 1 : bitzenc8( in, n/1, out, 0, 0); break; + case 2 : bitzenc16(in, n/2, out, 0, 0); break; + case 4 : bitzenc32(in, n/4, out, 0, 0); break; + case 8 : bitzenc64(in, n/8, out, 0, 0); break; + } CPYR(in,n,esize,out); + esize==2?v8enc16(out, n, tmp):v8enc32(out, n, tmp); return lzcomp(tmp, n, out, lev); } -unsigned tp4lzxdec16(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp) { +unsigned v8lzzdec(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp) { lzdecomp(in,n,tmp); - tp4dec(tmp, n, (unsigned char *)out, 2); - bitxdec16(out, n/2, 0); + esize==2?v8dec16(tmp, n, (unsigned char *)out):v8dec32(tmp, n, (unsigned char *)out); + switch(esize) { + case 1: bitzdec8( out, n/1, 0);break; + case 2: bitzdec16(out, n/2, 0);break; + case 4: bitzdec32(out, n/4, 0);break; + case 8: bitzdec64(out, n/8, 0);break; + } return n; } -//-------------- -unsigned tp4lzzenc32(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp, int lev) { - bitzenc32(in, n/4, out, 0, 0); CPYR(in,n,4,out); - tp4enc(out, n, tmp, 4); +//----------------- Byte transpose + Lz --------------------------------------------------------------------------------------- + #if 1 //def USE_SSE +unsigned tplzenc(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { tpenc(in, n, tmp, esize); return lzcomp(tmp, n, out, lev);} +unsigned tplzdec(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp) { lzdecomp(in,n,tmp); tpdec(tmp, n, (unsigned char *)out, esize); return n;} + +unsigned tplzxenc(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { // XOR + switch(esize) { + case 1 : bitxenc8( in, n/1, out, 0); break; + case 2 : bitxenc16(in, n/2, out, 0); break; + case 4 : bitxenc32(in, n/4, out, 0); break; + case 8 : bitxenc64(in, n/8, out, 0); break; + } CPYR(in,n,esize,out); + tpenc(out, n, tmp, esize); return lzcomp(tmp, n, out, lev); } - -unsigned tp4lzzdec32(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp) { +unsigned tplzxdec(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp) { lzdecomp(in,n,tmp); - tp4dec(tmp, n, (unsigned char *)out, 4); - bitzdec32(out, n/4, 0); + tpdec(tmp, n, (unsigned char *)out, esize); + switch(esize) { + case 1: bitxdec8( out, n/1, 0);break; + case 2: bitxdec16(out, n/2, 0);break; + case 4: bitxdec32(out, n/4, 0);break; + case 8: bitxdec64(out, n/8, 0);break; + } return n; } -unsigned tp4lzxenc32(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp, int lev) { - bitxenc32(in, n/4, out, 0); CPYR(in,n,4,out); - tp4enc(out, n, tmp, 4); +unsigned tplzzenc(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { // Zigzag + switch(esize) { + case 1 : bitzenc8( in, n/1, out, 0, 0); break; + case 2 : bitzenc16(in, n/2, out, 0, 0); break; + case 4 : bitzenc32(in, n/4, out, 0, 0); break; + case 8 : bitzenc64(in, n/8, out, 0, 0); break; + } CPYR(in,n,esize,out); + tpenc(out, n, tmp, esize); return lzcomp(tmp, n, out, lev); } - -unsigned tp4lzxdec32(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp) { +unsigned tplzzdec(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp) { lzdecomp(in,n,tmp); - tp4dec(tmp, n, (unsigned char *)out, 4); - bitxdec32(out, n/4, 0); + tpdec(tmp, n, (unsigned char *)out, esize); + switch(esize) { + case 1: bitzdec8( out, n/1, 0);break; + case 2: bitzdec16(out, n/2, 0);break; + case 4: bitzdec32(out, n/4, 0);break; + case 8: bitzdec64(out, n/8, 0);break; + } return n; } -//------------------ -unsigned tp4lzzenc64(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp, int lev) { - bitzenc64(in, n/8, out, 0, 0); CPYR(in,n,8,out); - tp4enc(out, n, tmp, 8); + +//------------------- tp4 : Nibble transpose + lz -------------------------------- +unsigned tp4lzenc(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { tp4enc(in, n, tmp, esize); return lzcomp(tmp, n, out, lev); } +unsigned tp4lzdec(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp) { lzdecomp(in,n,tmp); tp4dec(tmp, n, (unsigned char *)out, esize); return n; } + +unsigned tp4lzxenc(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { //XOR + switch(esize) { + case 1 : bitxenc8( in, n/1, out, 0); break; + case 2 : bitxenc16(in, n/2, out, 0); break; + case 4 : bitxenc32(in, n/4, out, 0); break; + case 8 : bitxenc64(in, n/8, out, 0); break; + } CPYR(in,n,esize,out); + tp4enc(out, n, tmp, esize); return lzcomp(tmp, n, out, lev); } - -unsigned tp4lzzdec64(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp) { +unsigned tp4lzxdec(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp) { lzdecomp(in,n,tmp); - tp4dec(tmp, n, (unsigned char *)out, 8); - bitzdec64(out, n/8, 0); + tp4dec(tmp, n, (unsigned char *)out, esize); + switch(esize) { + case 1: bitxdec8( out, n/1, 0);break; + case 2: bitxdec16(out, n/2, 0);break; + case 4: bitxdec32(out, n/4, 0);break; + case 8: bitxdec64(out, n/8, 0);break; + } return n; } -unsigned tp4lzxenc64(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp, int lev) { - bitxenc64(in, n/8, out, 0); CPYR(in,n,8,out); - tp4enc(out, n, tmp, 8); - return lzcomp(tmp, n, out, lev); -} -unsigned tp4lzxdec64(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp) { - lzdecomp(in,n,tmp); - tp4dec(tmp, n, (unsigned char *)out, 8); - bitxdec64(out, n/8, 0); - return n; -} -//-------------------------- -unsigned tp4lzzenc8(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp, int lev) { - bitzenc8(in, n/1, out, 0, 0); - tp4enc(out, n, tmp, 1); +unsigned tp4lzzenc(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { + switch(esize) { + case 1 : bitzenc8( in, n/1, out, 0, 0); break; + case 2 : bitzenc16(in, n/2, out, 0, 0); break; + case 4 : bitzenc32(in, n/4, out, 0, 0); break; + case 8 : bitzenc64(in, n/8, out, 0, 0); break; + } CPYR(in,n,esize,out); + tp4enc(out, n, tmp, esize); return lzcomp(tmp, n, out, lev); } - -unsigned tp4lzzdec8(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp) { +unsigned tp4lzzdec(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp) { lzdecomp(in,n,tmp); - tp4dec(tmp, n, (unsigned char *)out, 1); - bitzdec8(out, n/1, 0); + tp4dec(tmp, n, (unsigned char *)out, esize); + switch(esize) { + case 1: bitzdec8( out, n/1, 0);break; + case 2: bitzdec16(out, n/2, 0);break; + case 4: bitzdec32(out, n/4, 0);break; + case 8: bitzdec64(out, n/8, 0);break; + } return n; } -unsigned tp4lzxenc8(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp, int lev) { - bitxenc8(in, n/1, out, 0); - tp4enc(out, n, tmp, 1); - return lzcomp(tmp, n, out, lev); +//------------------ 2D ----------------- +unsigned tp2dlzzenc(unsigned char *in, unsigned x, unsigned y, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { + switch(esize) { + case 1 : bitzenc8( in, x*y, out, 0, 0); break;//CPYR(in,n,4,out); + case 2 : bitzenc16(in, x*y, out, 0, 0); break;//CPYR(in,n,4,out); + case 4 : bitzenc32(in, x*y, out, 0, 0); break;//CPYR(in,n,4,out); + case 8 : bitzenc64(in, x*y, out, 0, 0); break;//CPYR(in,n,4,out); + } + tp2denc(out, x, y, tmp, esize); + return lzcomp(tmp, x*y*esize, out, lev); } -unsigned tp4lzxdec8(unsigned char *in, unsigned n, unsigned char *out, unsigned char *tmp) { - lzdecomp(in,n,tmp); - tp4dec(tmp, n, (unsigned char *)out, 1); - bitxdec8(out, n/1, 0); - return n; +unsigned tp2dlzzdec(unsigned char *in, unsigned x, unsigned y, unsigned char *out, unsigned esize, unsigned char *tmp) { + lzdecomp(in,x*y*esize,tmp); + tp2ddec(tmp, x, y, (unsigned char *)out, esize); + switch(esize) { + case 1: bitzdec8( out, x*y, 0);break; + case 2: bitzdec16(out, x*y, 0);break; + case 4: bitzdec32(out, x*y, 0);break; + case 8: bitzdec64(out, x*y, 0);break; + } + return x*y*esize; +} + +unsigned tp2dlzxenc(unsigned char *in, unsigned x, unsigned y, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { + switch(esize) { + case 1 : bitxenc8( in, x*y, out, 0); break;//CPYR(in,n,4,out); + case 2 : bitxenc16(in, x*y, out, 0); break;//CPYR(in,n,4,out); + case 4 : bitxenc32(in, x*y, out, 0); break;//CPYR(in,n,4,out); + case 8 : bitxenc64(in, x*y, out, 0); break;//CPYR(in,n,4,out); + } + tp2denc(out, x, y, tmp, esize); + return lzcomp(tmp, x*y*esize, out, lev); +} +unsigned tp2dlzxdec(unsigned char *in, unsigned x, unsigned y, unsigned char *out, unsigned esize, unsigned char *tmp) { + lzdecomp(in,x*y*esize,tmp); + tp2ddec(tmp, x, y, (unsigned char *)out, esize); + switch(esize) { + case 1: bitxdec8( out, x*y, 0);break; + case 2: bitxdec16(out, x*y, 0);break; + case 4: bitxdec32(out, x*y, 0);break; + case 8: bitxdec64(out, x*y, 0);break; + } + return x*y*esize; +} +//------------------ 3D ----------------- +unsigned tp3dlzzenc(unsigned char *in, unsigned x, unsigned y, unsigned z, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { + switch(esize) { + case 1 : bitzenc8( in, x*y*z, out, 0, 0); break;//CPYR(in,n,4,out); + case 2 : bitzenc16(in, x*y*z, out, 0, 0); break;//CPYR(in,n,4,out); + case 4 : bitzenc32(in, x*y*z, out, 0, 0); break;//CPYR(in,n,4,out); + case 8 : bitzenc64(in, x*y*z, out, 0, 0); break;//CPYR(in,n,4,out); + } + tp3denc(out, x, y, z, tmp, esize); + return lzcomp(tmp, x*y*z*esize, out, lev); +} +unsigned tp3dlzzdec(unsigned char *in, unsigned x, unsigned y, unsigned z, unsigned char *out, unsigned esize, unsigned char *tmp) { + lzdecomp(in,x*y*z*esize,tmp); + tp3ddec(tmp, x, y, z, (unsigned char *)out, esize); + switch(esize) { + case 1: bitzdec8( out, x*y*z, 0);break; + case 2: bitzdec16(out, x*y*z, 0);break; + case 4: bitzdec32(out, x*y*z, 0);break; + case 8: bitzdec64(out, x*y*z, 0);break; + } + return x*y*z*esize; +} + +unsigned tp3dlzxenc(unsigned char *in, unsigned x, unsigned y, unsigned z, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { + switch(esize) { + case 1 : bitxenc8( in, x*y*z, out, 0); break;//CPYR(in,n,4,out); + case 2 : bitxenc16(in, x*y*z, out, 0); break;//CPYR(in,n,4,out); + case 4 : bitxenc32(in, x*y*z, out, 0); break;//CPYR(in,n,4,out); + case 8 : bitxenc64(in, x*y*z, out, 0); break;//CPYR(in,n,4,out); + } + tp3denc(out, x, y, z, tmp, esize); + return lzcomp(tmp, x*y*z*esize, out, lev); +} +unsigned tp3dlzxdec(unsigned char *in, unsigned x, unsigned y, unsigned z, unsigned char *out, unsigned esize, unsigned char *tmp) { + lzdecomp(in,x*y*z*esize,tmp); + tp3ddec(tmp, x, y, z, (unsigned char *)out, esize); + switch(esize) { + case 1: bitxdec8( out, x*y*z, 0);break; + case 2: bitxdec16(out, x*y*z, 0);break; + case 4: bitxdec32(out, x*y*z, 0);break; + case 8: bitxdec64(out, x*y*z, 0);break; + } + return x*y*z*esize; +} + +//------------------ 4D ----------------- +unsigned tp4dlzzenc(unsigned char *in, unsigned w, unsigned x, unsigned y, unsigned z, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { + switch(esize) { + case 1 : bitzenc8( in, w*x*y*z, out, 0, 0); break;//CPYR(in,n,4,out); + case 2 : bitzenc16(in, w*x*y*z, out, 0, 0); break;//CPYR(in,n,4,out); + case 4 : bitzenc32(in, w*x*y*z, out, 0, 0); break;//CPYR(in,n,4,out); + case 8 : bitzenc64(in, w*x*y*z, out, 0, 0); break;//CPYR(in,n,4,out); + } + tp4denc(out, w, x, y, z, tmp, esize); + return lzcomp(tmp, w*x*y*z*esize, out, lev); +} +unsigned tp4dlzzdec(unsigned char *in, unsigned w, unsigned x, unsigned y, unsigned z, unsigned char *out, unsigned esize, unsigned char *tmp) { + lzdecomp(in, w*x*y*z*esize,tmp); + tp4ddec(tmp, w, x, y, z, (unsigned char *)out, esize); + switch(esize) { + case 1: bitzdec8( out, w*x*y*z, 0);break; + case 2: bitzdec16(out, w*x*y*z, 0);break; + case 4: bitzdec32(out, w*x*y*z, 0);break; + case 8: bitzdec64(out, w*x*y*z, 0);break; + } + return w*x*y*z*esize; +} + +unsigned tp4dlzxenc(unsigned char *in, unsigned w, unsigned x, unsigned y, unsigned z, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { + switch(esize) { + case 1 : bitxenc8( in, w*x*y*z, out, 0); break;//CPYR(in,n,4,out); + case 2 : bitxenc16(in, w*x*y*z, out, 0); break;//CPYR(in,n,4,out); + case 4 : bitxenc32(in, w*x*y*z, out, 0); break;//CPYR(in,n,4,out); + case 8 : bitxenc64(in, w*x*y*z, out, 0); break;//CPYR(in,n,4,out); + } + tp4denc(out, w, x, y, z, tmp, esize); + return lzcomp(tmp, w*x*y*z*esize, out, lev); +} +unsigned tp4dlzxdec(unsigned char *in, unsigned w, unsigned x, unsigned y, unsigned z, unsigned char *out, unsigned esize, unsigned char *tmp) { + lzdecomp(in, w*x*y*z*esize,tmp); + tp4ddec(tmp, w, x, y, z, (unsigned char *)out, esize); + switch(esize) { + case 1: bitxdec8( out, w*x*y*z, 0);break; + case 2: bitxdec16(out, w*x*y*z, 0);break; + case 4: bitxdec32(out, w*x*y*z, 0);break; + case 8: bitxdec64(out, w*x*y*z, 0);break; + } + return w*x*y*z*esize; } #endif - -unsigned tplzenc(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { - tpenc(in, n, tmp, esize); - return lzcomp(tmp, n, out, lev); + +unsigned tp2dlzenc(unsigned char *in, unsigned x, unsigned y, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { + tp2denc(in, x, y, tmp, esize); //printf("x=%d,y=%d e=%d ", x, y, esize); + return lzcomp(tmp, x*y*esize, out, lev); +} +unsigned tp2dlzdec(unsigned char *in, unsigned x, unsigned y, unsigned char *out, unsigned esize, unsigned char *tmp) { + lzdecomp(in, x*y*esize, tmp); + tp2ddec(tmp, x, y, (unsigned char *)out, esize); + return x*y*esize; } -unsigned tplzdec(unsigned char *in, unsigned n, unsigned char *out, unsigned esize, unsigned char *tmp) { +unsigned tp3dlzenc(unsigned char *in, unsigned x, unsigned y, unsigned z, unsigned char *out, unsigned esize, unsigned char *tmp, int lev) { + tp3denc(in, x, y, z, tmp, esize); //for(int i=0;i>23 & 0xff) - 0x7e ) + #define EXPO64(u) ((u>>52 & 0x7ff) - 0x3fe) + #define MANT32(u) (u & 0x807fffffu) + #define MANT64(u) (u & 0x800fffffffffffffull) + #define U(s) TEMPLATE3(uint, s, _t) u = TEMPLATE2(ctou,s)(op);\ + t = TEMPLATE2(ctz,s)(u); tb += t; if(u) lb += TEMPLATE2(clz,s)(u); AC(t<=s,"Fatal t=%d ", t); \ + start ^= u; t = TEMPLATE2(ctz,s)(start); xtb += t; if(start) xlb += TEMPLATE2(clz,s)(start); start = u + + for(ip = in, op = out; ip < in+n*esize; ip += esize, op += esize) { + double id, od; + switch(s) { + case -4: { id = ctof32(ip); od = ctof32(op); U(32); e = EXPO32(u); expo = clz32(zigzagenc32(e-expo))/*-(32-(32-MANTF32-1))*/; elb+=expo; expo = e; + m = MANT32(u); mant = ctz32( m^mant) ; mtb+=mant; mant = m;//ctz32(zigzagenc32(m-mant)) + } break; + case -8: { id = ctof64(ip); od = ctof64(op); U(64); e = EXPO64(u); expo = clz32(zigzagenc32(e-expo))/*-(32-(64-MANTF64-1))*/; elb+=expo; expo = e; + m = MANT64(u); mant = ctz64( m^mant) ; mtb+=mant; mant = m;//ctz64(zigzagenc64(m-mant)) + } break; + case 1: { id = ctou8( ip); od = ctou8( op); U( 8);} break; + case 2: { id = ctou16(ip); od = ctou16(op); U(16);} break; + case 4: { id = ctou32(ip); od = ctou32(op); U(32);} break; + case 8: { id = ctou64(ip); od = ctou64(op); U(64);} break; + } + imax = max(id, imax); + imin = min(id, imin); + + double e = fabs(id - od); // absolute error + emax = max(e,emax); //emin = min(e,emin); + esum += e; + esumsqr += e*e; + + if(id) { idn++; + double erel = e/fabs(id); // relative error + erelmax = max(erelmax,erel); //erelmin = min(erelmin,erel); + //erelsum += e; erelsumsqr += e*e; + } + isumpavg += (id - iavg)*(id - iavg); + osumpavg += (od - oavg)*(od - oavg); + iosumpavg += (id - iavg)*(od - oavg); //bits += ctz64(ctou64(&od)) - ctz64(ctou64(&id)); + } + double mse = esumsqr/n, irange = imax - imin, fb=0; + if(s == -4) fb = (double)elb*100/((double)n*8); + else if(s == -8) fb = (double)elb*100/((double)n*11); + + //printf("Leading/Trailing bits [%.2f%%,%.2f%%=%.2f%%]. XOR[%.2f%%,%.2f%%=%.2f%%] Zigzag[%.2f%%,%.2f%%=%.2f%%]\n", BR(lb), BR(tb), BR(lb+tb), BR(xlb), BR(xtb), BR(xlb+xtb), BR(elb), BR(mtb), BR(elb+mtb) ); + printf("range: [%.20G - %.20G] = %.20G.\n", imin, imax, irange); + //printf("Min error: Absolute = %.12f, Relative = %f, pointwise relative = %f\n", emin, emin/irange, emax/irange, erelmax); + //printf("Avg error: Absolute = %.12f, Relative = %f, pointwise relative = %f\n", esum/idn, (esum/idn)/irange, erelsum/idn); + printf("Max error: Absolute = %.20G, Relative = %f, pointwise relative = %f\n", emax, emax/irange, erelmax); + printf("Peak Signal-to-Noise Ratio: PSNR = %f\n", 20*log10(irange)-10*log10(mse)); // psnr = 20 * log10((fmax - fmin) / (2 * erms)); + printf("Normalized Root Mean Square Error: NRMSE = %f\n", sqrt(mse)/irange); + double std1 = sqrt(isumpavg/n), std2 = sqrt(osumpavg/n), ee = iosumpavg/n, acEff = (iosumpavg/n)/sqrt(isumpavg/n)/sqrt(osumpavg/n); + //printf("Pearson Correlation Coefficient = %f\n", (iosumpavg/n)/sqrt(isumpavg/n)/sqrt(osumpavg/n)); +} + +//--------------------------------------------------------------------------------------------------------------------------------------------------- +#define NEEDTMP (id == 39 || id == 102 || id>=70 && id <= 99) +unsigned dim1,dim2,dim3,dim4; + +#define USIZE 1 unsigned bench8(unsigned char *in, unsigned n, unsigned char *out, unsigned char *cpy, int id, char *inname, int lev) { - unsigned l,m = n/(8/8),rc = 0, sorted=1; + unsigned l,m = n/(USIZE),rc = 0, d, dmin=-1; uint8_t *p; - char *tmp = NULL; - if((id == 43 || id>=60 && id <= 79) && !(tmp = (unsigned char*)malloc(CBUF(n)))) die(stderr, "malloc error\n"); + char *tmp = NULL; + if(NEEDTMP && !(tmp = (unsigned char*)malloc(CBUF(n)))) die(stderr, "malloc error\n"); - for(p=(uint8_t*)in,l = 1; l < m; l++) if(p[l] < p[l-1]) { sorted = 0; break; } + for(p = (uint8_t*)in,l = 1; l < m; l++) //calc mindelta + if(d=(p[l] < p[l-1])) { dmin = -1; break; /*unsorted*/} + else if(d < dmin) dmin = d; - memrcpy(cpy,in,n); + memrcpy(cpy,in,n); l = 0; switch(id) { - case 1: TMBENCH("",l=p4nenc8( in, m, out) ,n); pr(l,n); TMBENCH2("p4nenc8 ",p4ndec8( out, m, cpy) ,n); break; - - case 4: TMBENCH("",l=p4ndenc8( in, m, out) ,n); pr(l,n); TMBENCH2("p4ndenc8 ",p4nddec8( out, m, cpy) ,n); break; - - case 7: TMBENCH("",l=p4nd1enc8( in, m, out) ,n); pr(l,n); TMBENCH2("p4nd1enc8 ",p4nd1dec8( out, m, cpy) ,n); break; + case 1: TMBENCH("",l=p4nenc8( in, m, out) ,n); pr(l,n); TMBENCH2(" 1",p4ndec8( out, m, cpy) ,n); break; - case 10: TMBENCH("",l=p4nzenc8( in, m, out) ,n); pr(l,n); TMBENCH2("p4nzenc8 ",p4nzdec8( out, m, cpy) ,n); break; - //case 13: TMBENCH("",l=p4nsenc8( in, m, out) ,n); pr(l,n); TMBENCH2("p4nsenc8 ",p4nsdec8( out, m, cpy) ,n); break; - - case 20: TMBENCH("",l=bitnpack8( in, m, out) ,n); pr(l,n); TMBENCH2("bitnpack8 ",bitnunpack8( out, m, cpy) ,n); break; - - case 23: TMBENCH("",l=bitndpack8( in, m, out) ,n); pr(l,n); TMBENCH2("bitndpack8 ",bitndunpack8( out, m, cpy) ,n); break; - - case 26: TMBENCH("",l=bitnd1pack8( in, m, out) ,n); pr(l,n); TMBENCH2("bitnd1pack8 ",bitnd1unpack8( out, m, cpy) ,n); break; - - case 29: TMBENCH("",l=bitnzpack8( in, m, out) ,n); pr(l,n); TMBENCH2("bitnzpack8 ",bitnzunpack8( out, m, cpy) ,n); break; - - case 32: if(!sorted) return 0; TMBENCH("",l=bitnfpack8(in, m, out) ,n); pr(l,n); - TMBENCH2("bitnfpack8 ",bitnfunpack8( out, m, cpy) ,n); break; + case 4: TMBENCH("",l=p4ndenc8( in, m, out) ,n); pr(l,n); TMBENCH2(" 4",p4nddec8( out, m, cpy) ,n); break; - case 41: TMBENCH("",l=vbzenc8( in, m, out,0)-out,n); pr(l,n); TMBENCH2("vbzenc8 ",vbzdec8( out, m, cpy,0) ,n); break; - case 42: TMBENCH("",l=vsenc8( in, m, out)-out,n); pr(l,n); TMBENCH2("vsenc8 ",vsdec8( out, m, cpy) ,n); break; // vsimple : variable simple - case 43: TMBENCH("",l=vszenc8( in, m, out,tmp)-out,n); pr(l,n); TMBENCH2("vszenc8 ",vszdec8( out, m, cpy) ,n); break; - - case 50: TMBENCH("",l=bvzzenc8( in, m, out,0),n); pr(l,n); TMBENCH2("bvzzenc8 ",bvzzdec8( out, m, cpy,0) ,n); break; // bitio - case 51: TMBENCH("",l=bvzenc8( in, m, out,0),n); pr(l,n); TMBENCH2("bvzenc8 ",bvzdec8( out, m, cpy,0) ,n); break; - case 52: TMBENCH("",l=fpgenc8( in, m, out,0),n); pr(l,n); TMBENCH2("fpgenc8 ",fpgdec8( out, m, cpy,0) ,n); break; + case 7: TMBENCH("",l=p4nd1enc8( in, m, out) ,n); pr(l,n); TMBENCH2(" 7",p4nd1dec8( out, m, cpy) ,n); break; - case 55: TMBENCH("",l=fpzzenc8( in, m, out,0),n); pr(l,n); TMBENCH2("fpzzenc8 ",fpzzdec8( out, m, cpy,0) ,n); break; //Floating point/Integer - case 56: TMBENCH("",l=fpfcmenc8( in, m, out,0),n); pr(l,n); TMBENCH2("fpfcmenc8 ",fpfcmdec8( out, m, cpy,0) ,n); break; - case 57: TMBENCH("",l=fpdfcmenc8( in, m, out,0),n); pr(l,n); TMBENCH2("fpdfcmenc8 ",fpdfcmdec8( out, m, cpy,0) ,n); break; - case 58: TMBENCH("",l=fp2dfcmenc8( in, m, out,0),n); pr(l,n); TMBENCH2("fp2dfcmenc8 ",fp2dfcmdec8( out, m, cpy,0) ,n); break; + case 10: TMBENCH("",l=p4nzenc8( in, m, out) ,n); pr(l,n); TMBENCH2(" 10",p4nzdec8( out, m, cpy) ,n); break; - case 60: TMBENCH("",l=trlec( in, n,out),n); pr(l,n); TMBENCH2("trle ",trled( out,l,cpy, n),n); break; // TurboRLE - case 61: TMBENCH("",l=trlezc( in, n,out,tmp),n); pr(l,n); TMBENCH2("trlez ",trlezd( out,l,cpy, n),n); break; - case 62: TMBENCH("",l=srlec8( in, n,out,RLE8),n); pr(l,n); TMBENCH2("srle8 ",srled8( out,l,cpy, n,RLE8),n);break; - case 63: TMBENCH("",l=srlezc8( in, n,out,tmp,RLE8),n); pr(l,n); TMBENCH2("srlez8 ",srlezd8( out,l,cpy, n,RLE8),n);break; + case 20: TMBENCH("",l=bitnpack8( in, m, out) ,n); pr(l,n); TMBENCH2(" 20",bitnunpack8( out, m, cpy) ,n); break; + case 23: TMBENCH("",l=bitndpack8( in, m, out) ,n); pr(l,n); TMBENCH2(" 23",bitndunpack8( out, m, cpy) ,n); break; + + case 26: TMBENCH("",l=bitnd1pack8( in, m, out) ,n); pr(l,n); TMBENCH2(" 26",bitnd1unpack8( out, m, cpy) ,n); break; + + case 29: TMBENCH("",l=bitnzpack8( in, m, out) ,n); pr(l,n); TMBENCH2(" 29",bitnzunpack8( out, m, cpy) ,n); break; + + case 32: if(dmin==-1) goto end; + TMBENCH("",l=bitnfpack8( in, m, out) ,n); pr(l,n); TMBENCH2(" 32",bitnfunpack8( out, m, cpy) ,n); break; + + case 38: TMBENCH("",l=vsenc8( in, m, out)-out,n); pr(l,n); TMBENCH2(" 38",vsdec8( out, m, cpy) ,n); break; // vsimple : variable simple + case 39: TMBENCH("",l=vszenc8( in, m, out,tmp)-out,n); pr(l,n); TMBENCH2(" 39",vszdec8( out, m, cpy) ,n); break; + + //case 40: TMBENCH("",l=vbenc8( in, m, out)-out,n); pr(l,n); TMBENCH2(" 40",vbdec8( out, m, cpy) ,n); break; // TurboVbyte : variable byte + case 41: TMBENCH("",l=vbzenc8( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 41",vbzdec8( out, m, cpy,0) ,n); break; + //case 42: TMBENCH("",l=vbdenc8( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 42",vbddec8( out, m, cpy,0) ,n); break; + //case 43: TMBENCH("",l=vbd1enc8( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 43",vbd1dec8( out, m, cpy,0) ,n); break; + //case 44: TMBENCH("",l=vbddenc8( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 44",vbdddec8( out, m, cpy,0) ,n); break; + + case 60: TMBENCH("",l=bvzzenc8( in, m, out,0),n); pr(l,n); TMBENCH2(" 60",bvzzdec8( out, m, cpy,0) ,n); break; // bitio + case 61: TMBENCH("",l=bvzenc8( in, m, out,0),n); pr(l,n); TMBENCH2(" 61",bvzdec8( out, m, cpy,0) ,n); break; + case 62: TMBENCH("",l=fpgenc8( in, m, out,0),n); pr(l,n); TMBENCH2(" 62",fpgdec8( out, m, cpy,0) ,n); break; + + case 65: TMBENCH("",l=fpxenc8( in, m, out,0),n); pr(l,n); TMBENCH2(" 65",fpxdec8( out, m, cpy,0) ,n); break; //Floating point/Integer + case 66: TMBENCH("",l=fpfcmenc8( in, m, out,0),n); pr(l,n); TMBENCH2(" 66",fpfcmdec8( out, m, cpy,0) ,n); break; + case 67: TMBENCH("",l=fpdfcmenc8( in, m, out,0),n); pr(l,n); TMBENCH2(" 67",fpdfcmdec8( out, m, cpy,0) ,n); break; + case 68: TMBENCH("",l=fp2dfcmenc8( in, m, out,0),n); pr(l,n); TMBENCH2(" 68",fp2dfcmdec8( out, m, cpy,0) ,n); break; + + case 70: TMBENCH("",l=trlec( in, n,out),n); pr(l,n); TMBENCH2(" 70",trled( out,l,cpy, n),n); break; // TurboRLE + case 71: TMBENCH("",l=trlexc( in, n,out,tmp),n); pr(l,n); TMBENCH2(" 71",trlexd( out,l,cpy, n),n); break; + case 72: TMBENCH("",l=trlezc( in, n,out,tmp),n); pr(l,n); TMBENCH2(" 72",trlezd( out,l,cpy, n),n); break; + case 73: TMBENCH("",l=srlec8( in, n,out,RLE8),n); pr(l,n); TMBENCH2(" 73",srled8( out,l,cpy, n,RLE8),n);break; + case 74: TMBENCH("",l=srlexc8( in, n,out,tmp,RLE8),n); pr(l,n); TMBENCH2(" 74",srlexd8( out,l,cpy, n,RLE8),n);break; + case 75: TMBENCH("",l=srlezc8( in, n,out,tmp,RLE8),n); pr(l,n); TMBENCH2(" 75",srlezd8( out,l,cpy, n,RLE8),n);break; #ifdef USE_LZ #ifdef CODEC1 - case 69: TMBENCH("",l=spdpenc(in,m*(8/8),out,SPDP_BSIZE,lev),n);pr(l,n); TMBENCH2("SPDP ",spdpdec( out, m*(8/8), cpy,SPDP_BSIZE,lev); ,n); break; + case 79: TMBENCH("",l=spdpenc(in,m*(USIZE),out,SPDPSIZE,lev),n);pr(l,n); TMBENCH2(" 79",spdpdec( out, m*(USIZE), cpy,SPDPSIZE,lev); ,n); break; #endif - case 70: TMBENCH("",l=tplzenc( in, n,out,8/8,tmp,lev) ,n); pr(l,n); TMBENCH2("tpbyte+lz ",tplzdec( out,n,cpy,8/8,tmp) ,n); break; - case 71: TMBENCH("",l=tp4lzenc( in, n,out,8/8,tmp,lev) ,n); pr(l,n); TMBENCH2("tpnibble+lz ",tp4lzdec( out,n,cpy,8/8,tmp) ,n); break; - case 72: TMBENCH("",l=tp4lzzenc8(in, n,out, tmp,lev) ,n); pr(l,n); TMBENCH2("tpnibbleZ+lz ",tp4lzzdec8( out,n,cpy, tmp) ,n); break; - case 73: TMBENCH("",l=tp4lzxenc8(in, n,out, tmp,lev) ,n); pr(l,n); TMBENCH2("tpnibbleX+lz ",tp4lzxdec8( out,n,cpy, tmp) ,n); break; - case 74: TMBENCH("",l=lzcomp( in, n,out, lev) ,n); pr(l,n); TMBENCH2("lz ",lzdecomp( out,n,cpy) ,n);break; + case 80: TMBENCH("",l=lzcomp( in,n,out, lev) ,n); pr(l,n); TMBENCH2(" 80",lzdecomp( out,n,cpy) ,n); break; + + case 84: TMBENCH("",l=tp4lzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 84",tp4lzdec( out,n,cpy,USIZE,tmp) ,n); break; + case 85: TMBENCH("",l=tp4lzxenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 85",tp4lzxdec( out,n,cpy,USIZE,tmp) ,n); break; + case 86: TMBENCH("",l=tp4lzzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 86",tp4lzzdec( out,n,cpy,USIZE,tmp) ,n); break; #ifdef BITSHUFFLE - case 75: TMBENCH("",l=bslzenc( in,n,out,8/8,tmp,lev), n); pr(l,n); TMBENCH2("bitshuffle+lz ",bslzdec(out,n,cpy,8/8,tmp), n); break; - #endif + case 87: TMBENCH("",l=bslzenc( in,n,out,USIZE,tmp,lev), n); pr(l,n); TMBENCH2(" 87",bslzdec( out,n,cpy,USIZE,tmp), n); break; + case 88: TMBENCH("",l=bslzxenc( in,n,out,USIZE,tmp,lev), n); pr(l,n); TMBENCH2(" 88",bslzxdec(out,n,cpy,USIZE,tmp), n); break; + case 89: TMBENCH("",l=bslzzenc( in,n,out,USIZE,tmp,lev), n); pr(l,n); TMBENCH2(" 89",bslzzdec(out,n,cpy,USIZE,tmp), n); break; + #endif + + case 90: if(dim2<=0) goto end; { unsigned d2=dim2*(dim3?dim3:1)*(dim4?dim4:1); + TMBENCH("",l=tp2dlzenc( in, dim1,d2, out,USIZE,tmp,lev),dim1*d2 *USIZE); pr(l,dim1*d2 *USIZE); + TMBENCH2(" 90",tp2dlzdec( out,dim1,d2, cpy,USIZE,tmp),dim1*d2 *USIZE);} break; + case 91: if(dim2<=0) goto end; { unsigned d2=dim2*(dim3?dim3:1)*(dim4?dim4:1); + TMBENCH("",l=tp2dlzzenc(in, dim1,d2, out,USIZE,tmp,lev),dim1*d2 *USIZE); pr(l,dim1*d2 *USIZE); + TMBENCH2(" 91",tp2dlzzdec(out,dim1,d2, cpy,USIZE,tmp),dim1*d2 *USIZE);} break; + case 92: if(dim2<=0) goto end; { unsigned d2=dim2*(dim3?dim3:1)*(dim4?dim4:1); + TMBENCH("",l=tp2dlzxenc(in, dim1,d2, out,USIZE,tmp,lev),dim1*d2 *USIZE); pr(l,dim1*d2 *USIZE); + TMBENCH2(" 92",tp2dlzxdec(out,dim1,d2, cpy,USIZE,tmp),dim1*d2 *USIZE);} break; + + case 93: if(dim3<=0) goto end; { unsigned d3=dim3*(dim4?dim4:1); + TMBENCH("",l=tp3dlzenc( in, dim1,dim2,d3, out,USIZE,tmp,lev),dim1*dim2*d3 *USIZE); pr(l,dim1*dim2*d3 *USIZE); + TMBENCH2(" 93",tp3dlzdec( out,dim1,dim2,d3, cpy,USIZE,tmp),dim1*dim2*d3 *USIZE);} break; + case 94: if(dim3<=0) goto end; { unsigned d3=dim3*(dim4?dim4:1); + TMBENCH("",l=tp3dlzzenc(in, dim1,dim2,d3, out,USIZE,tmp,lev),dim1*dim2*d3 *USIZE); pr(l,dim1*dim2*d3 *USIZE); + TMBENCH2(" 94",tp3dlzzdec(out,dim1,dim2,d3, cpy,USIZE,tmp),dim1*dim2*d3 *USIZE);} break; + case 95: if(dim3<=0) goto end; { unsigned d3=dim3*(dim4?dim4:1); + TMBENCH("",l=tp3dlzxenc(in, dim1,dim2,d3, out,USIZE,tmp,lev),dim1*dim2*d3 *USIZE); pr(l,dim1*dim2*d3 *USIZE); + TMBENCH2(" 95",tp3dlzxdec(out,dim1,dim2,d3, cpy,USIZE,tmp),dim1*dim2*d3 *USIZE);} break; + case 96: if(dim4<=0) goto end; { + TMBENCH("",l=tp4dlzenc( in, dim1,dim2,dim3,dim4, out,USIZE,tmp,lev),dim1*dim2*dim3*dim4*USIZE); pr(l,dim1*dim2*dim3*dim4*USIZE); + TMBENCH2(" 96",tp4dlzdec( out,dim1,dim2,dim3,dim4,cpy,USIZE,tmp),dim1*dim2*dim3*dim4*USIZE);} break; + case 97: if(dim4<=0) goto end; { + TMBENCH("",l=tp4dlzzenc(in, dim1,dim2,dim3,dim4, out,USIZE,tmp,lev),dim1*dim2*dim3*dim4*USIZE);pr(l,dim1*dim2*dim3*dim4*USIZE); + TMBENCH2(" 97",tp4dlzzdec(out,dim1,dim2,dim3,dim4,cpy,USIZE,tmp),dim1*dim2*dim3*dim4*USIZE);} break; + case 98: if(dim4<=0) goto end; { + TMBENCH("",l=tp4dlzxenc(in, dim1,dim2,dim3,dim4, out,USIZE,tmp,lev),dim1*dim2*dim3*dim4*USIZE);pr(l,dim1*dim2*dim3*dim4*USIZE); + TMBENCH2(" 98",tp4dlzxdec(out,dim1,dim2,dim3,dim4,cpy,USIZE,tmp),dim1*dim2*dim3*dim4*USIZE);} break; #endif - case ID_MEMCPY: if(!mcpy) return l; TMBENCH( "", libmemcpy( out,in,n) ,n); pr(n,n); TMBENCH2("memcpy ", libmemcpy( cpy,out,n) ,n); break; - default: return l; + + case 107: l = n; TMBENCH("", tpenc( in, n, out,USIZE),n); pr(l,n); TMBENCH2("107", tpdec( out, n,cpy, USIZE),n); break; + case 108: l = n; TMBENCH("", tp4enc(in, n, out,USIZE),n); pr(l,n); TMBENCH2("108", tp4dec(out, n,cpy, USIZE),n); break; + case 109: l = n; TMBENCH("", bitshuffle(in, n, out, USIZE),n); pr(l,n); TMBENCH2("109", bitunshuffle(out, n,cpy, USIZE),n); break; + + case ID_MEMCPY: if(!mcpy) goto end; + TMBENCH( "", libmemcpy(out,in,n) ,n); pr(n,n); TMBENCH2("110", libmemcpy( cpy,out,n) ,n); break; + default: goto end; } { char s[65]; printf("%-30s ", bestr(id,8,s)); } - rc = memcheck(in,m*(8/8),cpy); - if(tmp) free(tmp); + rc = memcheck(in,m*(USIZE),cpy); if(!rc) printf("\t%s\n", inname); + end:if(tmp) free(tmp); return l; } +#undef USIZE +#define USIZE 2 unsigned bench16(unsigned char *in, unsigned n, unsigned char *out, unsigned char *cpy, int id, char *inname, int lev) { - unsigned l,m = n/(16/8),rc = 0, sorted=1; + unsigned l,m = n/(USIZE),rc = 0, d, dmin=-1; uint16_t *p; - char *tmp = NULL; - if((id == 43 || id>=60 && id <= 79) && !(tmp = (unsigned char*)malloc(CBUF(n)))) die(stderr, "malloc error\n"); + char *tmp = NULL; + if(NEEDTMP && !(tmp = (unsigned char*)malloc(CBUF(n)))) die(stderr, "malloc error\n"); - for(p=(uint16_t*)in,l = 1; l < m; l++) if(p[l] < p[l-1]) { sorted = 0; break; } - - memrcpy(cpy,in,n); - switch(id) { - case 1: TMBENCH("",l=p4nenc16( in, m, out) ,n); pr(l,n); TMBENCH2("p4nenc16 ",p4ndec16( out, m, cpy) ,n); break; - case 2: TMBENCH("",l=p4nenc128v16( in, m, out) ,n); pr(l,n); TMBENCH2("p4nenc128v16 ",p4ndec128v16( out, m, cpy) ,n); break; - - case 4: TMBENCH("",l=p4ndenc16( in, m, out) ,n); pr(l,n); TMBENCH2("p4ndenc16 ",p4nddec16( out, m, cpy) ,n); break; - case 5: TMBENCH("",l=p4ndenc128v16( in, m, out) ,n); pr(l,n); TMBENCH2("p4ndenc128v16 ",p4nddec128v16( out, m, cpy) ,n); break; - - case 7: TMBENCH("",l=p4nd1enc16( in, m, out) ,n); pr(l,n); TMBENCH2("p4nd1enc16 ",p4nd1dec16( out, m, cpy) ,n); break; - case 8: TMBENCH("",l=p4nd1enc128v16( in, m, out) ,n); pr(l,n); TMBENCH2("p4nd1enc128v16 ",p4nd1dec128v16( out, m, cpy) ,n); break; - - case 10: TMBENCH("",l=p4nzenc16( in, m, out) ,n); pr(l,n); TMBENCH2("p4nzenc16 ",p4nzdec16( out, m, cpy) ,n); break; - case 11: TMBENCH("",l=p4nzenc128v16( in, m, out) ,n); pr(l,n); TMBENCH2("p4nzenc128v16 ",p4nzdec128v16( out, m, cpy) ,n); break; - //case 13: TMBENCH("",l=p4nsenc16( in, m, out) ,n); pr(l,n); TMBENCH2("p4nsenc16 ",p4nsdec16( out, m, cpy) ,n); break; - - case 20: TMBENCH("",l=bitnpack16( in, m, out) ,n); pr(l,n); TMBENCH2("bitnpack16 ",bitnunpack16( out, m, cpy) ,n); break; - case 21: TMBENCH("",l=bitnpack128v16( in, m, out) ,n); pr(l,n); TMBENCH2("bitnpack128v16 ",bitnunpack128v16( out, m, cpy) ,n); break; - - case 23: TMBENCH("",l=bitndpack16( in, m, out) ,n); pr(l,n); TMBENCH2("bitndpack16 ",bitndunpack16( out, m, cpy) ,n); break; - case 24: TMBENCH("",l=bitndpack128v16( in, m, out) ,n); pr(l,n); TMBENCH2("bitndpack128v16 ",bitndunpack128v16( out, m, cpy) ,n); break; - - case 26: TMBENCH("",l=bitnd1pack16( in, m, out) ,n); pr(l,n); TMBENCH2("bitnd1pack16 ",bitnd1unpack16( out, m, cpy) ,n); break; - case 27: TMBENCH("",l=bitnd1pack128v16(in, m, out) ,n); pr(l,n); TMBENCH2("bitnd1pack128v16",bitnd1unpack128v16(out, m, cpy) ,n); break; + for(p = (uint16_t*)in,l = 1; l < m; l++) //calc mindelta + if(d=(p[l] < p[l-1])) { dmin = -1; break; /*unsorted*/ } + else if(d < dmin) dmin = d; - case 29: TMBENCH("",l=bitnzpack16( in, m, out) ,n); pr(l,n); TMBENCH2("bitnzpack16 ",bitnzunpack16( out, m, cpy) ,n); break; - case 30: TMBENCH("",l=bitnzpack128v16( in, m, out) ,n); pr(l,n); TMBENCH2("bitnzpack128v16 ",bitnzunpack128v16( out, m, cpy) ,n); break; - - case 32: if(!sorted) return 0; TMBENCH("",l=bitnfpack16( in, m, out) ,n); pr(l,n); TMBENCH2("bitnfpack16 ",bitnfunpack16( out, m, cpy) ,n); break; - case 33: if(!sorted) return 0; TMBENCH("",l=bitnfpack128v16( in, m, out) ,n); pr(l,n); TMBENCH2("bitnfpack128v16 ",bitnfunpack128v16( out, m, cpy) ,n); break; + memrcpy(cpy,in,n); l=0; + switch(id) { + case 1: TMBENCH("",l=p4nenc16( in, m, out) ,n); pr(l,n); TMBENCH2(" 1",p4ndec16( out, m, cpy) ,n); break; + case 2: TMBENCH("",l=p4nenc128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 2",p4ndec128v16( out, m, cpy) ,n); break; - case 40: TMBENCH("",l=vbenc16( in, m, out)-out,n); pr(l,n); TMBENCH2("vbenc16 ",vbdec16( out, m, cpy) ,n); break; // TurboVbyte : variable byte - case 41: TMBENCH("",l=vbzenc16( in, m, out,0)-out,n); pr(l,n); TMBENCH2("vbzenc16 ",vbzdec16( out, m, cpy,0) ,n); break; - case 42: TMBENCH("",l=vsenc16( in, m, out)-out,n); pr(l,n); TMBENCH2("vsenc16 ",vsdec16( out, m, cpy) ,n); break; // vsimple : variable simple - case 43: TMBENCH("",l=vszenc16( in, m, out,tmp)-out,n); pr(l,n); TMBENCH2("vszenc16 ",vszdec16( out, m, cpy) ,n); break; - - case 50: TMBENCH("",l=bvzzenc16( in, m, out,0),n); pr(l,n); TMBENCH2("bvzzenc16 ",bvzzdec16( out, m, cpy,0) ,n); break; // bitio - case 51: TMBENCH("",l=bvzenc16( in, m, out,0),n); pr(l,n); TMBENCH2("bvzenc16 ",bvzdec16( out, m, cpy,0) ,n); break; - case 52: TMBENCH("",l=fpgenc16( in, m, out,0),n); pr(l,n); TMBENCH2("fpgenc16 ",fpgdec16( out, m, cpy,0) ,n); break; + case 4: TMBENCH("",l=p4ndenc16( in, m, out) ,n); pr(l,n); TMBENCH2(" 4",p4nddec16( out, m, cpy) ,n); break; + case 5: TMBENCH("",l=p4ndenc128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 5",p4nddec128v16( out, m, cpy) ,n); break; - case 55: TMBENCH("",l=fpzzenc16( in, m, out,0),n); pr(l,n); TMBENCH2("fpzzenc16 ",fpzzdec16( out, m, cpy,0) ,n); break; //Floating point/Integer - case 56: TMBENCH("",l=fpfcmenc16( in, m, out,0),n); pr(l,n); TMBENCH2("fpfcmenc16 ",fpfcmdec16( out, m, cpy,0) ,n); break; - case 57: TMBENCH("",l=fpdfcmenc16( in, m, out,0),n); pr(l,n); TMBENCH2("fpdfcmenc16 ",fpdfcmdec16( out, m, cpy,0) ,n); break; - case 58: TMBENCH("",l=fp2dfcmenc16( in, m, out,0),n); pr(l,n); TMBENCH2("fp2dfcmenc16 ",fp2dfcmdec16( out, m, cpy,0) ,n); break; + case 7: TMBENCH("",l=p4nd1enc16( in, m, out) ,n); pr(l,n); TMBENCH2(" 7",p4nd1dec16( out, m, cpy) ,n); break; + case 8: TMBENCH("",l=p4nd1enc128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 8",p4nd1dec128v16( out, m, cpy) ,n); break; - case 60: TMBENCH("",l=trlec( in, n,out),n); pr(l,n); TMBENCH2("trle ",trled( out,l,cpy, n),n); break; // TurboRLE - case 61: TMBENCH("",l=trlezc( in, n,out,tmp),n); pr(l,n); TMBENCH2("trlez ",trlezd( out,l,cpy, n),n); break; - case 62: TMBENCH("",l=srlec16( in, n,out,RLE16),n); pr(l,n); TMBENCH2("srle16 ",srled16( out,l,cpy, n,RLE16),n);break; - case 63: TMBENCH("",l=srlezc16( in, n,out,tmp,RLE16),n); pr(l,n); TMBENCH2("srlez16 ",srlezd16( out,l,cpy, n,RLE16),n);break; + case 10: TMBENCH("",l=p4nzenc16( in, m, out) ,n); pr(l,n); TMBENCH2(" 10",p4nzdec16( out, m, cpy) ,n); break; + case 11: TMBENCH("",l=p4nzenc128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 11",p4nzdec128v16( out, m, cpy) ,n); break; + + case 13: TMBENCH("",l=p4nzzenc128v16( in, m, out,0),n); pr(l,n); TMBENCH2(" 13",p4nzzdec128v16( out, m, cpy,0) ,n); break; + + case 20: TMBENCH("",l=bitnpack16( in, m, out) ,n); pr(l,n); TMBENCH2(" 20",bitnunpack16( out, m, cpy) ,n); break; + case 21: TMBENCH("",l=bitnpack128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 21",bitnunpack128v16( out, m, cpy) ,n); break; + + case 23: TMBENCH("",l=bitndpack16( in, m, out) ,n); pr(l,n); TMBENCH2(" 23",bitndunpack16( out, m, cpy) ,n); break; + case 24: TMBENCH("",l=bitndpack128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 24",bitndunpack128v16( out, m, cpy) ,n); break; + + case 26: TMBENCH("",l=bitnd1pack16( in, m, out) ,n); pr(l,n); TMBENCH2(" 26",bitnd1unpack16( out, m, cpy) ,n); break; + case 27: TMBENCH("",l=bitnd1pack128v16(in, m, out) ,n); pr(l,n); TMBENCH2(" 27",bitnd1unpack128v16(out, m, cpy) ,n); break; + + case 29: TMBENCH("",l=bitnzpack16( in, m, out) ,n); pr(l,n); TMBENCH2(" 29",bitnzunpack16( out, m, cpy) ,n); break; + case 30: TMBENCH("",l=bitnzpack128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 30",bitnzunpack128v16( out, m, cpy) ,n); break; + + case 32: if(dmin==-1) goto end; + TMBENCH("",l=bitnfpack16( in, m, out) ,n); pr(l,n); TMBENCH2(" 32",bitnfunpack16( out, m, cpy) ,n); break; + case 33: if(dmin==-1) goto end; + TMBENCH("",l=bitnfpack128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 33",bitnfunpack128v16( out, m, cpy) ,n); break; + + case 35: if(dmin==-1) goto end; + TMBENCH("",l=bitns1pack128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 35",bitns1unpack128v16( out, m, cpy) ,n); break; + //case 35: if(dmin==-1 /*|| !dmin*/) goto end; TMBENCH("",l=efanoenc16( in, m, out,0) ,n); pr(l,n); TMBENCH2("efanoenc16 ",efanodec16( out, m, cpy,0) ,n); break; + case 38: TMBENCH("",l=vsenc16( in, m, out)-out,n); pr(l,n); TMBENCH2(" 38",vsdec16( out, m, cpy) ,n); break; // vsimple : variable simple + case 39: TMBENCH("",l=vszenc16( in, m, out,tmp)-out,n); pr(l,n); TMBENCH2(" 39",vszdec16( out, m, cpy) ,n); break; + + case 40: TMBENCH("",l=vbenc16( in, m, out)-out,n); pr(l,n); TMBENCH2(" 40",vbdec16( out, m, cpy) ,n); break; // TurboVbyte : variable byte + case 41: TMBENCH("",l=vbzenc16( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 41",vbzdec16( out, m, cpy,0) ,n); break; + case 42: TMBENCH("",l=vbdenc16( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 42",vbddec16( out, m, cpy,0) ,n); break; + case 43: TMBENCH("",l=vbd1enc16( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 43",vbd1dec16( out, m, cpy,0) ,n); break; + case 44: TMBENCH("",l=vbddenc16( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 44",vbdddec16( out, m, cpy,0) ,n); break; + case 45: TMBENCH("",l=v8enc16( in, m, out)-out,n); pr(l,n); TMBENCH2(" 45",v8dec16( out, m, cpy) ,n); break; // Turbobyte : Group varint + case 46: TMBENCH("",l=v8zenc16( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 46",v8zdec16( out, m, cpy,0) ,n); break; + case 47: TMBENCH("",l=v8denc16( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 47",v8ddec16( out, m, cpy,0) ,n); break; + case 48: TMBENCH("",l=v8d1enc16( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 48",v8d1dec16( out, m, cpy,0) ,n); break; + + case 50: TMBENCH("",l=v8nenc128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 50",v8ndec128v16( out, m, cpy) ,n); break; + case 51: TMBENCH("",l=v8nzenc128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 51",v8nzdec128v16( out, m, cpy) ,n); break; + case 52: TMBENCH("",l=v8ndenc128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 52",v8nddec128v16( out, m, cpy) ,n); break; + case 53: TMBENCH("",l=v8nd1enc128v16( in, m, out) ,n); pr(l,n); TMBENCH2(" 53",v8nd1dec128v16( out, m, cpy) ,n); break; + + case 60: TMBENCH("",l=bvzzenc16( in, m, out,0),n); pr(l,n); TMBENCH2(" 60",bvzzdec16( out, m, cpy,0) ,n); break; // bitio + case 61: TMBENCH("",l=bvzenc16( in, m, out,0),n); pr(l,n); TMBENCH2(" 61",bvzdec16( out, m, cpy,0) ,n); break; + case 62: TMBENCH("",l=fpgenc16( in, m, out,0),n); pr(l,n); TMBENCH2(" 62",fpgdec16( out, m, cpy,0) ,n); break; + + case 65: TMBENCH("",l=fpxenc16( in, m, out,0),n); pr(l,n); TMBENCH2(" 65",fpxdec16( out, m, cpy,0) ,n); break; //Floating point/Integer + case 66: TMBENCH("",l=fpfcmenc16( in, m, out,0),n); pr(l,n); TMBENCH2(" 66",fpfcmdec16( out, m, cpy,0) ,n); break; + case 67: TMBENCH("",l=fpdfcmenc16( in, m, out,0),n); pr(l,n); TMBENCH2(" 67",fpdfcmdec16( out, m, cpy,0) ,n); break; + case 68: TMBENCH("",l=fp2dfcmenc16( in, m, out,0),n); pr(l,n); TMBENCH2(" 68",fp2dfcmdec16( out, m, cpy,0) ,n); break; + + case 70: TMBENCH("",l=trlec( in, n,out),n); pr(l,n); TMBENCH2(" 70",trled( out,l,cpy, n),n); break; // TurboRLE + case 71: TMBENCH("",l=trlexc( in, n,out,tmp),n); pr(l,n); TMBENCH2(" 71",trlexd( out,l,cpy, n),n); break; + case 72: TMBENCH("",l=trlezc( in, n,out,tmp),n); pr(l,n); TMBENCH2(" 72",trlezd( out,l,cpy, n),n); break; + case 73: TMBENCH("",l=srlec16( in, n,out,RLE16),n); pr(l,n); TMBENCH2(" 73",srled16( out,l,cpy, n,RLE16),n);break; + case 74: TMBENCH("",l=srlexc16( in, n,out,tmp,RLE16),n); pr(l,n); TMBENCH2(" 74",srlexd16( out,l,cpy, n,RLE16),n);break; + case 75: TMBENCH("",l=srlezc16( in, n,out,tmp,RLE16),n); pr(l,n); TMBENCH2(" 75",srlezd16( out,l,cpy, n,RLE16),n);break; #ifdef USE_LZ + //case 76: TMBENCH("",l=v8lzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2("TurboByte+lz ", v8lzdec( out,n,cpy,USIZE,tmp) ,n); break; + //case 77: TMBENCH("",l=v8lzxenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2("TurboByteX+lz ", v8lzxdec( out,n,cpy,USIZE,tmp) ,n); break; + //case 78: TMBENCH("",l=v8lzzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2("TurboByteZ+lz ", v8lzzdec( out,n,cpy,USIZE,tmp) ,n); break; #ifdef CODEC1 - case 69: TMBENCH("",l=spdpenc(in,m*(16/8),out,SPDP_BSIZE,lev),n);pr(l,n);TMBENCH2("SPDP ",spdpdec( out, m*(16/8), cpy,SPDP_BSIZE,lev); ,n); break; + case 79: TMBENCH("",l=spdpenc(in,m*(USIZE),out,SPDPSIZE,lev),n);pr(l,n); TMBENCH2(" 79",spdpdec( out, m*(USIZE), cpy,SPDPSIZE,lev); ,n); break; #endif - case 70: TMBENCH("",l=tplzenc( in, n,out,16/8,tmp,lev) ,n); pr(l,n); TMBENCH2("tpbyte+lz ",tplzdec( out,n,cpy,16/8,tmp) ,n); break; - case 71: TMBENCH("",l=tp4lzenc( in, n,out,16/8,tmp,lev) ,n); pr(l,n); TMBENCH2("tpnibble+lz ",tp4lzdec( out,n,cpy,16/8,tmp) ,n); break; - case 72: TMBENCH("",l=tp4lzzenc16(in, n,out, tmp,lev) ,n); pr(l,n); TMBENCH2("tpnibbleZ+lz ",tp4lzzdec16( out,n,cpy, tmp) ,n); break; - case 73: TMBENCH("",l=tp4lzxenc16(in, n,out, tmp,lev) ,n); pr(l,n); TMBENCH2("tpnibbleX+lz ",tp4lzxdec16( out,n,cpy, tmp) ,n); break; - case 74: TMBENCH("",l=lzcomp( in, n,out, lev) ,n); pr(l,n); TMBENCH2("lz ",lzdecomp( out,n,cpy) ,n);break; + case 80: TMBENCH("",l=lzcomp( in,n,out, lev) ,n); pr(l,n); TMBENCH2(" 80",lzdecomp( out,n,cpy) ,n); break; + case 81: TMBENCH("",l=tplzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 81",tplzdec( out,n,cpy,USIZE,tmp) ,n); break; + case 82: TMBENCH("",l=tplzxenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 82",tplzxdec( out,n,cpy,USIZE,tmp) ,n); break; + case 83: TMBENCH("",l=tplzzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 83",tplzzdec( out,n,cpy,USIZE,tmp) ,n); break; + case 84: TMBENCH("",l=tp4lzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 84",tp4lzdec( out,n,cpy,USIZE,tmp) ,n); break; + case 85: TMBENCH("",l=tp4lzxenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 85",tp4lzxdec( out,n,cpy,USIZE,tmp) ,n); break; + case 86: TMBENCH("",l=tp4lzzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 86",tp4lzzdec( out,n,cpy,USIZE,tmp) ,n); break; #ifdef BITSHUFFLE - case 75: TMBENCH("",l=bslzenc( in,n,out,16/8,tmp,lev), n); pr(l,n); TMBENCH2("bitshuffle+lz ",bslzdec(out,n,cpy,16/8,tmp), n); break; - #endif + case 87: TMBENCH("",l=bslzenc( in,n,out,USIZE,tmp,lev), n); pr(l,n); TMBENCH2(" 87",bslzdec( out,n,cpy,USIZE,tmp), n); break; + case 88: TMBENCH("",l=bslzxenc( in,n,out,USIZE,tmp,lev), n); pr(l,n); TMBENCH2(" 88",bslzxdec(out,n,cpy,USIZE,tmp), n); break; + case 89: TMBENCH("",l=bslzzenc( in,n,out,USIZE,tmp,lev), n); pr(l,n); TMBENCH2(" 89",bslzzdec(out,n,cpy,USIZE,tmp), n); break; + #endif + + case 90: if(dim2<=0) goto end; { unsigned d2=dim2*(dim3?dim3:1)*(dim4?dim4:1); + TMBENCH("",l=tp2dlzenc( in, dim1,d2, out,USIZE,tmp,lev),dim1*d2 *USIZE); pr(l,dim1*d2 *USIZE); + TMBENCH2(" 90",tp2dlzdec( out,dim1,d2, cpy,USIZE,tmp),dim1*d2 *USIZE);} break; + case 91: if(dim2<=0) goto end; { unsigned d2=dim2*(dim3?dim3:1)*(dim4?dim4:1); + TMBENCH("",l=tp2dlzzenc(in, dim1,d2, out,USIZE,tmp,lev),dim1*d2 *USIZE); pr(l,dim1*d2 *USIZE); + TMBENCH2(" 91",tp2dlzzdec(out,dim1,d2, cpy,USIZE,tmp),dim1*d2 *USIZE);} break; + case 92: if(dim2<=0) goto end; { unsigned d2=dim2*(dim3?dim3:1)*(dim4?dim4:1); + TMBENCH("",l=tp2dlzxenc(in, dim1,d2, out,USIZE,tmp,lev),dim1*d2 *USIZE); pr(l,dim1*d2 *USIZE); + TMBENCH2(" 92",tp2dlzxdec(out,dim1,d2, cpy,USIZE,tmp),dim1*d2 *USIZE);} break; + + case 93: if(dim3<=0) goto end; { unsigned d3=dim3*(dim4?dim4:1); + TMBENCH("",l=tp3dlzenc( in, dim1,dim2,d3, out,USIZE,tmp,lev),dim1*dim2*d3 *USIZE); pr(l,dim1*dim2*d3 *USIZE); + TMBENCH2(" 93",tp3dlzdec( out,dim1,dim2,d3, cpy,USIZE,tmp),dim1*dim2*d3 *USIZE);} break; + case 94: if(dim3<=0) goto end; { unsigned d3=dim3*(dim4?dim4:1); + TMBENCH("",l=tp3dlzzenc(in, dim1,dim2,d3, out,USIZE,tmp,lev),dim1*dim2*d3 *USIZE); pr(l,dim1*dim2*d3 *USIZE); + TMBENCH2(" 94",tp3dlzzdec(out,dim1,dim2,d3, cpy,USIZE,tmp),dim1*dim2*d3 *USIZE);} break; + case 95: if(dim3<=0) goto end; { unsigned d3=dim3*(dim4?dim4:1); + TMBENCH("",l=tp3dlzxenc(in, dim1,dim2,d3, out,USIZE,tmp,lev),dim1*dim2*d3 *USIZE); pr(l,dim1*dim2*d3 *USIZE); + TMBENCH2(" 95",tp3dlzxdec(out,dim1,dim2,d3, cpy,USIZE,tmp),dim1*dim2*d3 *USIZE);} break; + case 96: if(dim4<=0) goto end; { + TMBENCH("",l=tp4dlzenc( in, dim1,dim2,dim3,dim4, out,USIZE,tmp,lev),dim1*dim2*dim3*dim4*USIZE); pr(l,dim1*dim2*dim3*dim4*USIZE); + TMBENCH2(" 96",tp4dlzdec( out,dim1,dim2,dim3,dim4,cpy,USIZE,tmp),dim1*dim2*dim3*dim4*USIZE);} break; + case 97: if(dim4<=0) goto end; { + TMBENCH("",l=tp4dlzzenc(in, dim1,dim2,dim3,dim4, out,USIZE,tmp,lev),dim1*dim2*dim3*dim4*USIZE);pr(l,dim1*dim2*dim3*dim4*USIZE); + TMBENCH2(" 97",tp4dlzzdec(out,dim1,dim2,dim3,dim4,cpy,USIZE,tmp),dim1*dim2*dim3*dim4*USIZE);} break; + case 98: if(dim4<=0) goto end; { + TMBENCH("",l=tp4dlzxenc(in, dim1,dim2,dim3,dim4, out,USIZE,tmp,lev),dim1*dim2*dim3*dim4*USIZE);pr(l,dim1*dim2*dim3*dim4*USIZE); + TMBENCH2(" 98",tp4dlzxdec(out,dim1,dim2,dim3,dim4,cpy,USIZE,tmp),dim1*dim2*dim3*dim4*USIZE);} break; #endif - case ID_MEMCPY: if(!mcpy) return l; TMBENCH( "", libmemcpy( out,in,n) ,n); pr(n,n); TMBENCH2("memcpy ", libmemcpy( cpy,out,n) ,n); break; - default: return l; + + case 107: l = n; TMBENCH("", tpenc( in, n, out,USIZE),n); pr(l,n); TMBENCH2("107", tpdec( out, n,cpy, USIZE),n); break; + case 108: l = n; TMBENCH("", tp4enc(in, n, out,USIZE),n); pr(l,n); TMBENCH2("108", tp4dec(out, n,cpy, USIZE),n); break; + case 109: l = n; TMBENCH("", bitshuffle(in, n, out, USIZE),n); pr(l,n); TMBENCH2("109", bitunshuffle(out, n,cpy, USIZE),n); break; + + case ID_MEMCPY: if(!mcpy) goto end; + TMBENCH( "", libmemcpy(out,in,n) ,n); pr(n,n); TMBENCH2("110", libmemcpy( cpy,out,n) ,n); break; + + default: goto end; } { char s[65]; printf("%-30s ", bestr(id,16,s)); } - if(cpy) rc = memcheck(in,m*(16/8),cpy); - if(tmp) free(tmp); + if(cpy) rc = memcheck(in,m*(USIZE),cpy); if(!rc) printf("\t%s\n", inname); + end:if(tmp) free(tmp); return l; } +#undef USIZE +#define USIZE 4 unsigned bench32(unsigned char *in, unsigned n, unsigned char *out, unsigned char *cpy, int id, char *inname, int lev) { - unsigned l,m = n/(32/8),rc = 0, d, dmin=-1; + unsigned l,m = n/(USIZE),rc = 0, d, dmin=-1; uint32_t *p; - char *tmp = NULL; - if((id == 43 || id>=60 && id <= 79) && !(tmp = (unsigned char*)malloc(CBUF(n)))) die(stderr, "malloc error\n"); + char *tmp = NULL; + if(NEEDTMP && !(tmp = (unsigned char*)malloc(CBUF(n)))) die(stderr, "malloc error\n"); - for(p=(uint32_t*)in,l = 1; l < m; l++) if(d=(p[l] < p[l-1])) { dmin = -1; break; } else if(d < dmin) dmin = d; + for(p = (uint32_t*)in,l = 1; l < m; l++) //calc mindelta + if(d=(p[l] < p[l-1])) { dmin = -1; break; /*unsorted*/ } + else if(d < dmin) dmin = d; memrcpy(cpy,in,n); switch(id) { - case 1: TMBENCH("",l=p4nenc32( in, m, out) ,n); pr(l,n); TMBENCH2("p4nenc32 ",p4ndec32( out, m, cpy) ,n); break; - case 2: TMBENCH("",l=p4nenc128v32( in, m, out) ,n); pr(l,n); TMBENCH2("p4nenc128v32 ",p4ndec128v32( out, m, cpy) ,n); break; + case 1: TMBENCH("",l=p4nenc32( in, m, out) ,n); pr(l,n); TMBENCH2(" 1",p4ndec32( out, m, cpy) ,n); break; + case 2: TMBENCH("",l=p4nenc128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 2",p4ndec128v32( out, m, cpy) ,n); break; #if defined(__AVX2__) && defined(USE_AVX2) - case 3: TMBENCH("",l=p4nenc256v32( in, m, out) ,n); pr(l,n); TMBENCH2("p4nenc256v32 ",p4ndec256v32( out, m, cpy) ,n); break; - #endif - - case 4: TMBENCH("",l=p4ndenc32( in, m, out) ,n); pr(l,n); TMBENCH2("p4ndenc32 ",p4nddec32( out, m, cpy) ,n); break; - case 5: TMBENCH("",l=p4ndenc128v32( in, m, out) ,n); pr(l,n); TMBENCH2("p4ndenc128v32 ",p4nddec128v32( out, m, cpy) ,n); break; + case 3: TMBENCH("",l=p4nenc256v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 3",p4ndec256v32( out, m, cpy) ,n); break; + #endif + case 4: TMBENCH("",l=p4ndenc32( in, m, out) ,n); pr(l,n); TMBENCH2(" 4",p4nddec32( out, m, cpy) ,n); break; + case 5: TMBENCH("",l=p4ndenc128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 5",p4nddec128v32( out, m, cpy) ,n); break; #if defined(__AVX2__) && defined(USE_AVX2) - case 6: TMBENCH("",l=p4ndenc256v32( in, m, out) ,n); pr(l,n); TMBENCH2("p4ndenc256v32 ", p4nddec256v32( out, m, cpy) ,n); break; - #endif - - case 7: TMBENCH("",l=p4nd1enc32( in, m, out) ,n); pr(l,n); TMBENCH2("p4nd1enc32 ",p4nd1dec32( out, m, cpy) ,n); break; - case 8: TMBENCH("",l=p4nd1enc128v32( in, m, out) ,n); pr(l,n); TMBENCH2("p4nd1enc128v32 ",p4nd1dec128v32( out, m, cpy) ,n); break; + case 6: TMBENCH("",l=p4ndenc256v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 6", p4nddec256v32( out, m, cpy) ,n); break; + #endif + case 7: TMBENCH("",l=p4nd1enc32( in, m, out) ,n); pr(l,n); TMBENCH2(" 7",p4nd1dec32( out, m, cpy) ,n); break; + case 8: TMBENCH("",l=p4nd1enc128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 8",p4nd1dec128v32( out, m, cpy) ,n); break; #if defined(__AVX2__) && defined(USE_AVX2) - case 9: TMBENCH("",l=p4nd1enc256v32( in, m, out) ,n); pr(l,n); TMBENCH2("p4nd1enc256v32 ",p4nd1dec256v32( out, m, cpy) ,n); break; + case 9: TMBENCH("",l=p4nd1enc256v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 9",p4nd1dec256v32( out, m, cpy) ,n); break; #endif - case 10: TMBENCH("",l=p4nzenc32( in, m, out) ,n); pr(l,n); TMBENCH2("p4nzenc32 ",p4nzdec32( out, m, cpy) ,n); break; - case 11: TMBENCH("",l=p4nzenc128v32( in, m, out) ,n); pr(l,n); TMBENCH2("p4nzenc128v32 ",p4nzdec128v32( out, m, cpy) ,n); break; + case 10: TMBENCH("",l=p4nzenc32( in, m, out) ,n); pr(l,n); TMBENCH2(" 10",p4nzdec32( out, m, cpy) ,n); break; + case 11: TMBENCH("",l=p4nzenc128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 11",p4nzdec128v32( out, m, cpy) ,n); break; #if defined(__AVX2__) && defined(USE_AVX2) - case 12: TMBENCH("",l=p4nzenc256v32( in, m, out) ,n); pr(l,n); TMBENCH2("p4nzenc256v32 ",p4nzdec256v32( out, m, cpy) ,n); break; + case 12: TMBENCH("",l=p4nzenc256v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 12",p4nzdec256v32( out, m, cpy) ,n); break; #endif - //case 13: TMBENCH("",l=p4nsenc32( in, m, out) ,n); pr(l,n); TMBENCH2("p4nsenc32 ",p4nsdec32( out, m, cpy) ,n); break; - - case 20: TMBENCH("",l=bitnpack32( in, m, out) ,n); pr(l,n); TMBENCH2("bitnpack32 ",bitnunpack32( out, m, cpy) ,n); break; - case 21: TMBENCH("",l=bitnpack128v32( in, m, out) ,n); pr(l,n); TMBENCH2("bitnpack128v32 ",bitnunpack128v32( out, m, cpy) ,n); break; + case 13: TMBENCH("",l=p4nzzenc128v32( in, m, out,0),n); pr(l,n); TMBENCH2(" 13",p4nzzdec128v32( out, m, cpy,0) ,n); break; + //case 13: TMBENCH("",l=p4nsenc32( in, m, out) ,n); pr(l,n); TMBENCH2("",p4nsdec32( out, m, cpy) ,n); break; + + case 20: TMBENCH("",l=bitnpack32( in, m, out) ,n); pr(l,n); TMBENCH2(" 20",bitnunpack32( out, m, cpy) ,n); break; + case 21: TMBENCH("",l=bitnpack128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 21",bitnunpack128v32( out, m, cpy) ,n); break; #if defined(__AVX2__) && defined(USE_AVX2) - case 22: TMBENCH("",l=bitnpack256v32( in, m, out) ,n); pr(l,n); TMBENCH2("bitnpack256v32 ",bitnunpack256v32( out, m, cpy) ,n); break; + case 22: TMBENCH("",l=bitnpack256v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 22",bitnunpack256v32( out, m, cpy) ,n); break; + #endif + case 23: TMBENCH("",l=bitndpack32( in, m, out) ,n); pr(l,n); TMBENCH2(" 23",bitndunpack32( out, m, cpy) ,n); break; + case 24: TMBENCH("",l=bitndpack128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 24",bitndunpack128v32( out, m, cpy) ,n); break; + #if defined(__AVX2__) && defined(USE_AVX2) + case 25: TMBENCH("",l=bitndpack256v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 25",bitndunpack256v32( out, m, cpy) ,n); break; + #endif + case 26: TMBENCH("",l=bitnd1pack32( in, m, out) ,n); pr(l,n); TMBENCH2(" 26",bitnd1unpack32( out, m, cpy) ,n); break; + case 27: TMBENCH("",l=bitnd1pack128v32(in, m, out) ,n); pr(l,n); TMBENCH2(" 27",bitnd1unpack128v32(out, m, cpy) ,n); break; + #if defined(__AVX2__) && defined(USE_AVX2) + case 28: TMBENCH("",l=bitnd1pack256v32(in, m, out) ,n); pr(l,n); TMBENCH2(" 28",bitnd1unpack256v32(out, m, cpy) ,n); break; #endif - - case 23: TMBENCH("",l=bitndpack32( in, m, out) ,n); pr(l,n); TMBENCH2("bitndpack32 ",bitndunpack32( out, m, cpy) ,n); break; - case 24: TMBENCH("",l=bitndpack128v32( in, m, out) ,n); pr(l,n); TMBENCH2("bitndpack128v32 ",bitndunpack128v32( out, m, cpy) ,n); break; + case 29: TMBENCH("",l=bitnzpack32( in, m, out) ,n); pr(l,n); TMBENCH2(" 29",bitnzunpack32( out, m, cpy) ,n); break; + case 30: TMBENCH("",l=bitnzpack128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 30",bitnzunpack128v32( out, m, cpy) ,n); break; #if defined(__AVX2__) && defined(USE_AVX2) - case 25: TMBENCH("",l=bitndpack256v32( in, m, out) ,n); pr(l,n); TMBENCH2("bitndpack256v32 ",bitndunpack256v32( out, m, cpy) ,n); break; - #endif - - case 26: TMBENCH("",l=bitnd1pack32( in, m, out) ,n); pr(l,n); TMBENCH2("bitnd1pack32 ",bitnd1unpack32( out, m, cpy) ,n); break; - case 27: TMBENCH("",l=bitnd1pack128v32(in, m, out) ,n); pr(l,n); TMBENCH2("bitnd1pack128v32",bitnd1unpack128v32(out, m, cpy) ,n); break; - #if defined(__AVX2__) && defined(USE_AVX2) - case 28: TMBENCH("",l=bitnd1pack256v32(in, m, out) ,n); pr(l,n); TMBENCH2("bitnd1pack256v32",bitnd1unpack256v32(out, m, cpy) ,n); break; - #endif - - case 29: TMBENCH("",l=bitnzpack32( in, m, out) ,n); pr(l,n); TMBENCH2("bitnzpack32 ",bitnzunpack32( out, m, cpy) ,n); break; - case 30: TMBENCH("",l=bitnzpack128v32( in, m, out) ,n); pr(l,n); TMBENCH2("bitnzpack128v32 ",bitnzunpack128v32( out, m, cpy) ,n); break; - #if defined(__AVX2__) && defined(USE_AVX2) - case 31: TMBENCH("",l=bitnzpack256v32( in, m, out) ,n); pr(l,n); TMBENCH2("bitnzpack256v32 ",bitnzunpack256v32( out, m, cpy) ,n); break; + case 31: TMBENCH("",l=bitnzpack256v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 31",bitnzunpack256v32( out, m, cpy) ,n); break; #endif - - case 32: if(dmin==-1) return 0; TMBENCH("",l=bitnfpack32( in, m, out) ,n); pr(l,n); TMBENCH2("bitnfpack32 ",bitnfunpack32( out, m, cpy) ,n); break; - case 33: if(dmin==-1) return 0; TMBENCH("",l=bitnfpack128v32( in, m, out) ,n); pr(l,n); TMBENCH2("bitnfpack128v32 ",bitnfunpack128v32( out, m, cpy) ,n); break; + case 32: if(dmin==-1) goto end; + TMBENCH("",l=bitnfpack32( in, m, out) ,n); pr(l,n); TMBENCH2(" 32",bitnfunpack32( out, m, cpy) ,n); break; + case 33: if(dmin==-1) goto end; + TMBENCH("",l=bitnfpack128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 33",bitnfunpack128v32( out, m, cpy) ,n); break; #if defined(__AVX2__) && defined(USE_AVX2) - case 34: if(dmin==-1) return 0; TMBENCH("",l=bitnfpack256v32( in, m, out) ,n); pr(l,n); TMBENCH2("bitnfpack256v32 ",bitnfunpack256v32( out, m, cpy) ,n); break; + case 34: if(dmin==-1) goto end; + TMBENCH("",l=bitnfpack256v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 34",bitnfunpack256v32( out, m, cpy) ,n); break; #endif - //case 35: if(dmin==-1 /*|| !dmin*/) return 0; TMBENCH("",l=efanoenc32( in, m, out,0) ,n); pr(l,n); TMBENCH2("efanoenc32 ",efanodec32( out, m, cpy,0) ,n); break; + case 35: if(dmin==-1) goto end; + TMBENCH("",l=bitns1pack128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 35",bitns1unpack128v32( out, m, cpy) ,n); break; + //case 35: if(dmin==-1 /*|| !dmin*/) goto end; TMBENCH("",l=efanoenc32( in, m, out,0) ,n); pr(l,n); TMBENCH2("efanoenc32 ",efanodec32( out, m, cpy,0) ,n); break; + case 38: TMBENCH("",l=vsenc32( in, m, out)-out,n); pr(l,n); TMBENCH2(" 38",vsdec32( out, m, cpy) ,n); break; // vsimple : variable simple + case 39: TMBENCH("",l=vszenc32( in, m, out,tmp)-out,n); pr(l,n); TMBENCH2(" 39",vszdec32( out, m, cpy) ,n); break; - case 40: TMBENCH("",l=vbenc32( in, m, out)-out,n); pr(l,n); TMBENCH2("vbenc32 ",vbdec32( out, m, cpy) ,n); break; // TurboVbyte : variable byte - case 41: TMBENCH("",l=vbzenc32( in, m, out,0)-out,n); pr(l,n); TMBENCH2("vbzenc32 ",vbzdec32( out, m, cpy,0) ,n); break; - case 42: TMBENCH("",l=vsenc32( in, m, out)-out,n); pr(l,n); TMBENCH2("vsenc32 ",vsdec32( out, m, cpy) ,n); break; // vsimple : variable simple - case 43: TMBENCH("",l=vszenc32( in, m, out,tmp)-out,n); pr(l,n); TMBENCH2("vszenc32 ",vszdec32( out, m, cpy) ,n); break; - case 50: TMBENCH("",l=bvzzenc32( in, m, out,0),n); pr(l,n); TMBENCH2("bvzzenc32 ",bvzzdec32( out, m, cpy,0) ,n); break; // bitio - case 51: TMBENCH("",l=bvzenc32( in, m, out,0),n); pr(l,n); TMBENCH2("bvzenc32 ",bvzdec32( out, m, cpy,0) ,n); break; - case 52: TMBENCH("",l=fpgenc32( in, m, out,0),n); pr(l,n); TMBENCH2("fpgenc32 ",fpgdec32( out, m, cpy,0) ,n); break; + case 40: TMBENCH("",l=vbenc32( in, m, out)-out,n); pr(l,n); TMBENCH2(" 40",vbdec32( out, m, cpy) ,n); break; // TurboVbyte : variable byte + case 41: TMBENCH("",l=vbzenc32( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 41",vbzdec32( out, m, cpy,0) ,n); break; + case 42: TMBENCH("",l=vbdenc32( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 42",vbddec32( out, m, cpy,0) ,n); break; + case 43: TMBENCH("",l=vbd1enc32( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 43",vbd1dec32( out, m, cpy,0) ,n); break; + case 44: TMBENCH("",l=vbddenc32( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 44",vbdddec32( out, m, cpy,0) ,n); break; + case 45: TMBENCH("",l=v8enc32( in, m, out)-out,n); pr(l,n); TMBENCH2(" 45",v8dec32( out, m, cpy) ,n); break; // Turbobyte : Group varint + case 46: TMBENCH("",l=v8zenc32( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 46",v8zdec32( out, m, cpy,0) ,n); break; + case 47: TMBENCH("",l=v8denc32( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 47",v8ddec32( out, m, cpy,0) ,n); break; + case 48: TMBENCH("",l=v8d1enc32( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 48",v8d1dec32( out, m, cpy,0) ,n); break; + + case 50: TMBENCH("",l=v8nenc128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 50",v8ndec128v32( out, m, cpy) ,n); break; + case 51: TMBENCH("",l=v8nzenc128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 51",v8nzdec128v32( out, m, cpy) ,n); break; + case 52: TMBENCH("",l=v8ndenc128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 52",v8nddec128v32( out, m, cpy) ,n); break; + case 53: TMBENCH("",l=v8nd1enc128v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 53",v8nd1dec128v32( out, m, cpy) ,n); break; + #if defined(__AVX2__) && defined(USE_AVX2) + case 55: TMBENCH("",l=v8nenc256v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 55",v8ndec256v32( out, m, cpy) ,n); break; + case 56: TMBENCH("",l=v8nzenc256v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 56",v8nzdec256v32( out, m, cpy) ,n); break; + case 57: TMBENCH("",l=v8ndenc256v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 57",v8nddec256v32( out, m, cpy) ,n); break; + case 58: TMBENCH("",l=v8nd1enc256v32( in, m, out) ,n); pr(l,n); TMBENCH2(" 58",v8nd1dec256v32( out, m, cpy) ,n); break; + #endif + + case 60: TMBENCH("",l=bvzzenc32( in, m, out,0),n); pr(l,n); TMBENCH2(" 60",bvzzdec32( out, m, cpy,0) ,n); break; // bitio + case 61: TMBENCH("",l=bvzenc32( in, m, out,0),n); pr(l,n); TMBENCH2(" 61",bvzdec32( out, m, cpy,0) ,n); break; + case 62: TMBENCH("",l=fpgenc32( in, m, out,0),n); pr(l,n); TMBENCH2(" 62",fpgdec32( out, m, cpy,0) ,n); break; + + case 65: TMBENCH("",l=fpxenc32( in, m, out,0),n); pr(l,n); TMBENCH2(" 65",fpxdec32( out, m, cpy,0) ,n); break; //Floating point/Integer + case 66: TMBENCH("",l=fpfcmenc32( in, m, out,0),n); pr(l,n); TMBENCH2(" 66",fpfcmdec32( out, m, cpy,0) ,n); break; + case 67: TMBENCH("",l=fpdfcmenc32( in, m, out,0),n); pr(l,n); TMBENCH2(" 67",fpdfcmdec32( out, m, cpy,0) ,n); break; + case 68: TMBENCH("",l=fp2dfcmenc32( in, m, out,0),n); pr(l,n); TMBENCH2(" 68",fp2dfcmdec32( out, m, cpy,0) ,n); break; - case 55: TMBENCH("",l=fpzzenc32( in, m, out,0),n); pr(l,n); TMBENCH2("fpzzenc32 ",fpzzdec32( out, m, cpy,0) ,n); break; //Floating point/Integer - case 56: TMBENCH("",l=fpfcmenc32( in, m, out,0),n); pr(l,n); TMBENCH2("fpfcmenc32 ",fpfcmdec32( out, m, cpy,0) ,n); break; - case 57: TMBENCH("",l=fpdfcmenc32( in, m, out,0),n); pr(l,n); TMBENCH2("fpdfcmenc32 ",fpdfcmdec32( out, m, cpy,0) ,n); break; - case 58: TMBENCH("",l=fp2dfcmenc32( in, m, out,0),n); pr(l,n); TMBENCH2("fp2dfcmenc32 ",fp2dfcmdec32( out, m, cpy,0) ,n); break; - - case 60: TMBENCH("",l=trlec( in, n,out),n); pr(l,n); TMBENCH2("trle ",trled( out,l,cpy, n),n); break; // TurboRLE - case 61: TMBENCH("",l=trlezc( in, n,out,tmp),n); pr(l,n); TMBENCH2("trlez ",trlezd( out,l,cpy, n),n); break; - case 62: TMBENCH("",l=srlec32( in, n,out,RLE32),n); pr(l,n); TMBENCH2("srle32 ",srled32( out,l,cpy, n,RLE32),n);break; - case 63: TMBENCH("",l=srlezc32( in, n,out,tmp,RLE32),n); pr(l,n); TMBENCH2("srlez32 ",srlezd32( out,l,cpy, n,RLE32),n);break; + case 70: TMBENCH("",l=trlec( in, n,out),n); pr(l,n); TMBENCH2(" 70",trled( out,l,cpy, n),n); break; // TurboRLE + case 71: TMBENCH("",l=trlexc( in, n,out,tmp),n); pr(l,n); TMBENCH2(" 71",trlexd( out,l,cpy, n),n); break; + case 72: TMBENCH("",l=trlezc( in, n,out,tmp),n); pr(l,n); TMBENCH2(" 72",trlezd( out,l,cpy, n),n); break; + case 73: TMBENCH("",l=srlec32( in, n,out,RLE32),n); pr(l,n); TMBENCH2(" 73",srled32( out,l,cpy, n,RLE32),n);break; + case 74: TMBENCH("",l=srlexc32( in, n,out,tmp,RLE32),n); pr(l,n); TMBENCH2(" 74",srlexd32( out,l,cpy, n,RLE32),n);break; + case 75: TMBENCH("",l=srlezc32( in, n,out,tmp,RLE32),n); pr(l,n); TMBENCH2(" 75",srlezd32( out,l,cpy, n,RLE32),n);break; #ifdef USE_LZ + //case 76: l = n; TMBENCH("", ictste32( in, n,out),n); pr(l,n); TMBENCH2("120", ictstd32( out,n,cpy),n); break; + //case 76: TMBENCH("",l=v8lzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2("TurboByte+lz ", v8lzdec( out,n,cpy,USIZE,tmp) ,n); break; + //case 77: TMBENCH("",l=v8lzxenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2("TurboByteX+lz ", v8lzxdec( out,n,cpy,USIZE,tmp) ,n); break; + //case 78: TMBENCH("",l=v8lzzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2("TurboByteZ+lz ", v8lzzdec( out,n,cpy,USIZE,tmp) ,n); break; #ifdef CODEC1 - case 69: TMBENCH("",l=spdpenc(in,m*(32/8),out,SPDP_BSIZE,lev),n);pr(l,n);TMBENCH2("SPDP ",spdpdec( out, m*(32/8), cpy,SPDP_BSIZE,lev); ,n); break; + case 79: TMBENCH("",l=spdpenc(in,m*(USIZE),out,SPDPSIZE,lev),n);pr(l,n); TMBENCH2(" 79",spdpdec( out, m*(USIZE), cpy,SPDPSIZE,lev); ,n); break; #endif - case 70: TMBENCH("",l=tplzenc( in, n,out,32/8,tmp,lev) ,n); pr(l,n); TMBENCH2("tpbyte+lz ",tplzdec( out,n,cpy,32/8,tmp) ,n); break; - case 71: TMBENCH("",l=tp4lzenc( in, n,out,32/8,tmp,lev) ,n); pr(l,n); TMBENCH2("tpnibble+lz ",tp4lzdec( out,n,cpy,32/8,tmp) ,n); break; - case 72: TMBENCH("",l=tp4lzzenc32(in, n,out, tmp,lev) ,n); pr(l,n); TMBENCH2("tpnibbleZ+lz ",tp4lzzdec32( out,n,cpy, tmp) ,n); break; - case 73: TMBENCH("",l=tp4lzxenc32(in, n,out, tmp,lev) ,n); pr(l,n); TMBENCH2("tpnibbleX+lz ",tp4lzxdec32( out,n,cpy, tmp) ,n); break; - case 74: TMBENCH("",l=lzcomp( in, n,out, lev) ,n); pr(l,n); TMBENCH2("lz ",lzdecomp( out,n,cpy) ,n);break; + case 80: TMBENCH("",l=lzcomp( in,n,out, lev) ,n); pr(l,n); TMBENCH2(" 80",lzdecomp( out,n,cpy) ,n); break; + case 81: TMBENCH("",l=tplzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 81",tplzdec( out,n,cpy,USIZE,tmp) ,n); break; + case 82: TMBENCH("",l=tplzxenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 82",tplzxdec( out,n,cpy,USIZE,tmp) ,n); break; + case 83: TMBENCH("",l=tplzzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 83",tplzzdec( out,n,cpy,USIZE,tmp) ,n); break; + case 84: TMBENCH("",l=tp4lzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 84",tp4lzdec( out,n,cpy,USIZE,tmp) ,n); break; + case 85: TMBENCH("",l=tp4lzxenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 85",tp4lzxdec( out,n,cpy,USIZE,tmp) ,n); break; + case 86: TMBENCH("",l=tp4lzzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 86",tp4lzzdec( out,n,cpy,USIZE,tmp) ,n); break; #ifdef BITSHUFFLE - case 75: TMBENCH("",l=bslzenc( in,n,out,32/8,tmp,lev), n); pr(l,n); TMBENCH2("bitshuffle+lz ",bslzdec(out,n,cpy,32/8,tmp), n); break; - #endif + case 87: TMBENCH("",l=bslzenc( in,n,out,USIZE,tmp,lev), n); pr(l,n); TMBENCH2(" 87",bslzdec( out,n,cpy,USIZE,tmp), n); break; + case 88: TMBENCH("",l=bslzxenc( in,n,out,USIZE,tmp,lev), n); pr(l,n); TMBENCH2(" 88",bslzxdec(out,n,cpy,USIZE,tmp), n); break; + case 89: TMBENCH("",l=bslzzenc( in,n,out,USIZE,tmp,lev), n); pr(l,n); TMBENCH2(" 89",bslzzdec(out,n,cpy,USIZE,tmp), n); break; + #endif + + case 90: if(dim2<=0) goto end; { unsigned d2=dim2*(dim3?dim3:1)*(dim4?dim4:1); + TMBENCH("",l=tp2dlzenc( in, dim1,d2, out,USIZE,tmp,lev),dim1*d2 *USIZE); pr(l,dim1*d2 *USIZE); + TMBENCH2(" 90",tp2dlzdec( out,dim1,d2, cpy,USIZE,tmp),dim1*d2 *USIZE);} break; + case 91: if(dim2<=0) goto end; { unsigned d2=dim2*(dim3?dim3:1)*(dim4?dim4:1); + TMBENCH("",l=tp2dlzzenc(in, dim1,d2, out,USIZE,tmp,lev),dim1*d2 *USIZE); pr(l,dim1*d2 *USIZE); + TMBENCH2(" 91",tp2dlzzdec(out,dim1,d2, cpy,USIZE,tmp),dim1*d2 *USIZE);} break; + case 92: if(dim2<=0) goto end; { unsigned d2=dim2*(dim3?dim3:1)*(dim4?dim4:1); + TMBENCH("",l=tp2dlzxenc(in, dim1,d2, out,USIZE,tmp,lev),dim1*d2 *USIZE); pr(l,dim1*d2 *USIZE); + TMBENCH2(" 92",tp2dlzxdec(out,dim1,d2, cpy,USIZE,tmp),dim1*d2 *USIZE);} break; + + case 93: if(dim3<=0) goto end; { unsigned d3=dim3*(dim4?dim4:1); + TMBENCH("",l=tp3dlzenc( in, dim1,dim2,d3, out,USIZE,tmp,lev),dim1*dim2*d3 *USIZE); pr(l,dim1*dim2*d3 *USIZE); + TMBENCH2(" 93",tp3dlzdec( out,dim1,dim2,d3, cpy,USIZE,tmp),dim1*dim2*d3 *USIZE);} break; + case 94: if(dim3<=0) goto end; { unsigned d3=dim3*(dim4?dim4:1); + TMBENCH("",l=tp3dlzzenc(in, dim1,dim2,d3, out,USIZE,tmp,lev),dim1*dim2*d3 *USIZE); pr(l,dim1*dim2*d3 *USIZE); + TMBENCH2(" 94",tp3dlzzdec(out,dim1,dim2,d3, cpy,USIZE,tmp),dim1*dim2*d3 *USIZE);} break; + case 95: if(dim3<=0) goto end; { unsigned d3=dim3*(dim4?dim4:1); + TMBENCH("",l=tp3dlzxenc(in, dim1,dim2,d3, out,USIZE,tmp,lev),dim1*dim2*d3 *USIZE); pr(l,dim1*dim2*d3 *USIZE); + TMBENCH2(" 95",tp3dlzxdec(out,dim1,dim2,d3, cpy,USIZE,tmp),dim1*dim2*d3 *USIZE);} break; + case 96: if(dim4<=0) goto end; { + TMBENCH("",l=tp4dlzenc( in, dim1,dim2,dim3,dim4, out,USIZE,tmp,lev),dim1*dim2*dim3*dim4*USIZE); pr(l,dim1*dim2*dim3*dim4*USIZE); + TMBENCH2(" 96",tp4dlzdec( out,dim1,dim2,dim3,dim4,cpy,USIZE,tmp),dim1*dim2*dim3*dim4*USIZE);} break; + case 97: if(dim4<=0) goto end; { + TMBENCH("",l=tp4dlzzenc(in, dim1,dim2,dim3,dim4, out,USIZE,tmp,lev),dim1*dim2*dim3*dim4*USIZE);pr(l,dim1*dim2*dim3*dim4*USIZE); + TMBENCH2(" 97",tp4dlzzdec(out,dim1,dim2,dim3,dim4,cpy,USIZE,tmp),dim1*dim2*dim3*dim4*USIZE);} break; + case 98: if(dim4<=0) goto end; { + TMBENCH("",l=tp4dlzxenc(in, dim1,dim2,dim3,dim4, out,USIZE,tmp,lev),dim1*dim2*dim3*dim4*USIZE);pr(l,dim1*dim2*dim3*dim4*USIZE); + TMBENCH2(" 98",tp4dlzxdec(out,dim1,dim2,dim3,dim4,cpy,USIZE,tmp),dim1*dim2*dim3*dim4*USIZE);} break; #endif + #ifdef CODEC1 - case 76: TMBENCH("",l=streamvbyte_encode(in, m, out),n); pr(l,n); TMBENCH2("streamvbyte ",streamvbyte_decode(out, cpy, m),n); break; - case 77: TMBENCH("",l=streamvbyte_delta_encode(in, m, out,0),n); pr(l,n); TMBENCH2("streamvbyte delta",streamvbyte_delta_decode(out, cpy, m,0),n); break; + case 100:TMBENCH("",l=streamvbyte_encode(in, m, out),n); pr(l,n); TMBENCH2("100", streamvbyte_decode( out, cpy, m),n); break; + case 101:TMBENCH("",l=streamvbyte_delta_encode(in, m, out,0),n);pr(l,n); TMBENCH2("101", streamvbyte_delta_decode( out, cpy, m,0),n); break; + case 102:TMBENCH("",l=streamvbyte_zzag_encode(in,m,out,0,tmp),n);pr(l,n);TMBENCH2("102", streamvbyte_zzag_decode(out, cpy, m,0,tmp),n); break; #endif - case ID_MEMCPY: if(!mcpy) return l; TMBENCH( "", libmemcpy(out,in,n) ,n); pr(n,n); TMBENCH2("memcpy ", libmemcpy( cpy,out,n) ,n); break; - default: return l; + #ifdef CODEC2 + case 103: TMBENCH("",l=vbyte_encode(in, m, out),n); pr(l,n); TMBENCH2("103", masked_vbyte_decode(out, cpy, m),n); break; + case 104: TMBENCH("",l=FastPFore32( in, m, out,CBUF(n)),n); pr(l,n); TMBENCH2("104", FastPFord32( out, m, cpy),n); break; + case 105: TMBENCH("",l=FastPFore128v32(in, m, out,CBUF(n)),n); pr(l,n); TMBENCH2("105", FastPFord128v32(out, m, cpy),n); break; + case 106: TMBENCH("",l=OptPFore128v32( in, m, out,CBUF(n)),n); pr(l,n); TMBENCH2("106", OptPFord128v32( out, m, cpy),n); break; + #endif + case 107: l = n; TMBENCH("", tpenc( in, n, out,USIZE),n); pr(l,n); TMBENCH2("107", tpdec( out, n,cpy, USIZE),n); break; + case 108: l = n; TMBENCH("", tp4enc(in, n, out,USIZE),n); pr(l,n); TMBENCH2("108", tp4dec(out, n,cpy, USIZE),n); break; + case 109: l = n; TMBENCH("", bitshuffle(in, n, out, USIZE),n); pr(l,n); TMBENCH2("109", bitunshuffle(out, n,cpy, USIZE),n); break; + + case ID_MEMCPY: if(!mcpy) goto end; + TMBENCH( "", libmemcpy(out,in,n) ,n); pr(n,n); TMBENCH2("110", libmemcpy( cpy,out,n) ,n); break; + //case 111: TMBENCH("",fppad32(in, m, out,errlim),n); pr(n,n); TMBENCH2("fppad32 ", fppad32(in, m, out,errlim),n); break; + default: goto end; } { char s[65]; printf("%-30s ", bestr(id,32,s)); } - rc = memcheck(in,m*(32/8),cpy); - if(tmp) free(tmp); + rc = memcheck32(in,m,cpy); if(!rc) printf("\t%s\n", inname); + end:if(tmp) free(tmp); return l; } -unsigned bench64(unsigned char *in, unsigned n, unsigned char *out, unsigned char *cpy, int id, char *inname, int lev) { - unsigned l,m = n/(64/8),rc = 0, sorted=1; +#undef USIZE +#define USIZE 8 +unsigned bench64(unsigned char *in, unsigned n, unsigned char *out, unsigned char *cpy, int id, char *inname, int lev) { + unsigned l,m = n/(USIZE),rc = 0, d, dmin=-1; uint64_t *p; - char *tmp = NULL; - if((id == 43 || id>=60 && id <= 79) && !(tmp = (unsigned char*)malloc(CBUF(n)))) die(stderr, "malloc error\n"); + char *tmp = NULL; + if(NEEDTMP && !(tmp = (unsigned char*)malloc(CBUF(n)))) die(stderr, "malloc error\n"); - for(p=(uint64_t*)in,l = 1; l < m; l++) if(p[l] < p[l-1]) { sorted = 0; break; } + for(p = (uint64_t*)in,l = 1; l < m; l++) //calc mindelta + if(d=(p[l] < p[l-1])) { dmin = -1; break; /*unsorted*/} + else if(d < dmin) dmin = d; memrcpy(cpy,in,n); switch(id) { - case 1: TMBENCH("",l=p4nenc64( in, m, out) ,n); pr(l,n); TMBENCH2("p4nenc64 ",p4ndec64( out, m, cpy) ,n); break; - case 2: TMBENCH("",l=p4nenc128v64( in, m, out) ,n); pr(l,n); TMBENCH2("p4nenc128v64 ",p4ndec128v64( out, m, cpy) ,n); break; - - case 4: TMBENCH("",l=p4ndenc64( in, m, out) ,n); pr(l,n); TMBENCH2("p4ndenc64 ",p4nddec64( out, m, cpy) ,n); break; - - case 7: TMBENCH("",l=p4nd1enc64( in, m, out) ,n); pr(l,n); TMBENCH2("p4nd1enc64 ",p4nd1dec64( out, m, cpy) ,n); break; + case 1: TMBENCH("",l=p4nenc64( in, m, out) ,n); pr(l,n); TMBENCH2(" 1",p4ndec64( out, m, cpy) ,n); break; + case 2: TMBENCH("",l=p4nenc128v64( in, m, out) ,n); pr(l,n); TMBENCH2(" 2",p4ndec128v64( out, m, cpy) ,n); break; - case 10: TMBENCH("",l=p4nzenc64( in, m, out) ,n); pr(l,n); TMBENCH2("p4nzenc64 ",p4nzdec64( out, m, cpy) ,n); break; - //case 13: TMBENCH("",l=p4nsenc64( in, m, out) ,n); pr(l,n); TMBENCH2("p4nsenc64 ",p4nsdec64( out, m, cpy) ,n); break; - - case 20: TMBENCH("",l=bitnpack64( in, m, out) ,n); pr(l,n); TMBENCH2("bitnpack64 ",bitnunpack64( out, m, cpy) ,n); break; - case 21: TMBENCH("",l=bitnpack128v64( in, m, out) ,n); pr(l,n); TMBENCH2("bitnpack128v64 ",bitnunpack128v64( out, m, cpy) ,n); break; - - case 23: TMBENCH("",l=bitndpack64( in, m, out) ,n); pr(l,n); TMBENCH2("bitndpack64 ",bitndunpack64( out, m, cpy) ,n); break; - - case 26: TMBENCH("",l=bitnd1pack64( in, m, out) ,n); pr(l,n); TMBENCH2("bitnd1pack64 ",bitnd1unpack64( out, m, cpy) ,n); break; - - case 29: TMBENCH("",l=bitnzpack64( in, m, out) ,n); pr(l,n); TMBENCH2("bitnzpack64 ",bitnzunpack64( out, m, cpy) ,n); break; - - case 32: if(!sorted) return 0; TMBENCH("",l=bitnfpack64( in, m, out) ,n); pr(l,n); TMBENCH2("bitnfpack64 ",bitnfunpack64( out, m, cpy) ,n); break; + case 4: TMBENCH("",l=p4ndenc64( in, m, out) ,n); pr(l,n); TMBENCH2(" 4",p4nddec64( out, m, cpy) ,n); break; + //case 5: TMBENCH("",l=p4ndenc128v64( in, m, out) ,n); pr(l,n); TMBENCH2(" 5",p4nddec128v64( out, m, cpy) ,n); break; - case 40: TMBENCH("",l=vbenc64( in, m, out)-out,n); pr(l,n); TMBENCH2("vbenc64 ",vbdec64( out, m, cpy) ,n); break; // TurboVbyte : variable byte - case 41: TMBENCH("",l=vbzenc64( in, m, out,0)-out,n); pr(l,n); TMBENCH2("vbzenc64 ",vbzdec64( out, m, cpy,0) ,n); break; - case 42: TMBENCH("",l=vsenc64( in, m, out)-out,n); pr(l,n); TMBENCH2("vsenc64 ",vsdec64( out, m, cpy) ,n); break; // vsimple : variable simple - case 43: TMBENCH("",l=vszenc64( in, m, out,tmp)-out,n); pr(l,n); TMBENCH2("vszenc64 ",vszdec64( out, m, cpy) ,n); break; // vsimple : variable simple - - case 50: TMBENCH("",l=bvzzenc64( in, m, out,0),n); pr(l,n); TMBENCH2("bvzzenc64 ",bvzzdec64( out, m, cpy,0) ,n); break; // bitio - case 51: TMBENCH("",l=bvzenc64( in, m, out,0),n); pr(l,n); TMBENCH2("bvzenc64 ",bvzdec64( out, m, cpy,0) ,n); break; - case 52: TMBENCH("",l=fpgenc64( in, m, out,0),n); pr(l,n); TMBENCH2("fpgenc64 ",fpgdec64( out, m, cpy,0) ,n); break; + case 7: TMBENCH("",l=p4nd1enc64( in, m, out) ,n); pr(l,n); TMBENCH2(" 7",p4nd1dec64( out, m, cpy) ,n); break; + //case 8: TMBENCH("",l=p4nd1enc128v64( in, m, out) ,n); pr(l,n); TMBENCH2(" 8",p4nd1dec128v64( out, m, cpy) ,n); break; - case 55: TMBENCH("",l=fpzzenc64( in, m, out,0),n); pr(l,n); TMBENCH2("fpzzenc64 ",fpzzdec64( out, m, cpy,0) ,n); break; //Floating point/Integer - case 56: TMBENCH("",l=fpfcmenc64( in, m, out,0),n); pr(l,n); TMBENCH2("fpfcmenc64 ",fpfcmdec64( out, m, cpy,0) ,n); break; - case 57: TMBENCH("",l=fpdfcmenc64( in, m, out,0),n); pr(l,n); TMBENCH2("fpdfcmenc64 ",fpdfcmdec64( out, m, cpy,0) ,n); break; - case 58: TMBENCH("",l=fp2dfcmenc64( in, m, out,0),n); pr(l,n); TMBENCH2("fp2dfcmenc64 ",fp2dfcmdec64( out, m, cpy,0) ,n); break; - - case 60: TMBENCH("",l=trlec( in, n,out),n); pr(l,n); TMBENCH2("trle ",trled( out,l,cpy, n),n); break; // TurboRLE - case 61: TMBENCH("",l=trlezc( in, n,out,tmp),n); pr(l,n); TMBENCH2("trlez ",trlezd( out,l,cpy, n),n); break; - case 62: TMBENCH("",l=srlec64( in, n,out,RLE64),n); pr(l,n); TMBENCH2("srle64 ",srled64( out,l,cpy, n,RLE64),n);break; - case 63: TMBENCH("",l=srlezc64( in, n,out,tmp,RLE64),n); pr(l,n); TMBENCH2("srlez64 ",srlezd64( out,l,cpy, n,RLE64),n);break; + case 10: TMBENCH("",l=p4nzenc64( in, m, out) ,n); pr(l,n); TMBENCH2(" 10",p4nzdec64( out, m, cpy) ,n); break; + //case 11: TMBENCH("",l=p4nzenc128v64( in, m, out) ,n); pr(l,n); TMBENCH2(" 11",p4nzdec128v64( out, m, cpy) ,n); break; - #ifdef USE_LZ - #ifdef CODEC1 - case 69: TMBENCH("",l=spdpenc(in,m*(64/8),out,SPDP_BSIZE,lev),n);pr(l,n);TMBENCH2("SPDP ",spdpdec( out, m*(64/8), cpy,SPDP_BSIZE,lev); ,n); break; - #endif - case 70: TMBENCH("",l=tplzenc( in, n,out,64/8,tmp,lev) ,n); pr(l,n); TMBENCH2("tpbyte+lz ",tplzdec( out,n,cpy,64/8,tmp) ,n); break; - case 71: TMBENCH("",l=tp4lzenc( in, n,out,64/8,tmp,lev) ,n); pr(l,n); TMBENCH2("tpnibble+lz ",tp4lzdec( out,n,cpy,64/8,tmp) ,n); break; - case 72: TMBENCH("",l=tp4lzzenc64(in, n,out, tmp,lev) ,n); pr(l,n); TMBENCH2("tpnibbleZ+lz ",tp4lzzdec64( out,n,cpy, tmp) ,n); break; - case 73: TMBENCH("",l=tp4lzxenc64(in, n,out, tmp,lev) ,n); pr(l,n); TMBENCH2("tpnibbleX+lz ",tp4lzxdec64( out,n,cpy, tmp) ,n); break; - case 74: TMBENCH("",l=lzcomp( in, n,out, lev) ,n); pr(l,n); TMBENCH2("lz ",lzdecomp( out,n,cpy) ,n);break; - #ifdef BITSHUFFLE - case 75: TMBENCH("",l=bslzenc( in,n,out,64/8,tmp,lev), n); pr(l,n); TMBENCH2("bitshuffle+lz ",bslzdec(out,n,cpy,64/8,tmp), n); break; + case 13: TMBENCH("",l=p4nzzenc128v64( in, m, out,0),n); pr(l,n); TMBENCH2(" 13",p4nzzdec128v64( out, m, cpy,0) ,n); break; + + case 20: TMBENCH("",l=bitnpack64( in, m, out) ,n); pr(l,n); TMBENCH2(" 20",bitnunpack64( out, m, cpy) ,n); break; + case 21: TMBENCH("",l=bitnpack128v64( in, m, out) ,n); pr(l,n); TMBENCH2(" 21",bitnunpack128v64( out, m, cpy) ,n); break; + + case 23: TMBENCH("",l=bitndpack64( in, m, out) ,n); pr(l,n); TMBENCH2(" 23",bitndunpack64( out, m, cpy) ,n); break; + //case 24: TMBENCH("",l=bitndpack128v64( in, m, out) ,n); pr(l,n); TMBENCH2(" 24",bitndunpack128v64( out, m, cpy) ,n); break; + + case 26: TMBENCH("",l=bitnd1pack64( in, m, out) ,n); pr(l,n); TMBENCH2(" 26",bitnd1unpack64( out, m, cpy) ,n); break; + //case 27: TMBENCH("",l=bitnd1pack128v64(in, m, out) ,n); pr(l,n); TMBENCH2(" 27",bitnd1unpack128v64(out, m, cpy) ,n); break; + + case 29: TMBENCH("",l=bitnzpack64( in, m, out) ,n); pr(l,n); TMBENCH2(" 29",bitnzunpack64( out, m, cpy) ,n); break; + //case 30: TMBENCH("",l=bitnzpack128v64( in, m, out) ,n); pr(l,n); TMBENCH2(" 30",bitnzunpack128v64( out, m, cpy) ,n); break; + + case 32: if(dmin==-1) goto end; + TMBENCH("",l=bitnfpack64( in, m, out) ,n); pr(l,n); TMBENCH2(" 32",bitnfunpack64( out, m, cpy) ,n); break; + //case 33: if(dmin==-1) goto end; + // TMBENCH("",l=bitnfpack128v64( in, m, out) ,n); pr(l,n); TMBENCH2(" 33",bitnfunpack128v64( out, m, cpy) ,n); break; + + //case 35: if(dmin==-1) goto end; + // TMBENCH("",l=bitns1pack128v64( in, m, out) ,n); pr(l,n); TMBENCH2(" 35",bitns1unpack128v64( out, m, cpy) ,n); break; + //case 35: if(dmin==-1 /*|| !dmin*/) goto end; TMBENCH("",l=efanoenc64( in, m, out,0) ,n); pr(l,n); TMBENCH2("efanoenc64 ",efanodec64( out, m, cpy,0) ,n); break; + case 38: TMBENCH("",l=vsenc64( in, m, out)-out,n); pr(l,n); TMBENCH2(" 38",vsdec64( out, m, cpy) ,n); break; // vsimple : variable simple + case 39: TMBENCH("",l=vszenc64( in, m, out,tmp)-out,n); pr(l,n); TMBENCH2(" 39",vszdec64( out, m, cpy) ,n); break; + + case 40: TMBENCH("",l=vbenc64( in, m, out)-out,n); pr(l,n); TMBENCH2(" 40",vbdec64( out, m, cpy) ,n); break; // TurboVbyte : variable byte + case 41: TMBENCH("",l=vbzenc64( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 41",vbzdec64( out, m, cpy,0) ,n); break; + case 42: TMBENCH("",l=vbdenc64( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 42",vbddec64( out, m, cpy,0) ,n); break; + case 43: TMBENCH("",l=vbd1enc64( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 43",vbd1dec64( out, m, cpy,0) ,n); break; + case 44: TMBENCH("",l=vbddenc64( in, m, out,0)-out,n); pr(l,n); TMBENCH2(" 44",vbdddec64( out, m, cpy,0) ,n); break; + + case 60: TMBENCH("",l=bvzzenc64( in, m, out,0),n); pr(l,n); TMBENCH2(" 60",bvzzdec64( out, m, cpy,0) ,n); break; // bitio + case 61: TMBENCH("",l=bvzenc64( in, m, out,0),n); pr(l,n); TMBENCH2(" 61",bvzdec64( out, m, cpy,0) ,n); break; + case 62: TMBENCH("",l=fpgenc64( in, m, out,0),n); pr(l,n); TMBENCH2(" 62",fpgdec64( out, m, cpy,0) ,n); break; + + case 65: TMBENCH("",l=fpxenc64( in, m, out,0),n); pr(l,n); TMBENCH2(" 65",fpxdec64( out, m, cpy,0) ,n); break; //Floating point/Integer + case 66: TMBENCH("",l=fpfcmenc64( in, m, out,0),n); pr(l,n); TMBENCH2(" 66",fpfcmdec64( out, m, cpy,0) ,n); break; + case 67: TMBENCH("",l=fpdfcmenc64( in, m, out,0),n); pr(l,n); TMBENCH2(" 67",fpdfcmdec64( out, m, cpy,0) ,n); break; + case 68: TMBENCH("",l=fp2dfcmenc64( in, m, out,0),n); pr(l,n); TMBENCH2(" 68",fp2dfcmdec64( out, m, cpy,0) ,n); break; + + case 70: TMBENCH("",l=trlec( in, n,out),n); pr(l,n); TMBENCH2(" 70",trled( out,l,cpy, n),n); break; // TurboRLE + case 71: TMBENCH("",l=trlexc( in, n,out,tmp),n); pr(l,n); TMBENCH2(" 71",trlexd( out,l,cpy, n),n); break; + case 72: TMBENCH("",l=trlezc( in, n,out,tmp),n); pr(l,n); TMBENCH2(" 72",trlezd( out,l,cpy, n),n); break; + case 73: TMBENCH("",l=srlec64( in, n,out,RLE64),n); pr(l,n); TMBENCH2(" 73",srled64( out,l,cpy, n,RLE64),n);break; + case 74: TMBENCH("",l=srlexc64( in, n,out,tmp,RLE64),n); pr(l,n); TMBENCH2(" 74",srlexd64( out,l,cpy, n,RLE64),n);break; + case 75: TMBENCH("",l=srlezc64( in, n,out,tmp,RLE64),n); pr(l,n); TMBENCH2(" 75",srlezd64( out,l,cpy, n,RLE64),n);break; + #ifdef USE_LZ + //case 76: TMBENCH("",l=v8lzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2("TurboByte+lz ", v8lzdec( out,n,cpy,USIZE,tmp) ,n); break; + //case 77: TMBENCH("",l=v8lzxenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2("TurboByteX+lz ", v8lzxdec( out,n,cpy,USIZE,tmp) ,n); break; + //case 78: TMBENCH("",l=v8lzzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2("TurboByteZ+lz ", v8lzzdec( out,n,cpy,USIZE,tmp) ,n); break; + #ifdef CODEC1 + case 79: TMBENCH("",l=spdpenc(in,m*(USIZE),out,SPDPSIZE,lev),n);pr(l,n); TMBENCH2(" 79",spdpdec( out, m*(USIZE), cpy,SPDPSIZE,lev); ,n); break; #endif - #endif - case ID_MEMCPY: if(!mcpy) return l; TMBENCH( "", libmemcpy( out,in,n) ,n); pr(n,n); TMBENCH2("memcpy ", libmemcpy( cpy,out,n) ,n); break; - default: return l; + case 80: TMBENCH("",l=lzcomp( in,n,out, lev) ,n); pr(l,n); TMBENCH2(" 80",lzdecomp( out,n,cpy) ,n); break; + case 81: TMBENCH("",l=tplzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 81",tplzdec( out,n,cpy,USIZE,tmp) ,n); break; + case 82: TMBENCH("",l=tplzxenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 82",tplzxdec( out,n,cpy,USIZE,tmp) ,n); break; + case 83: TMBENCH("",l=tplzzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 83",tplzzdec( out,n,cpy,USIZE,tmp) ,n); break; + case 84: TMBENCH("",l=tp4lzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 84",tp4lzdec( out,n,cpy,USIZE,tmp) ,n); break; + case 85: TMBENCH("",l=tp4lzxenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 85",tp4lzxdec( out,n,cpy,USIZE,tmp) ,n); break; + case 86: TMBENCH("",l=tp4lzzenc( in,n,out,USIZE,tmp,lev) ,n); pr(l,n); TMBENCH2(" 86",tp4lzzdec( out,n,cpy,USIZE,tmp) ,n); break; + #ifdef BITSHUFFLE + case 87: TMBENCH("",l=bslzenc( in,n,out,USIZE,tmp,lev), n); pr(l,n); TMBENCH2(" 87",bslzdec( out,n,cpy,USIZE,tmp), n); break; + case 88: TMBENCH("",l=bslzxenc( in,n,out,USIZE,tmp,lev), n); pr(l,n); TMBENCH2(" 88",bslzxdec(out,n,cpy,USIZE,tmp), n); break; + case 89: TMBENCH("",l=bslzzenc( in,n,out,USIZE,tmp,lev), n); pr(l,n); TMBENCH2(" 89",bslzzdec(out,n,cpy,USIZE,tmp), n); break; + #endif + + case 90: if(dim2<=0) goto end; { unsigned d2=dim2*(dim3?dim3:1)*(dim4?dim4:1); + TMBENCH("",l=tp2dlzenc( in, dim1,d2, out,USIZE,tmp,lev),dim1*d2 *USIZE); pr(l,dim1*d2 *USIZE); + TMBENCH2(" 90",tp2dlzdec( out,dim1,d2, cpy,USIZE,tmp),dim1*d2 *USIZE);} break; + case 91: if(dim2<=0) goto end; { unsigned d2=dim2*(dim3?dim3:1)*(dim4?dim4:1); + TMBENCH("",l=tp2dlzzenc(in, dim1,d2, out,USIZE,tmp,lev),dim1*d2 *USIZE); pr(l,dim1*d2 *USIZE); + TMBENCH2(" 91",tp2dlzzdec(out,dim1,d2, cpy,USIZE,tmp),dim1*d2 *USIZE);} break; + case 92: if(dim2<=0) goto end; { unsigned d2=dim2*(dim3?dim3:1)*(dim4?dim4:1); + TMBENCH("",l=tp2dlzxenc(in, dim1,d2, out,USIZE,tmp,lev),dim1*d2 *USIZE); pr(l,dim1*d2 *USIZE); + TMBENCH2(" 92",tp2dlzxdec(out,dim1,d2, cpy,USIZE,tmp),dim1*d2 *USIZE);} break; + + case 93: if(dim3<=0) goto end; { unsigned d3=dim3*(dim4?dim4:1); + TMBENCH("",l=tp3dlzenc( in, dim1,dim2,d3, out,USIZE,tmp,lev),dim1*dim2*d3 *USIZE); pr(l,dim1*dim2*d3 *USIZE); + TMBENCH2(" 93",tp3dlzdec( out,dim1,dim2,d3, cpy,USIZE,tmp),dim1*dim2*d3 *USIZE);} break; + case 94: if(dim3<=0) goto end; { unsigned d3=dim3*(dim4?dim4:1); + TMBENCH("",l=tp3dlzzenc(in, dim1,dim2,d3, out,USIZE,tmp,lev),dim1*dim2*d3 *USIZE); pr(l,dim1*dim2*d3 *USIZE); + TMBENCH2(" 94",tp3dlzzdec(out,dim1,dim2,d3, cpy,USIZE,tmp),dim1*dim2*d3 *USIZE);} break; + case 95: if(dim3<=0) goto end; { unsigned d3=dim3*(dim4?dim4:1); + TMBENCH("",l=tp3dlzxenc(in, dim1,dim2,d3, out,USIZE,tmp,lev),dim1*dim2*d3 *USIZE); pr(l,dim1*dim2*d3 *USIZE); + TMBENCH2(" 95",tp3dlzxdec(out,dim1,dim2,d3, cpy,USIZE,tmp),dim1*dim2*d3 *USIZE);} break; + case 96: if(dim4<=0) goto end; { + TMBENCH("",l=tp4dlzenc( in, dim1,dim2,dim3,dim4, out,USIZE,tmp,lev),dim1*dim2*dim3*dim4*USIZE); pr(l,dim1*dim2*dim3*dim4*USIZE); + TMBENCH2(" 96",tp4dlzdec( out,dim1,dim2,dim3,dim4,cpy,USIZE,tmp),dim1*dim2*dim3*dim4*USIZE);} break; + case 97: if(dim4<=0) goto end; { + TMBENCH("",l=tp4dlzzenc(in, dim1,dim2,dim3,dim4, out,USIZE,tmp,lev),dim1*dim2*dim3*dim4*USIZE);pr(l,dim1*dim2*dim3*dim4*USIZE); + TMBENCH2(" 97",tp4dlzzdec(out,dim1,dim2,dim3,dim4,cpy,USIZE,tmp),dim1*dim2*dim3*dim4*USIZE);} break; + case 98: if(dim4<=0) goto end; { + TMBENCH("",l=tp4dlzxenc(in, dim1,dim2,dim3,dim4, out,USIZE,tmp,lev),dim1*dim2*dim3*dim4*USIZE);pr(l,dim1*dim2*dim3*dim4*USIZE); + TMBENCH2(" 98",tp4dlzxdec(out,dim1,dim2,dim3,dim4,cpy,USIZE,tmp),dim1*dim2*dim3*dim4*USIZE);} break; + #endif + case 107: l = n; TMBENCH("", tpenc( in, n, out,USIZE),n); pr(l,n); TMBENCH2("107", tpdec( out, n,cpy, USIZE),n); break; + case 108: l = n; TMBENCH("", tp4enc(in, n, out,USIZE),n); pr(l,n); TMBENCH2("108", tp4dec(out, n,cpy, USIZE),n); break; + case 109: l = n; TMBENCH("", bitshuffle(in, n, out, USIZE),n); pr(l,n); TMBENCH2("109", bitunshuffle(out, n,cpy, USIZE),n); break; + + case ID_MEMCPY: if(!mcpy) goto end; + TMBENCH( "", libmemcpy(out,in,n) ,n); pr(n,n); TMBENCH2("110", libmemcpy( cpy,out,n) ,n); break; + default: goto end; } { char s[65]; printf("%-30s ", bestr(id,64,s)); } - rc = memcheck(in,m*(64/8),cpy); - if(tmp) free(tmp); + rc = memcheck(in,m*(USIZE),cpy); if(!rc) printf("\t%s\n", inname); + end:if(tmp) free(tmp); return l; } - + void usage(char *pgm) { fprintf(stderr, "\nIcApp Copyright (c) 2013-2019 Powturbo %s\n", __DATE__); fprintf(stderr, "Usage: %s [options] [file]\n", pgm); @@ -1069,13 +1909,14 @@ void usage(char *pgm) { fprintf(stderr, "Benchmark:\n"); fprintf(stderr, " -i#/-j# # = Minimum de/compression iterations per run (default=auto)\n"); fprintf(stderr, " -I#/-J# # = Number of de/compression runs (default=3)\n"); + fprintf(stderr, " -e# # = function ids separated by ',' or ranges '#-#' (default='1-%d')\n", ID_MEMCPY); fprintf(stderr, "File format:\n"); fprintf(stderr, " -F[Xx[k][H]][.d][s]\n"); fprintf(stderr, " X = file format:\n"); fprintf(stderr, " t = text:one integer per line, k=column number in multiple columns line\n"); fprintf(stderr, " c = text:integers separated by non digit char\n"); fprintf(stderr, " x = entry format\n"); - fprintf(stderr, " [b=int8], [s=int16], [u=int32(default)], [s=int64], [f:float] [d:double]\n"); + fprintf(stderr, " [b=int8], [s=int16], [u=int32(default)], [l=int64], [f:float] [d:double]\n"); fprintf(stderr, " .# = decimal digits (default 2). Convert dec. numbers to integers\n"); fprintf(stderr, " H = skip first line(s)\n"); fprintf(stderr, " -H = skip first line(s). Only for text files\n"); @@ -1087,35 +1928,44 @@ void usage(char *pgm) { fprintf(stderr, " -T# = #:Timestamp in iso-8601 converted to milliseconds (64 bits)\n"); fprintf(stderr, " -V# = #:divisor. Only for text files\n"); fprintf(stderr, " -D# = #:decimals. Only for text files\n"); - fprintf(stderr, " -g# = allowed error for lossy floating point compression (ex. -g.00001)\n"); + fprintf(stderr, " -g# = allowed relative error for lossy floating point compression (ex. -g.00001)\n"); + fprintf(stderr, " -RD1xD2xD3xD4 = D1,D2,D3,D4 : dimensions (ex. -R128x64x1024)\n"); fprintf(stderr, "Output:\n"); - fprintf(stderr, " -v# # = verbosity 0..5 (default 1). 5=print first values read from text file\n"); + fprintf(stderr, " -v# # = verbosity 0..5 (default 1). 5=print first values read from text file\n"); fprintf(stderr, "----- arg. ZIPF specified --------------\n"); fprintf(stderr, " -aF F = zipfian distribution alpha ex. -a1.0 uniform -a1.5 skewed\n"); - fprintf(stderr, " -mNs N = minimum number. s=(k,K, m,M, g,G\n"); - fprintf(stderr, " -MNs N = maximum number\n"); - fprintf(stderr, " -nNs N = number of integers to generate\n"); - fprintf(stderr, "Ex. ./icapp -a1.5 -m0 -M255 -n100M ZIPF\n"); - fprintf(stderr, "ex. ./icapp file -e2\n"); - fprintf(stderr, "ex. ./icapp -Ft -D2 ibm.data\n"); - fprintf(stderr, "ex. ./icapp -Ft -f8 usages.dat\n"); - fprintf(stderr, "ex. ./icapp -Ft -f8 -HH tripdata.csv\n"); + fprintf(stderr, " -m#s # = minimum number. s=(k,K, m,M, g,G\n"); + fprintf(stderr, " -M#s # = maximum number\n"); + fprintf(stderr, " -n#s # = number of integers to generate\n"); + fprintf(stderr, " -d# Generate a non decreasing sequence. #:delta 0=non decreasing 1=strictly non decreasing\n"); + fprintf(stderr, "Examples:\n"); + fprintf(stderr, "./icapp -a1.5 -m0 -M255 -n100M ZIPF\n"); + fprintf(stderr, "./icapp -e45-59,90,91 -I15 -J15 -d0 ZIPF\n"); + fprintf(stderr, "./icapp -e45-59 -I15 -J15 -d1 -M16 -Fs -n10000 ZIPF\n"); + fprintf(stderr, "./icapp file -e2,7-9,14,15\n"); + fprintf(stderr, "./icapp -Ft -D2 ibm.data\n"); + fprintf(stderr, "./icapp -Ft -f8 usages.dat\n"); + fprintf(stderr, "./icapp -Ft -f8 -HH tripdata.csv\n"); + fprintf(stderr, "./icapp -Fd -g.001 double.raw\n"); exit(0); } int main(int argc, char* argv[]) { - unsigned b = 1 << 30, lz=0, fno,idmin=1,idmax=-1,m=1000000; int isize=4,dfmt = 0,kid=1,skiph=0,decs=0,divs=1,be_mindelta=0,lev=1; - unsigned char *in=NULL,*out,*cpy; - double mdelta=-10,errlim=0.0; + unsigned b = 1 << 30, lz=0, fno,m=1000000; + int isize=4,dfmt = 0,kid=1,skiph=0,decs=0,divs=1,be_mindelta=0,lev=1,nsd=-1,dim0=0;//tp2test();tp3test();exit(0); + unsigned char *in = NULL, *out, *cpy, *scmd = NULL; + double mdelta=-10,errlim=0.0; + tm_verbose = 1; + int c, digit_optind = 0, this_option_optind = optind ? optind : 1, option_index = 0; static struct option long_options[] = { {"blocsize", 0, 0, 'b'}, {0, 0, 0} }; for(;;) { - if((c = getopt_long(argc, argv, "a:B:C:e:D:E:f:F:g:i:I:j:J:k:K:Hl:m:M:n:s:v:V:y", long_options, &option_index)) == -1) break; + if((c = getopt_long(argc, argv, "a:B:C:d:D:d:e:f:F:g:G:i:I:j:J:k:K:Hl:m:M:n:R:s:v:V:w:y", long_options, &option_index)) == -1) break; switch(c) { case 0 : printf("Option %s", long_options[option_index].name); if(optarg) printf (" with arg %s", optarg); printf ("\n"); break; - case 'C': cmp = atoi(optarg); break; - case 'e': idmin = atoi(optarg); if(idmax == -1) idmax = idmin; break; - case 'E': idmax = atoi(optarg); break; + case 'C': cmp = atoi(optarg); break; + case 'e': scmd = optarg; break; + case 'G': nsd = atoi(optarg); break; case 'D': decs = atoi(optarg); break; case 'F': { char *s = optarg; @@ -1137,7 +1987,7 @@ int main(int argc, char* argv[]) { if(*s == 'H') { skiph++; s++; } // skip first line(s). ex. HHH : skip 3 first lines switch(*s) { case 's': be_mindelta = 0; break; case 'S': be_mindelta = 1; break; case 'z': be_mindelta = 2; break; } } break; - + case 'g': errlim = strtod(optarg, NULL); break; case 'H': skiph++; break; case 'K': { kid = atoi(optarg); if(!keysep) keysep = ",;\t"; } break; @@ -1150,7 +2000,7 @@ int main(int argc, char* argv[]) { case 'B': b = argtoi(optarg,1); break; //case 'c': cmp++; break; case 'l': lev = atoi(optarg); break; - case 'y': mcpy=0; break; + case 'y': mcpy = 0; break; case 'a': a = strtod(optarg, NULL); break; case 'd': mdelta = strtod(optarg, NULL);break; @@ -1158,70 +2008,114 @@ int main(int argc, char* argv[]) { case 'm': rm = argtoi(optarg,1); break; case 'M': rx = argtoi(optarg,1); break; case 'f': isize = -argtoi(optarg,1); break; - case 'v': verbose = atoi(optarg); break; + case 'R': { char *p; dim1 = strtoul(optarg, &p, 10); if(!dim1) dim0++; + if(*p) dim2 = strtoul(p+1, &p, 10); + if(*p) dim3 = strtoul(p+1, &p, 10); + if(*p) dim4 = strtoul(p+1, &p, 10); printf("dim=%dx%dx%dx%d ", dim1, dim2, dim3, dim4); + } break; + case 'w': tm_verbose = atoi(optarg); break; + case 'v': verbose = atoi(optarg); break; case 'V': divs = atoi(optarg); break; default: usage(argv[0]); exit(0); } - } + } #ifdef LZTURBO - beini(); + beini(); #endif - if(idmax == -1) idmax = ID_MEMCPY; - if(idmax < idmin) idmax = idmin; if(argc - optind < 1) { usage(argv[0]); exit(0); - } if(verbose) printf("dfmt=%d,size=%d\n", dfmt, isize); + } if(verbose>1) printf("dfmt=%d,size=%d\n", dfmt, isize); for(fno = optind; fno < argc; fno++) { - char *inname = argv[fno]; - int i,n; + char *inname = argv[fno]; + int i,n; long long flen; - FILE *fi=NULL; + FILE *fi = NULL; if(!strcmp(inname,"ZIPF") || !strcmp(inname,"TMS")) flen = n = m*abs(isize); else { - fi = fopen(inname, "rb"); if(!fi ) { perror(inname); continue; } + fi = fopen(inname, "rb"); if(!fi) { perror(inname); continue; } if(dfmt) { n = flen = befgen(&in, 0, dfmt, isize, fi, kid, skiph, decs, divs, be_mindelta); - } else { - fseek(fi, 0, SEEK_END); - flen = ftell(fi); + } else { + fseek(fi, 0, SEEK_END); + flen = ftell(fi); fseek(fi, 0, SEEK_SET); if(flen > b) flen = b; - n = flen; + n = flen; + if(dim0) { char *p; if(!(p = strrchr(inname, '\\')) && !(p = strrchr(inname, '/'))) p=inname; + dim1=dim2=dim3=dim4=0; + while(!isdigit(*p)) p++; if(verbose>1) printf("fn='%s' ", p); + dim1 = strtoul(p, &p, 10); + if(dim1 && *p) dim2 = strtoul(p+1, &p, 10); + if(dim2 && *p) dim3 = strtoul(p+1, &p, 10); + if(dim3 && *p) dim4 = strtoul(p+1, &p, 10); + } } } - if(!in && !(in = (unsigned char*)malloc(n+64 ))) die("malloc error 'in =%d'\n", n); cpy = in; - if(!(out = (unsigned char*)malloc(CBUF(n)+1024))) die("malloc error 'out=%d'\n", n); - if(cmp && !(cpy = (unsigned char*)malloc(CBUF(n)+1024))) die("malloc error 'cpy=%d'\n", n); - if(fi) { + if(dim4 && !dim3) dim3 = 1; if(dim3 && !dim2) dim2 = 1; if(dim2 && !dim1) dim1 = 1; + if(dim1 || dim2 || dim3) printf("dim=%dx%dx%dx%d\n", dim1, dim2, dim3, dim4); + if(!in && !(in = (unsigned char*)malloc(n+64+1024 ))) die("malloc error 'in =%d'\n", n); cpy = in; + if(!(out = (unsigned char*)malloc(CBUF(n)+1024*1024))) die("malloc error 'out=%d'\n", n); + if(cmp && !(cpy = (unsigned char*)malloc(CBUF(n)+1024*1024))) die("malloc error 'cpy=%d'\n", n); + if(fi) { if(!dfmt) n = fread(in, 1, n, fi); fclose(fi); } else if(!strcmp(inname,"TMS") && abs(isize) == 8) - tms64(in, m, rm, rx); + tms64(in, m, rm, rx, a); else datagen(in, m, isize, mdelta); if(n <= 0) exit(0); - if(fno == optind) - tm_init(tm_Rep, 1); - if(verbose || fno == optind) printf(" E MB/s size ratio D MB/s function (%s size=%d bits)\n", isize>0?"integer":"floating point", abs(isize)*8); + //if(fno == optind) + tm_init(tm_Rep, tm_verbose /* 2 print id */); - if(errlim > 0.0) { // convert input for lossy floating point compression - if(isize == -4) padfloat32(in,n/4,in,errlim); - else if(isize == -8) padfloat64(in,n/8,in,errlim); + if(errlim > 0.0 || nsd>=0) { // convert input for lossy floating point compression + if(errlim < 0.000009999) errlim = 0.00001; + if(isize == -4) { + fppad32(in,n/4,out,errlim); if(verbose>0) fpstat(in, n/4, out, -4); //if(nsd >= 0) fprnd32(in,n/4,out,nsd); else // + fppad32(in,n/4, in,errlim); /*if(nsd >= 0) fprnd32(in,n/4,in, nsd); else */ + //TMBENCH("fppad32",fppad32(in,n/8,out,errlim),n);printf("\n"); + } else if(isize == -8) { //TMBENCH("fppad64",fppad64(in,n/8,out,errlim),n);printf("\n"); + fppad64(in,n/8,out,errlim); if(verbose>0) fpstat(in, n/8, out, -8); /*if(nsd>=0) fprnd64(in,n/8,out,nsd); else*/ + fppad64(in,n/8, in,errlim); /*if(nsd>=0) fprnd64(in,n/8, in,nsd); else*/ + } + #ifdef USE_FLOAT16 + else if(isize == -2) { + fppad16(in,n/2,out,errlim); if(verbose>0) fpstat(in, n/2, out, -2); /*if(nsd>=0) fprnd64(in,n/8,out,nsd); else*/ + fppad16(in,n/2, in,errlim); /*if(nsd>=0) fprnd64(in,n/8, in,nsd); else*/ + } + #endif + } + char *p = scmd?scmd:"1-110"; + if(fi) { + switch(abs(isize)) { + case 1: histl8( in,n); stprint("file: max", xbits); break; + case 2: histl16(in,n/2); stprint("file: max", xbits); break; + case 4: histl32(in,n/4); stprint("file: max", xbits); break; + case 8: histl64(in,n/8); stprint("file: max", xbits); break; + } + switch(isize) { + case -2: histt16(in,n/2); stprint("file: ctz", tbits); break; + case -4: histt32(in,n/4); stprint("file: ctz", tbits); break; + case -8: histt64(in,n/8); stprint("file: ctz", tbits); break; + } } - for(i=idmin; i <= idmax; i++) - switch(abs(isize)) { - case 1: bench8( in,n,out,cpy,i,inname,lev); break; - case 2: bench16(in,n,out,cpy,i,inname,lev); break; - case 4: bench32(in,n,out,cpy,i,inname,lev); break; - case 8: bench64(in,n,out,cpy,i,inname,lev); break; - default: die("integer size must be 2, 4 or 8\n"); - } + if(verbose>1 || fno == optind) + printf(" E MB/s size ratio D MB/s function (%s size=%d bits, err=%f)\n", isize>0?"integer":"floating point", abs(isize)*8, errlim); + do { + unsigned id = strtoul(p, &p, 10),idx = id, i; + while(isspace(*p)) p++; if(*p == '-') { if((idx = strtoul(p+1, &p, 10)) < id) idx = id; if(idx > ID_MEMCPY) idx = ID_MEMCPY; } + for(i = id; i <= idx; i++) + switch(abs(isize)) { + case 1: bench8( in,n,out,cpy,i,inname,lev); break; + case 2: bench16(in,n,out,cpy,i,inname,lev); break; + case 4: bench32(in,n,out,cpy,i,inname,lev); break; + case 8: bench64(in,n,out,cpy,i,inname,lev); break; + default: die("integer size must be 2, 4 or 8\n"); + } + } while(*p++); printf("\n"); - if(idmax > idmin) printf("\n"); free(in); free(out); free(cpy); in = out = cpy = NULL; } } -