44#include <stdio.h>
55#include "simdcomp.h"
66
7+
78int main () {
89 int N = 5000 * SIMDBlockSize ;
910 __m128i * buffer = malloc (SIMDBlockSize * sizeof (uint32_t ));
@@ -15,20 +16,34 @@ int main() {
1516 datain [k ] = k * gap ;
1617 uint32_t offset = 0 ;
1718 for (int k = 0 ; k * SIMDBlockSize < N ; ++ k ) {
19+ /////////////////////////////
20+ // First part works for general arrays (sorted or unsorted)
21+ /////////////////////////////
22+ // we compute the bit width
1823 const uint32_t b = maxbits (datain + k * SIMDBlockSize );
19- simdpackwithoutmask (datain + k * SIMDBlockSize , buffer , b );//compressed
24+ // we read 128 integers at "datain + k * SIMDBlockSize" and
25+ // write b 128-bit vectors at "buffer"
26+ simdpackwithoutmask (datain + k * SIMDBlockSize , buffer , b );
27+ // we read back b1 128-bit vectors at "buffer" and write 128 integers at backbuffer
2028 simdunpack (buffer , backbuffer , b );//uncompressed
2129 for (int j = 0 ; j < SIMDBlockSize ; ++ j ) {
2230 if (backbuffer [j ] != datain [k * SIMDBlockSize + j ]) {
2331 printf ("bug in simdpack\n" );
2432 return -2 ;
2533 }
2634 }
35+ /////////////////////////////
36+ // next part assumes that the data is sorted (uses differential coding)
37+ /////////////////////////////
38+ // we compute the bit width
2739 const uint32_t b1 = simdmaxbitsd1 (offset ,
2840 datain + k * SIMDBlockSize );
41+ // we read 128 integers at "datain + k * SIMDBlockSize" and
42+ // write b1 128-bit vectors at "buffer"
2943 simdpackwithoutmaskd1 (offset , datain + k * SIMDBlockSize , buffer ,
30- b1 );//compressed
31- simdunpackd1 (offset , buffer , backbuffer , b1 );//uncompressed
44+ b1 );
45+ // we read back b1 128-bit vectors at "buffer" and write 128 integers at backbuffer
46+ simdunpackd1 (offset , buffer , backbuffer , b1 );
3247 for (int j = 0 ; j < SIMDBlockSize ; ++ j ) {
3348 if (backbuffer [j ] != datain [k * SIMDBlockSize + j ]) {
3449 printf ("bug in simdpack d1\n" );
0 commit comments