diff options
author | eschnett <eschnett@105869f7-3296-0410-a4ea-f4349344b45a> | 2012-09-14 18:48:46 +0000 |
---|---|---|
committer | eschnett <eschnett@105869f7-3296-0410-a4ea-f4349344b45a> | 2012-09-14 18:48:46 +0000 |
commit | 6005a49ff06f8368b516c168e5a396530c1193d4 (patch) | |
tree | 83ee6b75212e9f106c9854b3cca7060a63504a03 /src/vectors-8-QPX.h | |
parent | ff90dc4b8644b18cb8c01bdba1df2488518652ba (diff) |
Add support for (dynamic) if-then expressions
Add types for holding integers and booleans, and vectors thereof.
Add if-then expressions.
Add floating point comparisons.
Update tests.
git-svn-id: https://svn.cct.lsu.edu/repos/numrel/LSUThorns/Vectors/trunk@66 105869f7-3296-0410-a4ea-f4349344b45a
Diffstat (limited to 'src/vectors-8-QPX.h')
-rw-r--r-- | src/vectors-8-QPX.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/vectors-8-QPX.h b/src/vectors-8-QPX.h index 80762fe..93a7707 100644 --- a/src/vectors-8-QPX.h +++ b/src/vectors-8-QPX.h @@ -6,6 +6,8 @@ // Note: bgxlC_r does not like const declarations, so we need to cast // them away and/or omit them everywhere +// See <http://pic.dhe.ibm.com/infocenter/compbg/v121v141/index.jsp> + #include <assert.h> @@ -19,11 +21,18 @@ #define vec8_architecture "QPX" // Vector type corresponding to CCTK_REAL +// TODO: Use a typedef to avoid the "const" issue? Or use a struct? #define CCTK_REAL8_VEC vector4double // Number of vector elements in a CCTK_REAL_VEC #define CCTK_REAL8_VEC_SIZE 4 +// Integer and boolean types corresponding to this real type +#define CCTK_INTEGER8 CCTK_REAL8 +#define CCTK_BOOLEAN8 CCTK_REAL8 +#define CCTK_INTEGER8_VEC CCTK_REAL8_VEC +#define CCTK_BOOLEAN8_VEC CCTK_REAL8_VEC + union k8const_t { @@ -300,6 +309,8 @@ union k8const_t { #define k8tan(x) K8REPL(tan,x) #define k8tanh(x) K8REPL(tanh,x) +// canonical true is +1.0, canonical false is -1.0 +// >=0 is true, -0 is true, nan is false #define k8lfalse \ ({ CCTK_REAL8_VEC dummy; vec_logical(dummy,dummy,0x0); }) #define k8ltrue \ @@ -309,3 +320,10 @@ union k8const_t { #define k8lor(x,y) (vec_or(x,y)) #define k8lxor(x,y) (vec_xor(x,y)) #define k8ifthen(x,y,z) (vec_sel(z,x,y)) + +#define k8cmpeq(x,y) (vec_cmpeq(x,y)) +#define k8cmpne(x,y) (vec_not(vec_cmpeq(x,y))) +#define k8cmpgt(x,y) (vec_cmpgt(x,y)) +#define k8cmpge(x,y) (vec_not(vec_cmplt(x,y))) +#define k8cmplt(x,y) (vec_cmplt(x,y)) +#define k8cmple(x,y) (vec_not(vec_cmpgt(x,y))) |