QDP++
qdp_scalarsite_sse_blas_wrapper.h
Go to the documentation of this file.
1#ifndef QDP_SCALARSITE_SSE_BLAS_WRAPPER_H
2#define QDP_SCALARSITE_SSE_BLAS_WRAPPER_H
3
5// Threading evaluates wrappers
6//
7// by Xu Guo, EPCC, 6 October, 2008
9
10//
11// vaxOpy3: for vaxpy3 and vaxmy3
12//
13
14// structure for vaxOpy3 of having order
22
23// user func for vaxOpy3 of having order
24inline
26
27 REAL32* Out = a->Out;
28 REAL32* scalep = a->scalep;
29 REAL32* InScale = a->InScale;
30 REAL32* Opt = a->Opt;
31 void (*func)(REAL32*, REAL32*, REAL32*, REAL32*, int) = a->func;
32
33 int n_3vec = (hi - lo); // no of numbers
34
35 int index = lo; // Rescale to real32
36
37 InScale = &InScale[24*index];
38 Opt = &Opt[24*index];
39 Out = &Out[24*index];
40
41 func(Out, scalep, InScale, Opt, n_3vec);
42}
43
44// structure for vaxOpy3 (with yptr only) of NOT having order
46 unordered_sse_vaxOpy3_y_user_arg( const OLattice< TVec >& x_,
47 OLattice< TVec >& d_,
48 REAL32* scalep_,
49 const int* tab_,
50 int xy_order_,
51 void (*func_)(REAL32*, REAL32*, REAL32*, REAL32*, int))
52 :x(x_),d(d_),scalep(scalep_),tab(tab_),xy_order(xy_order_),func(func_) {}
53
54 const OLattice< TVec >& x;
55 OLattice< TVec >& d;
57 const int* tab;
59 void (*func)(REAL32*, REAL32*, REAL32*, REAL32*, int);
60};
61
62// user func for vaxOpy3 (with yptr only) of NOT having order
63inline
65
66 const OLattice< TVec >& x = a->x;
67 OLattice< TVec >& d = a->d;
68 REAL32* scalep = a->scalep;
69 const int* tab = a->tab;
70 int xy_order = a->xy_order;
71 void (*func)(REAL32*, REAL32*, REAL32*, REAL32*, int) = a->func;
72
73 if (xy_order){
74 for(int j=lo; j < hi; j++) {
75 int i=tab[j];
76 REAL32* xptr = (REAL32 *)&(x.elem(i).elem(0).elem(0).real());
77 REAL32* yptr = &(d.elem(i).elem(0).elem(0).real());
78 func(yptr, scalep, xptr, yptr, 1);
79 }
80 }
81 else {
82 for(int j=lo; j < hi; j++) {
83 int i=tab[j];
84 REAL32* xptr = (REAL32 *)&(x.elem(i).elem(0).elem(0).real());
85 REAL32* yptr = &(d.elem(i).elem(0).elem(0).real());
86 func(yptr, scalep, yptr, xptr, 1);
87 }
88 }
89
90
91}
92
93// structure for vaxOpy3 (with zptr) of NOT having order
96 const OLattice< TVec >& x_,
97 const OLattice< TVec >& y_,
98 OLattice< TVec >& d_,
99 REAL32* scalep_,
100 const int* tab_,
101 void (*func_)(REAL32*, REAL32*, REAL32*, REAL32*, int))
102 : x(x_),y(y_),d(d_),scalep(scalep_),tab(tab_),func(func_) {}
103
104
105 const OLattice< TVec >& x;
106 const OLattice< TVec >& y;
107 OLattice< TVec >& d;
109 const int* tab;
110 void (*func)(REAL32*, REAL32*, REAL32*, REAL32*, int);
111};
112
113// user func for vaxpy3 (with zptr only) of NOT having order
114inline
116
117 const OLattice< TVec >& x = a->x;
118 const OLattice< TVec >& y = a->y;
119 OLattice< TVec >& d = a->d;
120 REAL32* scalep = a->scalep;
121 const int* tab = a->tab;
122 void (*func)(REAL32*, REAL32*, REAL32*, REAL32*, int) = a->func;
123
124 for(int j=lo; j < hi; j++) {
125 int i=tab[j];
126 REAL32* xptr = (REAL32 *)&(x.elem(i).elem(0).elem(0).real());
127 REAL32* yptr = (REAL32 *)&(y.elem(i).elem(0).elem(0).real());
128 REAL32* zptr = &(d.elem(i).elem(0).elem(0).real());
129 func(zptr, scalep, xptr, yptr, 1);
130 }
131
132}
133
134
135
136
137//
138// vOp: for vadd and vsub
139//
140
141// structure for vOp of having order
148
149// user func for vOp of having order
150inline
152
153 REAL32* Out = a->Out;
154 REAL32* In1 = a->In1;
155 REAL32* In2 = a->In2;
156 void (*func)(REAL32*, REAL32*, REAL32*, int) = a->func;
157
158 int n_3vec = hi - lo;
159
160 int index = lo;
161 In1 = &In1[24*index];
162 In2 = &In2[24*index];
163 Out = &Out[24*index];
164
165 func(Out, In1, In2, n_3vec);
166}
167
168// structure for vOp (with yptr only) of NOT having order
171 const OLattice< TVec >& x_,
172 OLattice< TVec >& d_,
173 const int* tab_,
174 void (*func_)(REAL32*, REAL32*, REAL32*, int))
175 : x(x_),d(d_),tab(tab_),func(func_) {}
176
177 const OLattice< TVec >& x;
178 OLattice< TVec >& d;
179 const int* tab;
180 void (*func)(REAL32*, REAL32*, REAL32*, int);
181};
182
183// user func for vOp (with yptr only) of NOT having order
184inline
186
187 const OLattice< TVec >& x = a->x;
188 OLattice< TVec >& d = a->d;
189 const int* tab = a->tab;
190 void (*func)(REAL32*, REAL32*, REAL32*, int) = a->func;
191
192
193 for(int j=lo; j < hi; j++) {
194 int i = tab[j];
195 REAL32 *xptr = (REAL32 *)(&x.elem(i).elem(0).elem(0).real());
196 REAL32 *yptr = (REAL32 *)(&d.elem(i).elem(0).elem(0).real());
197 func(yptr, yptr, xptr,1);
198 }
199
200}
201
202// structure for vOp (with zptr) of NOT having order
205 const OLattice< TVec >& x_,
206 const OLattice< TVec >& y_,
207 OLattice< TVec >& d_,
208 const int* tab_,
209 void (*func_)(REAL32*, REAL32*, REAL32*, int))
210 : x(x_),y(y_),d(d_),tab(tab_),func(func_) {}
211 const OLattice< TVec >& x;
212 const OLattice< TVec >& y;
213 OLattice< TVec >& d;
214 const int* tab;
215 void (*func)(REAL32*, REAL32*, REAL32*, int);
216};
217
218// user func for vOp (with zptr only) of NOT having order
219inline
221
222 const OLattice< TVec >& x = a->x;
223 const OLattice< TVec >& y = a->y;
224 OLattice< TVec >& d = a->d;
225 const int* tab = a->tab;
226 void (*func)(REAL32*, REAL32*, REAL32*, int) = a->func;
227
228 for(int j=lo; j < hi; j++) {
229 int i = tab[j];
230 REAL32 *xptr = (REAL32 *) &(x.elem(i).elem(0).elem(0).real());
231 REAL32 *yptr = (REAL32 *) &(y.elem(i).elem(0).elem(0).real());
232 REAL32* zptr = &(d.elem(i).elem(0).elem(0).real());
233
234 // Get the no of 3vecs. s.start() and s.end() are inclusive so add +1
235 func(zptr, xptr, yptr, 1);
236
237 }
238
239}
240
241
242
243//
244// vscal
245//
246
247// structure for vscal of having order
253
254// user func for vscal of having order
255inline
257
258 REAL32* Out = a->Out;
259 REAL32* scalep = a->scalep;
260 REAL32* In = a->In;
261
262 int n_3vec = hi - lo;
263 int index = lo;
264 Out = &Out[24*index];
265 In = &In[24*index];
266 vscal(Out, scalep, In, n_3vec);
267}
268
269// structure for vscal of NOT having order
272 const OLattice< TVec >& x_,
273 OLattice< TVec >& d_,
274 REAL32* scalep_,
275 const int* tab_) : x(x_),d(d_),scalep(scalep_),tab(tab_) {}
276 const OLattice< TVec >& x;
277 OLattice< TVec >& d;
279 const int* tab;
280};
281
282// user func for vscal of NOT having order
283inline
285
286 const OLattice< TVec >& x = a->x;
287 OLattice< TVec >& d = a->d;
288 REAL32* scalep = a->scalep;
289 const int* tab = a->tab;
290
291 for(int j=lo; j < hi; j++) {
292 int i=tab[j];
293 REAL32* xptr = (REAL32 *) &(x.elem(i).elem(0).elem(0).real());
294 REAL32* zptr = &(d.elem(i).elem(0).elem(0).real());
295 vscal(zptr, scalep, xptr, 1);
296 }
297
298}
299
300
301
302//
303// vaxOpby3: for vaxpby3 and vaxmby3
304//
305
306// structure for vaxOpby3 of having order
315
316// user func for vaxOpby3 of having order
317inline
319
320 REAL32* zptr = arg->zptr;
321 REAL32* aptr = arg->aptr;
322 REAL32* xptr = arg->xptr;
323 REAL32* bptr = arg->bptr;
324 REAL32* yptr = arg->yptr;
325 void (*func)(REAL32*, REAL32*, REAL32*, REAL32*, REAL32*, int) = arg->func;
326
327 int n_3vec = (hi - lo);
328
329 int index = 24*lo;
330 zptr = &zptr[index];
331 xptr = &xptr[index];
332 yptr = &yptr[index];
333
334 func(zptr, aptr, xptr, bptr, yptr, n_3vec);
335}
336
337// structure for vaxOpby3 of NOT having order
340 REAL32* aptr_,
341 const OLattice< TVec >& x_,
342 REAL32* bptr_,
343 const OLattice< TVec >& y_,
344 OLattice< TVec >& d_,
345 const int* tab_,
346 void (*func_)(REAL32*, REAL32*, REAL32*, REAL32*, REAL32*, int))
347 : aptr(aptr_),x(x_),bptr(bptr_),y(y_),d(d_),tab(tab_),func(func_) {}
348
349
351 const OLattice< TVec >& x;
353 const OLattice< TVec >& y;
354 OLattice< TVec >& d;
355 const int* tab;
356 void (*func)(REAL32*, REAL32*, REAL32*, REAL32*, REAL32*, int);
357};
358
359// user func for vaxOpby3 of NOT having order
360inline
362 REAL32* aptr = arg->aptr;
363 const OLattice< TVec >& x = arg->x;
364 REAL32* bptr = arg->bptr;
365 const OLattice< TVec >& y = arg->y;
366 OLattice< TVec >& d = arg->d;
367 const int* tab = arg->tab;
368 void (*func)(REAL32*, REAL32*, REAL32*, REAL32*, REAL32*, int) = arg->func;
369
370
371 for(int j=lo; j < hi; j++) {
372 int i = tab[j];
373
374 REAL32 *xptr = (REAL32 *) &(x.elem(i).elem(0).elem(0).real());
375 REAL32 *yptr = (REAL32 *) &(y.elem(i).elem(0).elem(0).real());
376 REAL32 * zptr = &(d.elem(i).elem(0).elem(0).real());
377
378 func(zptr, aptr, xptr, bptr, yptr, 1);
379
380 }
381
382}
383
384
386 REAL32* vptr; // Single Prec vector
387 REAL64* results; // Always store sums in doubles
388 void (*func)(REAL64*, REAL32*, int);
389};
390
391inline void ordered_norm_single_func(int lo, int hi, int myId, ordered_sse_norm_single_user_arg* a)
392 {
393
394 int nvec = hi - lo;
395 int index = 24*lo;
396 REAL32* vptr = &(a->vptr[index]);
397 void (*func)(REAL64*, REAL32*, int) = a->func;
398 func( &(a->results[myId]), vptr, nvec);
399 }
400
401#endif
MakeReturn< UnaryNode< FnReal, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnReal >::Type_t >::Expression_t real(const QDPExpr< T1, C1 > &l)
double REAL64
float REAL32
void unordered_sse_vscal_evaluate_function(int lo, int hi, int myId, unordered_sse_vscal_user_arg *a)
void unordered_sse_vOp_y_evaluate_function(int lo, int hi, int myId, unordered_sse_vOp_y_user_arg *a)
void unordered_vOp_z_evaluate_function(int lo, int hi, int myId, unordered_sse_vOp_z_user_arg *a)
void unordered_sse_vaxOpy3_y_evaluate_function(int lo, int hi, int myId, unordered_sse_vaxOpy3_y_user_arg *a)
void unordered_sse_vaxOpby3_evaluate_function(int lo, int hi, int myId, unordered_sse_vaxOpby3_user_arg *arg)
void unordered_sse_vaxOpy3_z_evaluate_function(int lo, int hi, int myId, unordered_sse_vaxOpy3_z_user_arg *a)
void ordered_norm_single_func(int lo, int hi, int myId, ordered_sse_norm_single_user_arg *a)
void ordered_sse_vaxOpy3_evaluate_function(int lo, int hi, int myId, ordered_sse_vaxOpy3_user_arg *a)
void ordered_sse_vOp_evaluate_function(int lo, int hi, int myId, ordered_sse_vOp_user_arg *a)
void ordered_sse_vaxOpby3_evaluate_function(int lo, int hi, int myId, ordered_sse_vaxOpby3_user_arg *arg)
void ordered_sse_vscal_evaluate_function(int lo, int hi, int myId, ordered_sse_vscal_user_arg *a)
void(* func)(REAL32 *, REAL32 *, REAL32 *, int)
void(* func)(REAL32 *, REAL32 *, REAL32 *, REAL32 *, REAL32 *, int)
void(* func)(REAL32 *, REAL32 *, REAL32 *, REAL32 *, int)
unordered_sse_vOp_y_user_arg(const OLattice< TVec > &x_, OLattice< TVec > &d_, const int *tab_, void(*func_)(REAL32 *, REAL32 *, REAL32 *, int))
void(* func)(REAL32 *, REAL32 *, REAL32 *, int)
void(* func)(REAL32 *, REAL32 *, REAL32 *, int)
unordered_sse_vOp_z_user_arg(const OLattice< TVec > &x_, const OLattice< TVec > &y_, OLattice< TVec > &d_, const int *tab_, void(*func_)(REAL32 *, REAL32 *, REAL32 *, int))
unordered_sse_vaxOpby3_user_arg(REAL32 *aptr_, const OLattice< TVec > &x_, REAL32 *bptr_, const OLattice< TVec > &y_, OLattice< TVec > &d_, const int *tab_, void(*func_)(REAL32 *, REAL32 *, REAL32 *, REAL32 *, REAL32 *, int))
void(* func)(REAL32 *, REAL32 *, REAL32 *, REAL32 *, REAL32 *, int)
void(* func)(REAL32 *, REAL32 *, REAL32 *, REAL32 *, int)
unordered_sse_vaxOpy3_y_user_arg(const OLattice< TVec > &x_, OLattice< TVec > &d_, REAL32 *scalep_, const int *tab_, int xy_order_, void(*func_)(REAL32 *, REAL32 *, REAL32 *, REAL32 *, int))
unordered_sse_vaxOpy3_z_user_arg(const OLattice< TVec > &x_, const OLattice< TVec > &y_, OLattice< TVec > &d_, REAL32 *scalep_, const int *tab_, void(*func_)(REAL32 *, REAL32 *, REAL32 *, REAL32 *, int))
void(* func)(REAL32 *, REAL32 *, REAL32 *, REAL32 *, int)
unordered_sse_vscal_user_arg(const OLattice< TVec > &x_, OLattice< TVec > &d_, REAL32 *scalep_, const int *tab_)