Skip to content

Commit

Permalink
Fixing...
Browse files Browse the repository at this point in the history
SSE2 compatibility should be warranted #10
  • Loading branch information
lemire committed Jan 8, 2016
1 parent dac115f commit fb6e83f
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
4 changes: 2 additions & 2 deletions include/simdcomputil.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ uint32_t simdmin(const uint32_t * in);
/* computes (quickly) the minimal value of the specified number of values */
uint32_t simdmin_length(const uint32_t * in, uint32_t length);


#ifdef __SSE4_1__
/* computes (quickly) the minimal and maximal value of the specified number of values */
void simdmaxmin_length(const uint32_t * in, uint32_t length, uint32_t * getmin, uint32_t * getmax);

/* computes (quickly) the minimal and maximal value of the 128 values */
void simdmaxmin(const uint32_t * in, uint32_t * getmin, uint32_t * getmax);


#endif

/* like maxbit over 128 integers (SIMDBlockSize) with provided initial value
and using differential coding */
Expand Down
6 changes: 5 additions & 1 deletion src/simdcomputil.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
*/

#include "simdcomputil.h"
#ifdef __SSE4_1__
#include <smmintrin.h>
#endif
#include <assert.h>

#define Delta(curr, prev) \
Expand Down Expand Up @@ -49,6 +51,8 @@ static uint32_t orasint(const __m128i accumulator) {
return _mm_cvtsi128_si32(_tmp2);
}

#ifdef __SSE4_1__

static uint32_t minasint(const __m128i accumulator) {
const __m128i _tmp1 = _mm_min_epu32(_mm_srli_si128(accumulator, 8), accumulator); /* (A,B,C,D) xor (0,0,A,B) = (A,B,C xor A,D xor B)*/
const __m128i _tmp2 = _mm_min_epu32(_mm_srli_si128(_tmp1, 4), _tmp1); /* (A,B,C xor A,D xor B) xor (0,0,0,C xor A)*/
Expand Down Expand Up @@ -135,7 +139,7 @@ void simdmaxmin_length(const uint32_t * in, uint32_t length, uint32_t * getmin,
}
}


#endif

SIMDCOMP_PURE uint32_t maxbits_length(const uint32_t * in,uint32_t length) {
uint32_t k;
Expand Down
5 changes: 5 additions & 0 deletions src/simdintegratedbitpacking.c
Original file line number Diff line number Diff line change
Expand Up @@ -24867,6 +24867,8 @@ void simdfastsetd1fromprevious( __m128i * in, uint32_t bit, uint32_t previousval
simdfastset(in, bit, value - previousvalue, index);
}

#ifdef __SSE4_1__

void simdfastsetd1(uint32_t initvalue, __m128i * in, uint32_t bit, uint32_t value, size_t index) {
if(index == 0) {
simdfastset(in, bit, value - initvalue, index);
Expand All @@ -24875,3 +24877,6 @@ void simdfastsetd1(uint32_t initvalue, __m128i * in, uint32_t bit, uint32_t valu
simdfastset(in, bit, value - prev, index);
}
}

#endif

3 changes: 3 additions & 0 deletions src/simdpackedsearch.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* This code is released under a BSD License.
*/
#ifdef __SSE4_1__

#include <smmintrin.h>
#include "simdintegratedbitpacking.h"

Expand Down Expand Up @@ -15861,3 +15863,4 @@ simdsearchd1(__m128i * initOffset, const __m128i *in, uint32_t bit,
return (-1);
}

#endif
3 changes: 2 additions & 1 deletion src/simdpackedselect.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* This code is released under a BSD License.
*/
#ifdef __SSE4_1__
#include "simdintegratedbitpacking.h"
#include <smmintrin.h>

Expand Down Expand Up @@ -15486,4 +15487,4 @@ simdscand1(__m128i * initOffset, const __m128i *in, uint32_t bit)
return ;
}


#endif
21 changes: 14 additions & 7 deletions src/unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ int testset() {
return 0;
}

#ifdef __SSE4_1__

int testsetd1() {
int bit;
size_t i;
Expand Down Expand Up @@ -175,7 +177,7 @@ int testsetd1() {

return 0;
}

#endif

int testsetFOR() {
int bit;
Expand Down Expand Up @@ -317,6 +319,7 @@ int test() {
return 0;
}

#ifdef __SSE4_1__
int testFOR() {
int N = 5000 * SIMDBlockSize, gap;
__m128i * buffer = malloc(SIMDBlockSize * sizeof(uint32_t));
Expand Down Expand Up @@ -362,6 +365,7 @@ int testFOR() {
printf("Code looks good.\n");
return 0;
}
#endif

#define MAX 300
int test_simdmaxbitsd1_length() {
Expand Down Expand Up @@ -405,7 +409,7 @@ int uint32_cmp(const void *a, const void *b)
return 0;
}


#ifdef __SSE4_1__
int test_simdpackedsearch() {
uint32_t buffer[128];
uint32_t result = 0;
Expand Down Expand Up @@ -488,7 +492,6 @@ int test_simdpackedsearchFOR() {
return 0;
}


int test_simdpackedsearch_advanced() {
uint32_t buffer[128];
uint32_t backbuffer[128];
Expand Down Expand Up @@ -655,17 +658,20 @@ int test_simdpackedselect_advanced() {
printf("advanced simdselectd1: ok\n");
return 0;
}
#endif


int main() {
int r;
r = testsetFOR();
if (r)
return r;

#ifdef __SSE4_1__
r = testsetd1();
if (r)
return r;

#endif
r = testset();
if (r)
return r;
Expand All @@ -679,22 +685,23 @@ int main() {
r = testlongpack();
if (r)
return r;

#ifdef __SSE4_1__
r = test_simdpackedsearchFOR();
if (r)
return r;

r = testFOR();
if (r)
return r;
#endif
r = test();
if (r)
return r;

r = test_simdmaxbitsd1_length();
if (r)
return r;

#ifdef __SSE4_1__
r = test_simdpackedsearch();
if (r)
return r;
Expand All @@ -703,14 +710,14 @@ int main() {
if (r)
return r;


r = test_simdpackedselect();
if (r)
return r;

r = test_simdpackedselect_advanced();
if (r)
return r;
#endif


return 0;
Expand Down

0 comments on commit fb6e83f

Please sign in to comment.