aboutsummaryrefslogtreecommitdiff
path: root/src/vectors-8-default.h
blob: ee8559329ade11d8959d96f8763fae62252e23b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Fallback vectorisation implementation: Do not vectorise

// We use macros here, so that we are not surprised by compilers which
// don't like to inline functions. This should also make debug builds
// (which may not inline) more efficient.



#include <assert.h>
#include <math.h>



#define vec8_architecture "scalar (no vectorisation, 64-bit precision)"

// Use CCTK_REAL8
#define CCTK_REAL8_VEC CCTK_REAL8

// Number of vector elements in a vector
#define CCTK_REAL8_VEC_SIZE 1



// Create a vector replicating a scalar
#define vec8_set1(a) (a)
// Create a vector from N scalars
#define vec8_set(a) (a)

// Access vectors elements
#define vec8_elt0(x) (x)
#define vec8_elt(x,d) (x)



// Load an aligned vector from memory
#define vec8_load(p) (p)
// Load an unaligned vector from memory
#define vec8_loadu(p) (p)

// Load a vector from memory that may or may not be aligned, as
// decided by the offset and the vector size. These functions are
// useful e.g. for loading neightbouring grid points while evaluating
// finite differencing stencils.
#define vec8_loadu_maybe(off,p) (p)
#define vec8_loadu_maybe3(off1,off2,off3,p) (p)

// Aligned store
#define vec8_store(p,x) ((p)=(x))
// Unaligned store
#define vec8_store_nta(p,x) ((p)=(x))

#define vec8_store_partial_prepare(i,imin,imax) ((void)0)
#define vec8_store_nta_partial(p,x) (vec8_store_nta(p,x))
// Store the n lower elements of a vector to memory
#define vec8_store_nta_partial_lo(p,x,n) (assert(0))
// Store the n higher elements of a vector into memory. This stores
// the vector elements into memory locations as if element 0 were
// stored at p.
#define vec8_store_nta_partial_hi(p,x,n) (assert(0))
#define vec8_store_nta_partial_mid(p,x,nlo,nhi) (assert(0))



// Operators
#define k8neg(x) (-(x))

#define k8add(x,y) ((x)+(y))
#define k8sub(x,y) ((x)-(y))
#define k8mul(x,y) ((x)*(y))
#define k8div(x,y) ((x)/(y))

// Fused multiply-add, defined as [+-]x*y[+-]z
#define k8madd(x,y,z)  (+(x)*(y)+(z))
#define k8msub(x,y,z)  (+(x)*(y)-(z))
#define k8nmadd(x,y,z) (-(x)*(y)-(z))
#define k8nmsub(x,y,z) (-(x)*(y)+(z))

// Functions
#define k8cos(x)    (cos(x))
#define k8exp(x)    (exp(x))
#define k8fabs(x)   (fabs(x))
#define k8fmax(x,y) (fmax(x,y))
#define k8fmin(x,y) (fmin(x,y))
#define k8fnabs(x)  (-fabs(x))
#define k8log(x)    (log(x))
#define k8pow(x,a)  (pow(x,a))
#define k8sin(x)    (sin(x))
#define k8sqrt(x)   (sqrt(x))
#define k8tan(x)    (tan(x))

#ifdef __cplusplus
#  define k8sgn(x) ({ using namespace std; signbit(x); })
#else
#  define k8sgn(x) (signbit(x))
#endif

#define k8ifmsb(x,y,z) (k8sgn(x)?(y):(z))