QUDA  v1.1.0
A library for QCD on GPUs
double_single.h
Go to the documentation of this file.
1 #pragma once
2 
3 __host__ __device__ inline void dsadd(float2 &c, const float2 &a, const float2 &b) {
4  float t1 = a.x + b.x;
5  float e = t1 - a.x;
6  float t2 = ((b.x - e) + (a.x - (t1 - e))) + a.y + b.y;
7  // The result is t1 + t2, after normalization.
8  c.x = e = t1 + t2;
9  c.y = t2 - (e - t1);
10 }
11 
12 struct doublesingle {
13  float2 a;
14  __host__ __device__ inline doublesingle() : a(make_float2(0.0f,0.0f)) { ; }
15  __host__ __device__ inline doublesingle(const doublesingle &b) : a(make_float2(b.a.x, b.a.y)) { ; }
16  __host__ __device__ inline doublesingle(const float a) : a(make_float2(a, 0.0)) { ; }
17 
18  __host__ __device__ inline void operator+=(const doublesingle &b) { dsadd(this->a, this->a, b.a); }
19  __host__ __device__ inline void operator+=(const float &b) {
20  float2 b2 = make_float2(b, 0.0);
21  dsadd(this->a, this->a, b2); }
22 
23  __host__ __device__ inline doublesingle& operator=(const doublesingle &b)
24  { a.x = b.a.x; a.y = b.a.y; return *this; }
25 
26  __host__ __device__ inline doublesingle& operator=(const float &b)
27  { a.x = b; a.y = 0.0f; return *this; }
28 };
29 
30 __host__ __device__ inline doublesingle operator+=(doublesingle &a, const doublesingle &b)
31 { dsadd(a.a, a.a, b.a); return a;}
32 
33 __host__ __device__ double operator+=(double& a, doublesingle &b) { a += b.a.x; a += b.a.y; return a; }
34 
35 struct doublesingle2 {
38  __host__ __device__ inline doublesingle2& operator=(const double &a)
39  { x = a; y = a; return *this; }
40  __host__ __device__ inline void operator+=(const double2 &b) {x += b.x; y += b.y;}
41  __host__ __device__ inline void operator+=(const doublesingle2 &b) {x += b.x; y += b.y;}
42 };
43 
44 __host__ __device__ double2 operator+=(double2& a, doublesingle2 &b)
45 { a.x += b.x.a.x; a.x += b.x.a.y; a.y += b.y.a.x; a.y += b.y.a.y; return a; }
46 
47 struct doublesingle3 {
51  __host__ __device__ inline void operator+=(const double3 &b) {x += b.x; y += b.y; z += b.z;}
52  __host__ __device__ inline void operator+=(const doublesingle3 &b) {x += b.x; y += b.y; z+= b.z;}
53 };
54 
55 __host__ __device__ double3 operator+=(double3& a, doublesingle3 &b)
56 { a.x += b.x.a.x; a.x += b.x.a.y; a.y += b.y.a.x; a.y += b.y.a.y; a.z += b.z.a.x; a.z += b.z.a.y; return a; }
__host__ __device__ doublesingle operator+=(doublesingle &a, const doublesingle &b)
Definition: double_single.h:30
__host__ __device__ void dsadd(float2 &c, const float2 &a, const float2 &b)
Definition: double_single.h:3
__host__ __device__ void operator+=(const double2 &b)
Definition: double_single.h:40
__host__ __device__ void operator+=(const doublesingle2 &b)
Definition: double_single.h:41
doublesingle y
Definition: double_single.h:37
__host__ __device__ doublesingle2 & operator=(const double &a)
Definition: double_single.h:38
doublesingle x
Definition: double_single.h:36
__host__ __device__ void operator+=(const double3 &b)
Definition: double_single.h:51
doublesingle x
Definition: double_single.h:48
doublesingle y
Definition: double_single.h:49
doublesingle z
Definition: double_single.h:50
__host__ __device__ void operator+=(const doublesingle3 &b)
Definition: double_single.h:52
__host__ __device__ doublesingle(const doublesingle &b)
Definition: double_single.h:15
__host__ __device__ doublesingle(const float a)
Definition: double_single.h:16
__host__ __device__ doublesingle()
Definition: double_single.h:14
__host__ __device__ void operator+=(const doublesingle &b)
Definition: double_single.h:18
__host__ __device__ void operator+=(const float &b)
Definition: double_single.h:19
__host__ __device__ doublesingle & operator=(const doublesingle &b)
Definition: double_single.h:23
__host__ __device__ doublesingle & operator=(const float &b)
Definition: double_single.h:26