DD-AVX  2.0.0
vector_add_d.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(data()[i]);
23 
24  reg b_hi = load(vec1.hi[i]);
25  reg b_lo = load(vec1.lo[i]);
26 
27  reg c_hi = load(vec2.hi[i]);
28  reg c_lo = load(vec2.lo[i]);
29 
30  Add(a_hi, b_hi, b_lo, c_hi, c_lo, regs);
31 
32  store(data()[i], a_hi);
33  }
34  for(;i<ie;i++){
35  Add(data()[i], vec1.hi[i], vec1.lo[i], vec2.hi[i], vec2.lo[i]);
36  }
37  }
38 }
39 
41 {
42  if(size() != vec1.size() || size() != vec2.size()){
43  std::cerr << "error bad vector size" << std::endl;
44  assert(1);
45  }
46  registers regs;
47  double *vv = data();
48 
49 #pragma omp parallel private(regs)
50  {
51  int i=0, is=0, ie=0;
52  get_isie(size(), is, ie);
53  for(i = is; i < (ie-SIMD_Length+1); i += SIMD_Length){
54  reg a_hi = load(data()[i]);
55 
56  reg b_hi = load(vec1.data()[i]);
57  reg b_lo = regs.zeros;
58 
59  reg c_hi = load(vec2.hi[i]);
60  reg c_lo = load(vec2.lo[i]);
61 
62  Add(a_hi, b_hi, b_lo, c_hi, c_lo, regs);
63 
64  store(data()[i], a_hi);
65  }
66  for(;i<ie;i++){
67  Add(data()[i], vec1.data()[i], 0.0, vec2.hi[i], vec2.lo[i]);
68  }
69  }
70 }
71 
73 {
74  add(vec2, vec1);
75 }
76 
78 {
79  if(size() != vec1.size() || size() != vec2.size()){
80  std::cerr << "error bad vector size" << std::endl;
81  assert(1);
82  }
83 
84 #pragma omp parallel for
85  for(int i = 0; i < size(); i++){
86  data()[i] = vec1.data()[i] + vec2.data()[i];
87 
88  }
89 }
90 
91 //=========================================================
92 // operator
93 //=========================================================
95 {
96  add(*this, vec);
97  return *this;
98 }
100 {
101  add(*this, vec);
102  return *this;
103 }
104 
106 {
107  add(*this, vec);
108  return *this;
109 }
111 {
112  add(*this, vec);
113  return *this;
114 }
115 
Double precision vector class, This class is almost same as std::vector<double>
d_real_vector operator+=(dd_real_vector &vec)
all elemetnt arithmetic function
d_real_vector operator+(dd_real_vector &vec)
all elemetnt arithmetic function
void add(dd_real_vector &vec1, dd_real_vector &vec2)
all elemetnt arithmetic function
Definition: vector_add_d.cpp:9
Double-double precision vector class.
std::vector< double > lo
int size() const
get size
std::vector< double > hi