aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsvn_bwardell <svn_bwardell@105869f7-3296-0410-a4ea-f4349344b45a>2011-08-07 12:41:50 +0000
committersvn_bwardell <svn_bwardell@105869f7-3296-0410-a4ea-f4349344b45a>2011-08-07 12:41:50 +0000
commit96caf45931a90c080adc8073762d72aa2a80ac76 (patch)
tree48ccb4894a0bdd3dbf62826e8c0e05641d1f4236
parent1d6878bcc13a1695043cb680f7ab83be28048419 (diff)
Fix definition of kifthen for architectures where blend instructions are not available.
git-svn-id: https://svn.cct.lsu.edu/repos/numrel/LSUThorns/Vectors/trunk@20 105869f7-3296-0410-a4ea-f4349344b45a
-rw-r--r--src/vectors-4-SSE.h15
-rw-r--r--src/vectors-4-default.h9
-rw-r--r--src/vectors-8-SSE2.h11
-rw-r--r--src/vectors-8-default.h9
4 files changed, 34 insertions, 10 deletions
diff --git a/src/vectors-4-SSE.h b/src/vectors-4-SSE.h
index 8319c49..7948032 100644
--- a/src/vectors-4-SSE.h
+++ b/src/vectors-4-SSE.h
@@ -303,6 +303,12 @@ static const union {
#ifdef __SSE4_1__
# define k4ifthen(x,y,z) (_mm_blendv_ps(y,z,x))
#else
+#include <math.h>
+#ifdef __cplusplus
+#define SGN(x) std::signbit(x)
+#else
+#define SGN(x) signbit(x)
+#endif
# define k4ifthen(x,y,z) \
({ \
CCTK_REAL4_VEC const xx=(x_); \
@@ -311,10 +317,9 @@ static const union {
CCTK_REAL4_VEC const y=yy; \
CCTK_REAL4_VEC const zz=(z_); \
CCTK_REAL4_VEC const z=zz; \
- CCTK_REAL4_VEC const c = _mm_and_ps(x,k4sign_mask); \
- vec4_set(vec4_elt0(not vec4_elt0(c) ? y : z), \
- vec4_elt1(not vec4_elt1(c) ? y : z), \
- vec4_elt2(not vec4_elt2(c) ? y : z), \
- vec4_elt3(not vec4_elt3(c) ? y : z)); \
+ vec4_set(SGN(vec4_elt0(x)) ? vec4_elt0(z) : vec4_elt0(y), \
+ SGN(vec4_elt1(x)) ? vec4_elt1(z) : vec4_elt1(y), \
+ SGN(vec4_elt2(x)) ? vec4_elt2(z) : vec4_elt2(y), \
+ SGN(vec4_elt3(x)) ? vec4_elt3(z) : vec4_elt3(y)); \
})
#endif
diff --git a/src/vectors-4-default.h b/src/vectors-4-default.h
index b59db7c..6f66ff9 100644
--- a/src/vectors-4-default.h
+++ b/src/vectors-4-default.h
@@ -81,4 +81,11 @@
#define k4pow(x,a) (powf(x,a))
#define k4sqrt(x) (sqrtf(x))
-#define k4ifthen(x,y,z) ((x)>=0?(y):(z))
+#include <math.h>
+#ifdef __cplusplus
+#define SGN(x) std::signbit(x)
+#else
+#define SGN(x) signbit(x)
+#endif
+
+#define k4ifthen(x,y,z) (SGN(x)?(z):(y))
diff --git a/src/vectors-8-SSE2.h b/src/vectors-8-SSE2.h
index 15a45ed..3bd5753 100644
--- a/src/vectors-8-SSE2.h
+++ b/src/vectors-8-SSE2.h
@@ -225,6 +225,12 @@ static const union {
r; \
})
#else
+#include <math.h>
+#ifdef __cplusplus
+#define SGN(x) std::signbit(x)
+#else
+#define SGN(x) signbit(x)
+#endif
# define k8ifthen(x_,y_,z_) \
({ \
CCTK_REAL8_VEC const xx=(x_); \
@@ -233,8 +239,7 @@ static const union {
CCTK_REAL8_VEC const y=yy; \
CCTK_REAL8_VEC const zz=(z_); \
CCTK_REAL8_VEC const z=zz; \
- CCTK_REAL8_VEC const c = _mm_and_pd(x,k8sign_mask); \
- vec8_set(vec8_elt0(not vec8_elt0(c) ? y : z), \
- vec8_elt1(not vec8_elt1(c) ? y : z)); \
+ vec8_set(SGN(vec8_elt0(x)) ? vec8_elt0(z) : vec8_elt0(y), \
+ SGN(vec8_elt1(x)) ? vec8_elt1(z) : vec8_elt1(y)); \
})
#endif
diff --git a/src/vectors-8-default.h b/src/vectors-8-default.h
index 6f81b91..cdce1ef 100644
--- a/src/vectors-8-default.h
+++ b/src/vectors-8-default.h
@@ -81,4 +81,11 @@
#define k8pow(x,a) (pow(x,a))
#define k8sqrt(x) (sqrt(x))
-#define k8ifthen(x,y,z) ((x)>=0?(y):(z))
+#include <math.h>
+#ifdef __cplusplus
+#define SGN(x) std::signbit(x)
+#else
+#define SGN(x) signbit(x)
+#endif
+
+#define k8ifthen(x,y,z) (SGN(x)?(z):(y))