DD-AVX  2.0.0
vector_add_dd.cpp
Go to the documentation of this file.
1 #include<DD-AVX_internal.hpp>
2 
3 using namespace ddavx_core;
4 
5 //=========================================================
6 // function
7 //=========================================================
8 
10 {
11  if(size() != vec1.size() || size() != vec2.size()){
12  std::cerr << "error bad vector size" << std::endl;
13  assert(1);
14  }
15  registers regs;
16 
17 #pragma omp parallel private(regs)
18  {
19  int i=0, is=0, ie=0;
20  get_isie(size(), is, ie);
21  for(i = is; i < (ie-SIMD_Length+1); i += SIMD_Length){
22  reg a_hi = load(hi[i]);
23  reg a_lo = load(lo[i]);
24 
25  reg b_hi = load(vec1.hi[i]);
26  reg b_lo = load(vec1.lo[i]);
27 
28  reg c_hi = load(vec2.hi[i]);
29  reg c_lo = load(vec2.lo[i]);
30 
31  Add(a_hi, a_lo, b_hi, b_lo, c_hi, c_lo, regs);
32 
33  store(hi[i], a_hi);
34  store(lo[i], a_lo);
35  }
36  for(;i<ie;i++){
37  Add(hi[i], lo[i], vec1.hi[i], vec1.lo[i], vec2.hi[i], vec2.lo[i]);
38  }
39  }
40 }
41 
43 {
44  if(size() != vec1.size() || size() != vec2.size()){
45  std::cerr << "error bad vector size" << std::endl;
46  assert(1);
47  }
48  registers regs;
49 
50 #pragma omp parallel private(regs)
51  {
52  int i=0, is=0, ie=0;
53  get_isie(size(), is, ie);
54  for(i = is; i < (ie-SIMD_Length+1); i += SIMD_Length){
55  reg a_hi = load(hi[i]);
56  reg a_lo = load(lo[i]);
57 
58  reg b_hi = load(vec1.data()[i]);
59  reg b_lo = regs.zeros;
60 
61  reg c_hi = load(vec2.hi[i]);
62  reg c_lo = load(vec2.lo[i]);
63 
64  Add(a_hi, a_lo, b_hi, b_lo, c_hi, c_lo, regs);
65 
66  store(hi[i], a_hi);
67  store(lo[i], a_lo);
68  }
69  for(;i<ie;i++){
70  Add(hi[i], lo[i], vec1.data()[i], 0.0, vec2.hi[i], vec2.lo[i]);
71  }
72  }
73 }
74 
75 
77 {
78  add(vec2, vec1);
79 }
80 
82 {
83  if(size() != vec1.size() || size() != vec2.size()){
84  std::cerr << "error bad vector size" << std::endl;
85  assert(1);
86  }
87  registers regs;
88 
89 #pragma omp parallel private(regs)
90  {
91  int i=0, is=0, ie=0;
92  get_isie(size(), is, ie);
93  for(i = is; i < (ie-SIMD_Length+1); i += SIMD_Length){
94  reg a_hi = load(hi[i]);
95  reg a_lo = load(lo[i]);
96 
97  reg b_hi = load(vec1.data()[i]);
98  reg b_lo = regs.zeros;
99 
100  reg c_hi = load(vec2.data()[i]);
101  reg c_lo = regs.zeros;
102 
103  Add(a_hi, a_lo, b_hi, b_lo, c_hi, c_lo, regs);
104 
105  store(hi[i], a_hi);
106  store(lo[i], a_lo);
107  }
108  for(;i<ie;i++){
109  Add(hi[i], lo[i], vec1.data()[i], 0.0, vec2.data()[i], 0.0);
110  }
111  }
112 }
113 
114 //=========================================================
115 // operator
116 //=========================================================
117 
119 {
120  add(*this, vec);
121  return *this;
122 }
123 
125 {
126  add(*this, vec);
127  return *this;
128 }
129 
131 {
132  add(*this, vec);
133  return *this;
134 }
135 
137 {
138  add(*this, vec);
139  return *this;
140 }
141 
Double precision vector class, This class is almost same as std::vector<double>
Double-double precision vector class.
std::vector< double > lo
int size() const
get size
dd_real_vector operator+=(dd_real_vector &vec)
all elemetnt arithmetic function
dd_real_vector operator+(dd_real_vector &vec)
all elemetnt arithmetic function
std::vector< double > hi
void add(dd_real_vector &vec1, dd_real_vector &vec2)
all elemetnt arithmetic function