real_vsx_2hv_template.c 60.9 KB
Newer Older
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
//    This file is part of ELPA.
//
//    The ELPA library was originally created by the ELPA consortium,
//    consisting of the following organizations:
//
//    - Max Planck Computing and Data Facility (MPCDF), formerly known as
//	Rechenzentrum Garching der Max-Planck-Gesellschaft (RZG),
//    - Bergische Universität Wuppertal, Lehrstuhl für angewandte
//	Informatik,
//    - Technische Universität München, Lehrstuhl für Informatik mit
//	Schwerpunkt Wissenschaftliches Rechnen ,
//    - Fritz-Haber-Institut, Berlin, Abt. Theorie,
//    - Max-Plack-Institut für Mathematik in den Naturwissenschaften,
//	Leipzig, Abt. Komplexe Strukutren in Biologie und Kognition,
//	and
//    - IBM Deutschland GmbH
//
//    This particular source code file contains additions, changes and
//    enhancements authored by Intel Corporation which is not part of
//    the ELPA consortium.
//
//    More information can be found here:
//    http://elpa.mpcdf.mpg.de/
//
//    ELPA is free software: you can redistribute it and/or modify
//    it under the terms of the version 3 of the license of the
//    GNU Lesser General Public License as published by the Free
//    Software Foundation.
//
//    ELPA is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public License
//    along with ELPA.	If not, see <http://www.gnu.org/licenses/>
//
//    ELPA reflects a substantial effort on the part of the original
//    ELPA consortium, and we ask you to respect the spirit of the
//    license that we chose: i.e., please contribute any changes you
//    may have back to the original ELPA library distribution, and keep
//    any derivatives of ELPA under the same license that we chose for
//    the original distribution, the GNU Lesser General Public License.
//
// Author: Andreas Marek, MPCDF, based on the double precision case of A. Heinecke
//

48
#ifdef HAVE_VSX_SSE
49
50
51
52
53
54
55
56
57
#include <altivec.h>
#endif
#include <stdio.h>
#include <stdlib.h>


#define __forceinline __attribute__((always_inline)) static
#ifdef DOUBLE_PRECISION_REAL
#define __SSE_DATATYPE __vector double
58
#define _SSE_LOAD (__vector double) vec_ld
59
60
61
62
63
64
65
66
67
#define _SSE_ADD vec_add
#define _SSE_MUL vec_mul
#define _SSE_NEG vec_neg
#define _SSE_STORE vec_st
#define offset 2
#endif

#ifdef SINGLE_PRECISION_REAL
#define __SSE_DATATYPE __vector float
68
#define _SSE_LOAD  (__vector float) vec_ld
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#define _SSE_ADD vec_add
#define _SSE_MUL vec_mul
#define _SSE_NEG vec_neg
#define _SSE_STORE vec_st
#define offset 4
#endif


#ifdef HAVE_SSE_INTRINSICS
#undef __AVX__
#endif

//Forward declaration
#ifdef DOUBLE_PRECISION_REAL
__forceinline void hh_trafo_kernel_2_VSX_2hv_double(double* q, double* hh, int nb, int ldq, int ldh, double s);
__forceinline void hh_trafo_kernel_4_VSX_2hv_double(double* q, double* hh, int nb, int ldq, int ldh, double s);
__forceinline void hh_trafo_kernel_6_VSX_2hv_double(double* q, double* hh, int nb, int ldq, int ldh, double s);
__forceinline void hh_trafo_kernel_8_VSX_2hv_double(double* q, double* hh, int nb, int ldq, int ldh, double s);
__forceinline void hh_trafo_kernel_10_VSX_2hv_double(double* q, double* hh, int nb, int ldq, int ldh, double s);
__forceinline void hh_trafo_kernel_12_VSX_2hv_double(double* q, double* hh, int nb, int ldq, int ldh, double s);
#endif
#ifdef SINGLE_PRECISION_REAL
__forceinline void hh_trafo_kernel_4_VSX_2hv_single(float* q, float* hh, int nb, int ldq, int ldh, float s);
__forceinline void hh_trafo_kernel_8_VSX_2hv_single(float* q, float* hh, int nb, int ldq, int ldh, float s);
__forceinline void hh_trafo_kernel_12_VSX_2hv_single(float* q, float* hh, int nb, int ldq, int ldh, float s);
__forceinline void hh_trafo_kernel_16_VSX_2hv_single(float* q, float* hh, int nb, int ldq, int ldh, float s);
__forceinline void hh_trafo_kernel_20_VSX_2hv_single(float* q, float* hh, int nb, int ldq, int ldh, float s);
__forceinline void hh_trafo_kernel_24_VSX_2hv_single(float* q, float* hh, int nb, int ldq, int ldh, float s);
#endif


#ifdef DOUBLE_PRECISION_REAL
void double_hh_trafo_real_VSX_2hv_double(double* q, double* hh, int* pnb, int* pnq, int* pldq, int* pldh);
#endif
#ifdef SINGLE_PRECISION_REAL
void double_hh_trafo_real_VSX_2hv_single_(float* q, float* hh, int* pnb, int* pnq, int* pldq, int* pldh);
#endif

/*
!f>#ifdef HAVE_VSX_SSE
!f> interface
!f>   subroutine double_hh_trafo_real_vsx_2hv_double(q, hh, pnb, pnq, pldq, pldh) &
!f>				bind(C, name="double_hh_trafo_real_vsx_2hv_double")
!f>	use, intrinsic :: iso_c_binding
!f>	integer(kind=c_int) :: pnb, pnq, pldq, pldh
!f>	type(c_ptr), value  :: q
!f>	real(kind=c_double) :: hh(pnb,6)
!f>   end subroutine
!f> end interface
!f>#endif
*/

/*
!f>#ifdef HAVE_VSX_SSE
!f> interface
!f>   subroutine double_hh_trafo_real_vsx_2hv_single(q, hh, pnb, pnq, pldq, pldh) &
!f>				bind(C, name="double_hh_trafo_real_vsx_2hv_single")
!f>	use, intrinsic :: iso_c_binding
!f>	integer(kind=c_int)	:: pnb, pnq, pldq, pldh
!f>	type(c_ptr), value	:: q
!f>	real(kind=c_float)	:: hh(pnb,6)
!f>   end subroutine
!f> end interface
!f>#endif
*/

#ifdef DOUBLE_PRECISION_REAL
void double_hh_trafo_real_vsx_2hv_double(double* q, double* hh, int* pnb, int* pnq, int* pldq, int* pldh)
#endif
#ifdef SINGLE_PRECISION_REAL
void double_hh_trafo_real_vsx_2hv_single(float* q, float* hh, int* pnb, int* pnq, int* pldq, int* pldh)
#endif
{
	int i;
	int nb = *pnb;
	int nq = *pldq;
	int ldq = *pldq;
	int ldh = *pldh;
	int worked_on;

	worked_on = 0;

	// calculating scalar product to compute
	// 2 householder vectors simultaneously
#ifdef DOUBLE_PRECISION_REAL
	double s = hh[(ldh)+1]*1.0;
#endif
#ifdef SINGLE_PRECISION_REAL
	float s = hh[(ldh)+1]*1.0;
#endif

#ifdef HAVE_SSE_INTRINSICS
	#pragma ivdep
#endif
	for (i = 2; i < nb; i++)
	{
		s += hh[i-1] * hh[(i+ldh)];
	}

	// Production level kernel calls with padding
#ifdef DOUBLE_PRECISION_REAL
	for (i = 0; i < nq-10; i+=12)
	{
		hh_trafo_kernel_12_VSX_2hv_double(&q[i], hh, nb, ldq, ldh, s);
		worked_on += 12;
	}
#endif
#ifdef SINGLE_PRECISION_REAL
	for (i = 0; i < nq-20; i+=24)
	{
		hh_trafo_kernel_24_VSX_2hv_single(&q[i], hh, nb, ldq, ldh, s);
		worked_on += 24;
	}
#endif

	if (nq == i)
	{
		return;
	}

#ifdef DOUBLE_PRECISION_REAL
	if (nq-i == 10)
	{
		hh_trafo_kernel_10_VSX_2hv_double(&q[i], hh, nb, ldq, ldh, s);
		worked_on += 10;
	}
#endif

#ifdef SINGLE_PRECISION_REAL
	if (nq-i == 20)
	{
		hh_trafo_kernel_20_VSX_2hv_single(&q[i], hh, nb, ldq, ldh, s);
		worked_on += 20;
	}
#endif

#ifdef DOUBLE_PRECISION_REAL
	if (nq-i == 8)
	{
		hh_trafo_kernel_8_VSX_2hv_double(&q[i], hh, nb, ldq, ldh, s);
		worked_on += 8;
	}
#endif

#ifdef SINGLE_PRECISION_REAL
	if (nq-i == 16)
	{
		hh_trafo_kernel_16_VSX_2hv_single(&q[i], hh, nb, ldq, ldh, s);
		worked_on += 16;
	}
#endif


#ifdef DOUBLE_PRECISION_REAL
	if (nq-i == 6)
	{
		hh_trafo_kernel_6_VSX_2hv_double(&q[i], hh, nb, ldq, ldh, s);
		worked_on += 6;
	}
#endif

#ifdef SINGLE_PRECISION_REAL
	if (nq-i == 12)
	{
		hh_trafo_kernel_12_VSX_2hv_single(&q[i], hh, nb, ldq, ldh, s);
		worked_on += 12;
	}
#endif

#ifdef DOUBLE_PRECISION_REAL
	if (nq-i == 4)
	{
		hh_trafo_kernel_4_VSX_2hv_double(&q[i], hh, nb, ldq, ldh, s);
		worked_on += 4;
	}
#endif

#ifdef SINGLE_PRECISION_REAL
	if (nq-i == 8)
	{
		hh_trafo_kernel_8_VSX_2hv_single(&q[i], hh, nb, ldq, ldh, s);
		worked_on += 8;
	}
#endif

#ifdef DOUBLE_PRECISION_REAL
	if (nq-i == 2)
	{
		hh_trafo_kernel_2_VSX_2hv_double(&q[i], hh, nb, ldq, ldh, s);
		worked_on += 2;
	}
#endif

#ifdef SINGLE_PRECISION_REAL
	if (nq-i == 4)
	{
		hh_trafo_kernel_4_VSX_2hv_single(&q[i], hh, nb, ldq, ldh, s);
		worked_on += 4;
	}
#endif
#ifdef WITH_DEBUG
	if (worked_on != nq)
	{
		printf("Error in real VSX BLOCK2 kernel %d %d\n", worked_on, nq);
		abort();
	}
#endif
}

/**
 * Unrolled kernel that computes
#ifdef DOUBLE_PRECISION_REAL
 * 12 rows of Q simultaneously, a
#endif
#ifdef SINGLE_PRECISION_REAL
 * 24 rows of Q simultaneously, a
#endif
 * matrix Vector product with two householder
 * vectors + a rank 2 update is performed
 */
#ifdef DOUBLE_PRECISION_REAL
 __forceinline void hh_trafo_kernel_12_VSX_2hv_double(double* q, double* hh, int nb, int ldq, int ldh, double s)
#endif
#ifdef SINGLE_PRECISION_REAL
 __forceinline void hh_trafo_kernel_24_VSX_2hv_single(float* q, float* hh, int nb, int ldq, int ldh, float s)
#endif
{
	/////////////////////////////////////////////////////
	// Matrix Vector Multiplication, Q [12 x nb+1] * hh
	// hh contains two householder vectors, with offset 1
	/////////////////////////////////////////////////////
	int i;
301
302
303
304
305
306
307
#ifdef DOUBLE_PRECISION_REAL
	double mone = 1.0;
#endif
#ifdef SINGLE_PRECISION_REAL
	float mone = 1.0;
#endif

308
309
310
311
312
313
314
315
316
317
#ifdef HAVE_SSE_INTRINSICS
	// Needed bit mask for floating point sign flip
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE sign = (__SSE_DATATYPE)_mm_set1_epi64x(0x8000000000000000LL);
#endif
#ifdef SINGLE_PRECISION_REAL
        __SSE_DATATYPE sign = _mm_castsi128_ps(_mm_set_epi32(0x80000000, 0x80000000, 0x80000000, 0x80000000));
#endif
#endif

318
319
320
321
322
323
	__SSE_DATATYPE x1 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq]);
	__SSE_DATATYPE x2 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+offset]);
	__SSE_DATATYPE x3 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+2*offset]);
	__SSE_DATATYPE x4 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+3*offset]);
	__SSE_DATATYPE x5 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+4*offset]);
	__SSE_DATATYPE x6 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+5*offset]);
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343

#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE h1 = _mm_set1_pd(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	__SSE_DATATYPE h1 = _mm_set1_ps(hh[ldh+1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
        __SSE_DATATYPE h1 = vec_splats(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
        __SSE_DATATYPE h1 = vec_splats(hh[ldh+1]);
#endif
#endif

	__SSE_DATATYPE h2;

344
	__SSE_DATATYPE q1 = _SSE_LOAD(0, (unsigned long int *)  &q[0]);
345
	__SSE_DATATYPE y1 = _SSE_ADD(q1, _SSE_MUL(x1, h1));
346
	__SSE_DATATYPE q2 = _SSE_LOAD(0, (unsigned long int *)  &q[offset]);
347
	__SSE_DATATYPE y2 = _SSE_ADD(q2, _SSE_MUL(x2, h1));
348
	__SSE_DATATYPE q3 = _SSE_LOAD(0, (unsigned long int *)  &q[2*offset]);
349
	__SSE_DATATYPE y3 = _SSE_ADD(q3, _SSE_MUL(x3, h1));
350
	__SSE_DATATYPE q4 = _SSE_LOAD(0, (unsigned long int *)  &q[3*offset]);
351
	__SSE_DATATYPE y4 = _SSE_ADD(q4, _SSE_MUL(x4, h1));
352
	__SSE_DATATYPE q5 = _SSE_LOAD(0, (unsigned long int *)  &q[4*offset]);
353
	__SSE_DATATYPE y5 = _SSE_ADD(q5, _SSE_MUL(x5, h1));
354
	__SSE_DATATYPE q6 = _SSE_LOAD(0, (unsigned long int *)  &q[5*offset]);
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
	__SSE_DATATYPE y6 = _SSE_ADD(q6, _SSE_MUL(x6, h1));
	for(i = 2; i < nb; i++)
	{
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
		h1 = _mm_set1_pd(hh[i-1]);
		h2 = _mm_set1_pd(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = _mm_set1_ps(hh[i-1]);
		h2 = _mm_set1_ps(hh[ldh+i]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#endif

379
		q1 = _SSE_LOAD(0, (unsigned long int *)  &q[i*ldq]);
380
381
		x1 = _SSE_ADD(x1, _SSE_MUL(q1,h1));
		y1 = _SSE_ADD(y1, _SSE_MUL(q1,h2));
382
		q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+offset]);
383
384
		x2 = _SSE_ADD(x2, _SSE_MUL(q2,h1));
		y2 = _SSE_ADD(y2, _SSE_MUL(q2,h2));
385
		q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+2*offset]);
386
387
		x3 = _SSE_ADD(x3, _SSE_MUL(q3,h1));
		y3 = _SSE_ADD(y3, _SSE_MUL(q3,h2));
388
		q4 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+3*offset]);
389
390
		x4 = _SSE_ADD(x4, _SSE_MUL(q4,h1));
		y4 = _SSE_ADD(y4, _SSE_MUL(q4,h2));
391
		q5 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+4*offset]);
392
393
		x5 = _SSE_ADD(x5, _SSE_MUL(q5,h1));
		y5 = _SSE_ADD(y5, _SSE_MUL(q5,h2));
394
		q6 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+5*offset]);
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
		x6 = _SSE_ADD(x6, _SSE_MUL(q6,h1));
		y6 = _SSE_ADD(y6, _SSE_MUL(q6,h2));
	}
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	h1 = _mm_set1_pd(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h1 = _mm_set1_ps(hh[nb-1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	h1 = vec_splats(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
411
	h1 = vec_splats(hh[nb-1]);
412
413
414
#endif
#endif

415
	q1 = _SSE_LOAD(0, (unsigned long int *)  &q[nb*ldq]);
416
	x1 = _SSE_ADD(x1, _SSE_MUL(q1,h1));
417
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+offset]);
418
	x2 = _SSE_ADD(x2, _SSE_MUL(q2,h1));
419
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+2*offset]);
420
	x3 = _SSE_ADD(x3, _SSE_MUL(q3,h1));
421
	q4 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+3*offset]);
422
	x4 = _SSE_ADD(x4, _SSE_MUL(q4,h1));
423
	q5 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+4*offset]);
424
	x5 = _SSE_ADD(x5, _SSE_MUL(q5,h1));
425
	q6 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+5*offset]);
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
	x6 = _SSE_ADD(x6, _SSE_MUL(q6,h1));
	/////////////////////////////////////////////////////
	// Rank-2 update of Q [12 x nb+1]
	/////////////////////////////////////////////////////
#ifdef  HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE tau1 = _mm_set1_pd(hh[0]);
	__SSE_DATATYPE tau2 = _mm_set1_pd(hh[ldh]);
	__SSE_DATATYPE vs = _mm_set1_pd(s);
#endif
#ifdef SINGLE_PRECISION_REAL
	__SSE_DATATYPE tau1 = _mm_set1_ps(hh[0]);
	__SSE_DATATYPE tau2 = _mm_set1_ps(hh[ldh]);
	__SSE_DATATYPE vs = _mm_set1_ps(s);
#endif
#endif
#ifdef  HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE tau1 = vec_splats(hh[0]);
	__SSE_DATATYPE tau2 = vec_splats(hh[ldh]);
	__SSE_DATATYPE vs = vec_splats(s);
#endif
#ifdef SINGLE_PRECISION_REAL
	__SSE_DATATYPE tau1 = vec_splats(hh[0]);
	__SSE_DATATYPE tau2 = vec_splats(hh[ldh]);
451
	__SSE_DATATYPE vs = vec_splats(s);
452
453
454
455
456
457
458
#endif
#endif

#ifdef HAVE_SSE_INTRINSICS
	h1 = _SSE_XOR(tau1, sign);
#endif
#ifdef HAVE_VSX_SSE
459
460
	//h1 = vec_neg(tau1);
	h1 = vec_mul(vec_splats(mone), tau1);
461
462
463
464
465
466
467
468
469
470
471
#endif
	x1 = _SSE_MUL(x1, h1);
	x2 = _SSE_MUL(x2, h1);
	x3 = _SSE_MUL(x3, h1);
	x4 = _SSE_MUL(x4, h1);
	x5 = _SSE_MUL(x5, h1);
	x6 = _SSE_MUL(x6, h1);
#ifdef HAVE_SSE_INTRINSICS
	h1 = _SSE_XOR(tau2, sign);
#endif
#ifdef HAVE_SPARC64_SSE
472
473
	//h1 = vec_neg(tau2);
	h1 = vec_mul(vec_splats(mone), tau2);
474
475
476
477
478
479
480
481
482
#endif
	h2 = _SSE_MUL(h1, vs);

	y1 = _SSE_ADD(_SSE_MUL(y1,h1), _SSE_MUL(x1,h2));
	y2 = _SSE_ADD(_SSE_MUL(y2,h1), _SSE_MUL(x2,h2));
	y3 = _SSE_ADD(_SSE_MUL(y3,h1), _SSE_MUL(x3,h2));
	y4 = _SSE_ADD(_SSE_MUL(y4,h1), _SSE_MUL(x4,h2));
	y5 = _SSE_ADD(_SSE_MUL(y5,h1), _SSE_MUL(x5,h2));
	y6 = _SSE_ADD(_SSE_MUL(y6,h1), _SSE_MUL(x6,h2));
483
	q1 = _SSE_LOAD(0, (unsigned long int *) &q[0]);
484
	q1 = _SSE_ADD(q1, y1);
485
486
	_SSE_STORE((__vector unsigned int) q1, 0, (unsigned int *) &q[0]);
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[offset]);
487
	q2 = _SSE_ADD(q2, y2);
488
489
	_SSE_STORE((__vector unsigned int) q2, 0, (unsigned int *)  &q[offset]);
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[2*offset]);
490
	q3 = _SSE_ADD(q3, y3);
491
492
	_SSE_STORE((__vector unsigned int) q3, 0, (unsigned int *)  &q[2*offset]);
	q4 = _SSE_LOAD(0, (unsigned long int *)  &q[3*offset]);
493
	q4 = _SSE_ADD(q4, y4);
494
495
	_SSE_STORE((__vector unsigned int) q4, 0, (unsigned int *)  &q[3*offset]);
	q5 = _SSE_LOAD(0, (unsigned long int *)  &q[4*offset]);
496
	q5 = _SSE_ADD(q5, y5);
497
498
	_SSE_STORE((__vector unsigned int) q5, 0, (unsigned int *)  &q[4*offset]);
	q6 = _SSE_LOAD(0, (unsigned long int *)  &q[5*offset]);
499
	q6 = _SSE_ADD(q6, y6);
500
	_SSE_STORE((__vector unsigned int) q6, 0, (unsigned int *)  &q[5*offset]);
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519

#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	h2 = _mm_set1_pd(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h2 = _mm_set1_ps(hh[ldh+1]);
#endif
#endif

#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	h2 = vec_splats(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h2 = vec_splats(hh[ldh+1]);
#endif
#endif

520
	q1 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq]);
521
	q1 = _SSE_ADD(q1, _SSE_ADD(x1, _SSE_MUL(y1, h2)));
522
523
	_SSE_STORE((__vector unsigned int) q1, 0, (unsigned int *)  &q[ldq]);
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+offset]);
524
	q2 = _SSE_ADD(q2, _SSE_ADD(x2, _SSE_MUL(y2, h2)));
525
526
	_SSE_STORE((__vector unsigned int) q2, 0, (unsigned int *)  &q[ldq+offset]);
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+2*offset]);
527
	q3 = _SSE_ADD(q3, _SSE_ADD(x3, _SSE_MUL(y3, h2)));
528
529
	_SSE_STORE((__vector unsigned int) q3, 0, (unsigned int *)  &q[ldq+2*offset]);
	q4 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+3*offset]);
530
	q4 = _SSE_ADD(q4, _SSE_ADD(x4, _SSE_MUL(y4, h2)));
531
532
	_SSE_STORE((__vector unsigned int) q4, 0, (unsigned int *)  &q[ldq+3*offset]);
	q5 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+4*offset]);
533
	q5 = _SSE_ADD(q5, _SSE_ADD(x5, _SSE_MUL(y5, h2)));
534
535
	_SSE_STORE((__vector unsigned int) q5, 0, (unsigned int *)  &q[ldq+4*offset]);
	q6 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+5*offset]);
536
	q6 = _SSE_ADD(q6, _SSE_ADD(x6, _SSE_MUL(y6, h2)));
537
	_SSE_STORE((__vector unsigned int) q6, 0, (unsigned int *)  &q[ldq+5*offset]);
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561

	for (i = 2; i < nb; i++)
	{
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
		h1 = _mm_set1_pd(hh[i-1]);
		h2 = _mm_set1_pd(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = _mm_set1_ps(hh[i-1]);
		h2 = _mm_set1_ps(hh[ldh+i]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#endif

562
		q1 = _SSE_LOAD(0, (unsigned long int *)  &q[i*ldq]);
563
		q1 = _SSE_ADD(q1, _SSE_ADD(_SSE_MUL(x1,h1), _SSE_MUL(y1, h2)));
564
565
		_SSE_STORE((__vector unsigned int) q1, 0,  (unsigned int *)  &q[i*ldq]);
		q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+offset]);
566
		q2 = _SSE_ADD(q2, _SSE_ADD(_SSE_MUL(x2,h1), _SSE_MUL(y2, h2)));
567
568
		_SSE_STORE((__vector unsigned int) q2, 0, (unsigned int *)  &q[(i*ldq)+offset]);
		q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+2*offset]);
569
		q3 = _SSE_ADD(q3, _SSE_ADD(_SSE_MUL(x3,h1), _SSE_MUL(y3, h2)));
570
571
		_SSE_STORE((__vector unsigned int) q3, 0, (unsigned int *)  &q[(i*ldq)+2*offset]);
		q4 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+3*offset]);
572
		q4 = _SSE_ADD(q4, _SSE_ADD(_SSE_MUL(x4,h1), _SSE_MUL(y4, h2)));
573
574
		_SSE_STORE((__vector unsigned int) q4, 0, (unsigned int *)  &q[(i*ldq)+3*offset]);
		q5 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+4*offset]);
575
		q5 = _SSE_ADD(q5, _SSE_ADD(_SSE_MUL(x5,h1), _SSE_MUL(y5, h2)));
576
577
		_SSE_STORE((__vector unsigned int) q5, 0, (unsigned  int *)  &q[(i*ldq)+4*offset]);
		q6 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+5*offset]);
578
		q6 = _SSE_ADD(q6, _SSE_ADD(_SSE_MUL(x6,h1), _SSE_MUL(y6, h2)));
579
		_SSE_STORE((__vector unsigned int) q6, 0, (unsigned int *)  &q[(i*ldq)+5*offset]);
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
	}
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	h1 = _mm_set1_pd(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h1 = _mm_set1_ps(hh[nb-1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	h1 = vec_splats(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h1 = vec_splats(hh[nb-1]);
#endif
#endif


599
	q1 = _SSE_LOAD(0, (unsigned long int *)  &q[nb*ldq]);
600
	q1 = _SSE_ADD(q1, _SSE_MUL(x1, h1));
601
602
	_SSE_STORE((__vector unsigned int) q1, 0, (unsigned int *)  &q[nb*ldq]);
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+offset]);
603
	q2 = _SSE_ADD(q2, _SSE_MUL(x2, h1));
604
605
	_SSE_STORE((__vector unsigned int) q2, 0, (unsigned int *)  &q[(nb*ldq)+offset]);
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+2*offset]);
606
	q3 = _SSE_ADD(q3, _SSE_MUL(x3, h1));
607
608
	_SSE_STORE((__vector unsigned int) q3, 0, (unsigned int *)  &q[(nb*ldq)+2*offset]);
	q4 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+3*offset]);
609
	q4 = _SSE_ADD(q4, _SSE_MUL(x4, h1));
610
611
	_SSE_STORE((__vector unsigned int) q4, 0, (unsigned int *)  &q[(nb*ldq)+3*offset]);
	q5 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+4*offset]);
612
	q5 = _SSE_ADD(q5, _SSE_MUL(x5, h1));
613
614
	_SSE_STORE((__vector unsigned int) q5, 0, (unsigned int *)  &q[(nb*ldq)+4*offset]);
	q6 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+5*offset]);
615
	q6 = _SSE_ADD(q6, _SSE_MUL(x6, h1));
616
	_SSE_STORE((__vector unsigned int) q6, 0, (unsigned int *)  &q[(nb*ldq)+5*offset]);
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
}



/**
 * Unrolled kernel that computes
#ifdef DOUBLE_PRECISION_REAL
 * 10 rows of Q simultaneously, a
#endif
#ifdef SINGLE_PRECISION_REAL
 * 20 rows of Q simultaneously, a
#endif
 * matrix Vector product with two householder
 * vectors + a rank 2 update is performed
 */
#ifdef DOUBLE_PRECISION_REAL
 __forceinline void hh_trafo_kernel_10_VSX_2hv_double(double* q, double* hh, int nb, int ldq, int ldh, double s)
#endif
#ifdef SINGLE_PRECISION_REAL
 __forceinline void hh_trafo_kernel_20_VSX_2hv_single(float* q, float* hh, int nb, int ldq, int ldh, float s)
#endif
{
	/////////////////////////////////////////////////////
	// Matrix Vector Multiplication, Q [12 x nb+1] * hh
	// hh contains two householder vectors, with offset 1
	/////////////////////////////////////////////////////
	int i;
644
645
646
647
648
649
650
#ifdef DOUBLE_PRECISION_REAL
	double mone = 1.0;
#endif
#ifdef SINGLE_PRECISION_REAL
	float mone = 1.0;
#endif

651
652
653
654
655
656
657
658
659
660
#ifdef HAVE_SSE_INTRINSICS
	// Needed bit mask for floating point sign flip
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE sign = (__SSE_DATATYPE)_mm_set1_epi64x(0x8000000000000000LL);
#endif
#ifdef SINGLE_PRECISION_REAL
        __SSE_DATATYPE sign = _mm_castsi128_ps(_mm_set_epi32(0x80000000, 0x80000000, 0x80000000, 0x80000000));
#endif
#endif

661
662
663
664
665
	__SSE_DATATYPE x1 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq]);
	__SSE_DATATYPE x2 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+offset]);
	__SSE_DATATYPE x3 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+2*offset]);
	__SSE_DATATYPE x4 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+3*offset]);
	__SSE_DATATYPE x5 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+4*offset]);
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685

#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE h1 = _mm_set1_pd(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	__SSE_DATATYPE h1 = _mm_set1_ps(hh[ldh+1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE h1 = vec_splats(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	__SSE_DATATYPE h1 = vec_splats(hh[ldh+1]);
#endif
#endif

	__SSE_DATATYPE h2;

686
	__SSE_DATATYPE q1 = _SSE_LOAD(0, (unsigned long int *) &q[0]);
687
	__SSE_DATATYPE y1 = _SSE_ADD(q1, _SSE_MUL(x1, h1));
688
	__SSE_DATATYPE q2 = _SSE_LOAD(0, (unsigned long int *)  &q[offset]);
689
	__SSE_DATATYPE y2 = _SSE_ADD(q2, _SSE_MUL(x2, h1));
690
	__SSE_DATATYPE q3 = _SSE_LOAD(0, (unsigned long int *)  &q[2*offset]);
691
	__SSE_DATATYPE y3 = _SSE_ADD(q3, _SSE_MUL(x3, h1));
692
	__SSE_DATATYPE q4 = _SSE_LOAD(0, (unsigned long int *)  &q[3*offset]);
693
	__SSE_DATATYPE y4 = _SSE_ADD(q4, _SSE_MUL(x4, h1));
694
	__SSE_DATATYPE q5 = _SSE_LOAD(0, (unsigned long int *)  &q[4*offset]);
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
	__SSE_DATATYPE y5 = _SSE_ADD(q5, _SSE_MUL(x5, h1));
	for(i = 2; i < nb; i++)
	{
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
		h1 = _mm_set1_pd(hh[i-1]);
		h2 = _mm_set1_pd(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = _mm_set1_ps(hh[i-1]);
		h2 = _mm_set1_ps(hh[ldh+i]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#endif


720
		q1 = _SSE_LOAD(0, (unsigned long int *)  &q[i*ldq]);
721
722
		x1 = _SSE_ADD(x1, _SSE_MUL(q1,h1));
		y1 = _SSE_ADD(y1, _SSE_MUL(q1,h2));
723
		q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+offset]);
724
725
		x2 = _SSE_ADD(x2, _SSE_MUL(q2,h1));
		y2 = _SSE_ADD(y2, _SSE_MUL(q2,h2));
726
		q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+2*offset]);
727
728
		x3 = _SSE_ADD(x3, _SSE_MUL(q3,h1));
		y3 = _SSE_ADD(y3, _SSE_MUL(q3,h2));
729
		q4 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+3*offset]);
730
731
		x4 = _SSE_ADD(x4, _SSE_MUL(q4,h1));
		y4 = _SSE_ADD(y4, _SSE_MUL(q4,h2));
732
		q5 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+4*offset]);
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
		x5 = _SSE_ADD(x5, _SSE_MUL(q5,h1));
		y5 = _SSE_ADD(y5, _SSE_MUL(q5,h2));
	}

#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	h1 = _mm_set1_pd(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h1 = _mm_set1_ps(hh[nb-1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	h1 = vec_splats(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
750
	h1 = vec_splats(hh[nb-1]);
751
752
753
#endif
#endif

754
	q1 = _SSE_LOAD(0, (unsigned long int *)  &q[nb*ldq]);
755
	x1 = _SSE_ADD(x1, _SSE_MUL(q1,h1));
756
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+offset]);
757
	x2 = _SSE_ADD(x2, _SSE_MUL(q2,h1));
758
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+2*offset]);
759
	x3 = _SSE_ADD(x3, _SSE_MUL(q3,h1));
760
	q4 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+3*offset]);
761
	x4 = _SSE_ADD(x4, _SSE_MUL(q4,h1));
762
	q5 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+4*offset]);
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
	x5 = _SSE_ADD(x5, _SSE_MUL(q5,h1));
	/////////////////////////////////////////////////////
	// Rank-2 update of Q [12 x nb+1]
	/////////////////////////////////////////////////////
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE tau1 = _mm_set1_pd(hh[0]);
	__SSE_DATATYPE tau2 = _mm_set1_pd(hh[ldh]);
	__SSE_DATATYPE vs = _mm_set1_pd(s);
#endif
#ifdef SINGLE_PRECISION_REAL
	__SSE_DATATYPE tau1 = _mm_set1_ps(hh[0]);
	__SSE_DATATYPE tau2 = _mm_set1_ps(hh[ldh]);
	__SSE_DATATYPE vs = _mm_set1_ps(s);

#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE tau1 = vec_splats(hh[0]);
	__SSE_DATATYPE tau2 = vec_splats(hh[ldh]);
	__SSE_DATATYPE vs = vec_splats(s);
#endif
#ifdef SINGLE_PRECISION_REAL
787
	__SSE_DATATYPE tau1 = vec_splats(hh[0]);
788
789
790
791
792
793
794
795
796
797
	__SSE_DATATYPE tau2 = vec_splats(hh[ldh]);
	__SSE_DATATYPE vs = vec_splats(s);

#endif
#endif

#ifdef HAVE_SSE_INTRINSICS
	h1 = _SSE_XOR(tau1, sign);
#endif
#ifdef HAVE_VSX_SSE
798
799
	h1 = vec_mul(vec_splats(mone), tau1);
	// h1 = vec_neg(tau1);
800
801
802
803
804
805
806
807
808
809
#endif
	x1 = _SSE_MUL(x1, h1);
	x2 = _SSE_MUL(x2, h1);
	x3 = _SSE_MUL(x3, h1);
	x4 = _SSE_MUL(x4, h1);
	x5 = _SSE_MUL(x5, h1);
#ifdef HAVE_SSE_INTRINSICS
	h1 = _SSE_XOR(tau2, sign);
#endif
#ifdef HAVE_VSX_SSE
810
811
	// h1 = vec_neg(tau2);
	h1 = vec_mul(vec_splats(mone), tau2);
812
813
814
815
816
817
818
819
#endif
	h2 = _SSE_MUL(h1, vs);

	y1 = _SSE_ADD(_SSE_MUL(y1,h1), _SSE_MUL(x1,h2));
	y2 = _SSE_ADD(_SSE_MUL(y2,h1), _SSE_MUL(x2,h2));
	y3 = _SSE_ADD(_SSE_MUL(y3,h1), _SSE_MUL(x3,h2));
	y4 = _SSE_ADD(_SSE_MUL(y4,h1), _SSE_MUL(x4,h2));
	y5 = _SSE_ADD(_SSE_MUL(y5,h1), _SSE_MUL(x5,h2));
820
	q1 = _SSE_LOAD(0, (unsigned int *) &q[0]);
821
	q1 = _SSE_ADD(q1, y1);
822
823
	_SSE_STORE((__vector unsigned int) q1, 0, (unsigned int *) &q[0]);
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[offset]);
824
	q2 = _SSE_ADD(q2, y2);
825
826
	_SSE_STORE((__vector unsigned int) q2, 0, (unsigned int *)  &q[offset]);
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[2*offset]);
827
	q3 = _SSE_ADD(q3, y3);
828
829
	_SSE_STORE((__vector unsigned int) q3,0, (unsigned int *)  &q[2*offset]);
	q4 = _SSE_LOAD(0, (unsigned long int *)  &q[3*offset]);
830
	q4 = _SSE_ADD(q4, y4);
831
832
	_SSE_STORE((__vector unsigned int) q4, 0, (unsigned int *)  &q[3*offset]);
	q5 = _SSE_LOAD(0, (unsigned long int *)  &q[4*offset]);
833
	q5 = _SSE_ADD(q5, y5);
834
	_SSE_STORE((__vector unsigned int) q5, 0, (unsigned int *)  &q[4*offset]);
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852

#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	h2 = _mm_set1_pd(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h2 = _mm_set1_ps(hh[ldh+1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	h2 = vec_splats(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h2 = vec_splats(hh[ldh+1]);
#endif
#endif

853
	q1 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq]);
854
	q1 = _SSE_ADD(q1, _SSE_ADD(x1, _SSE_MUL(y1, h2)));
855
856
	_SSE_STORE((__vector unsigned int) q1, 0, (unsigned int *)  &q[ldq]);
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+offset]);
857
	q2 = _SSE_ADD(q2, _SSE_ADD(x2, _SSE_MUL(y2, h2)));
858
859
	_SSE_STORE((__vector unsigned int) q2, 0, (unsigned int *)  &q[ldq+offset]);
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+2*offset]);
860
	q3 = _SSE_ADD(q3, _SSE_ADD(x3, _SSE_MUL(y3, h2)));
861
862
	_SSE_STORE((__vector unsigned int) q3, 0, (unsigned int *)  &q[ldq+2*offset]);
	q4 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+3*offset]);
863
	q4 = _SSE_ADD(q4, _SSE_ADD(x4, _SSE_MUL(y4, h2)));
864
865
	_SSE_STORE((__vector unsigned int) q4, 0, (unsigned int *)  &q[ldq+3*offset]);
	q5 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+4*offset]);
866
	q5 = _SSE_ADD(q5, _SSE_ADD(x5, _SSE_MUL(y5, h2)));
867
	_SSE_STORE((__vector unsigned int) q5, 0, (unsigned int *)  &q[ldq+4*offset]);
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891

	for (i = 2; i < nb; i++)
	{
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
		h1 = _mm_set1_pd(hh[i-1]);
		h2 = _mm_set1_pd(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = _mm_set1_ps(hh[i-1]);
		h2 = _mm_set1_ps(hh[ldh+i]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#endif

892
		q1 = _SSE_LOAD(0, (unsigned long int *)  &q[i*ldq]);
893
		q1 = _SSE_ADD(q1, _SSE_ADD(_SSE_MUL(x1,h1), _SSE_MUL(y1, h2)));
894
895
		_SSE_STORE((__vector unsigned int) q1, 0, (unsigned int *)  &q[i*ldq]);
		q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+offset]);
896
		q2 = _SSE_ADD(q2, _SSE_ADD(_SSE_MUL(x2,h1), _SSE_MUL(y2, h2)));
897
898
		_SSE_STORE((__vector unsigned int) q2, 0, (unsigned int *)  &q[(i*ldq)+offset]);
		q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+2*offset]);
899
		q3 = _SSE_ADD(q3, _SSE_ADD(_SSE_MUL(x3,h1), _SSE_MUL(y3, h2)));
900
901
		_SSE_STORE((__vector unsigned int) q3, 0, (unsigned int *)  &q[(i*ldq)+2*offset]);
		q4 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+3*offset]);
902
		q4 = _SSE_ADD(q4, _SSE_ADD(_SSE_MUL(x4,h1), _SSE_MUL(y4, h2)));
903
904
		_SSE_STORE((__vector unsigned int) q4, 0, (unsigned int *)  &q[(i*ldq)+3*offset]);
		q5 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+4*offset]);
905
		q5 = _SSE_ADD(q5, _SSE_ADD(_SSE_MUL(x5,h1), _SSE_MUL(y5, h2)));
906
		_SSE_STORE((__vector unsigned int) q5, 0, (unsigned int *)  &q[(i*ldq)+4*offset]);
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
	}
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	h1 = _mm_set1_pd(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h1 = _mm_set1_ps(hh[nb-1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	h1 = vec_splats(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h1 = vec_splats(hh[nb-1]);
#endif
#endif

925
	q1 = _SSE_LOAD(0, (unsigned long int *)  &q[nb*ldq]);
926
	q1 = _SSE_ADD(q1, _SSE_MUL(x1, h1));
927
928
	_SSE_STORE((__vector unsigned int) q1, 0, (unsigned int *)  &q[nb*ldq]);
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+offset]);
929
	q2 = _SSE_ADD(q2, _SSE_MUL(x2, h1));
930
931
	_SSE_STORE((__vector unsigned int) q2, 0, (unsigned int *)  &q[(nb*ldq)+offset]);
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+2*offset]);
932
	q3 = _SSE_ADD(q3, _SSE_MUL(x3, h1));
933
934
	_SSE_STORE((__vector unsigned int) q3, 0, (unsigned int *)  &q[(nb*ldq)+2*offset]);
	q4 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+3*offset]);
935
	q4 = _SSE_ADD(q4, _SSE_MUL(x4, h1));
936
937
	_SSE_STORE((__vector unsigned int) q4, 0, (unsigned int *)  &q[(nb*ldq)+3*offset]);
	q5 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+4*offset]);
938
	q5 = _SSE_ADD(q5, _SSE_MUL(x5, h1));
939
	_SSE_STORE((__vector unsigned int) q5, 0, (unsigned int *)  &q[(nb*ldq)+4*offset]);
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
}

/**
 * Unrolled kernel that computes
#ifdef DOUBLE_PRECISION_REAL
 * 8 rows of Q simultaneously, a
#endif
#ifdef SINGLE_PRECISION_REAL
 * 16 rows of Q simultaneously, a
#endif
 * matrix Vector product with two householder
 * vectors + a rank 2 update is performed
 */
#ifdef DOUBLE_PRECISION_REAL
 __forceinline void hh_trafo_kernel_8_VSX_2hv_double(double* q, double* hh, int nb, int ldq, int ldh, double s)
#endif
#ifdef SINGLE_PRECISION_REAL
 __forceinline void hh_trafo_kernel_16_VSX_2hv_single(float* q, float* hh, int nb, int ldq, int ldh, float s)
#endif
{
	/////////////////////////////////////////////////////
	// Matrix Vector Multiplication, Q [12 x nb+1] * hh
	// hh contains two householder vectors, with offset 1
	/////////////////////////////////////////////////////
	int i;

966
967
968
969
970
971
972
#ifdef DOUBLE_PRECISION_REAL
	double mone = 1.0;
#endif
#ifdef SINGLE_PRECISION_REAL
	float mone = 1.0;
#endif

973
974
975
976
977
978
979
980
981
#ifdef HAVE_SSE_INTRINSICS
	// Needed bit mask for floating point sign flip
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE sign = (__SSE_DATATYPE)_mm_set1_epi64x(0x8000000000000000LL);
#endif
#ifdef SINGLE_PRECISION_REAL
        __SSE_DATATYPE sign = _mm_castsi128_ps(_mm_set_epi32(0x80000000, 0x80000000, 0x80000000, 0x80000000));
#endif
#endif
982
983
984
985
	__SSE_DATATYPE x1 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq]);
	__SSE_DATATYPE x2 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+offset]);
	__SSE_DATATYPE x3 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+2*offset]);
	__SSE_DATATYPE x4 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+3*offset]);
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005

#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE h1 = _mm_set1_pd(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	__SSE_DATATYPE h1 = _mm_set1_ps(hh[ldh+1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE h1 = vec_splats(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	__SSE_DATATYPE h1 = vec_splats(hh[ldh+1]);
#endif
#endif

	__SSE_DATATYPE h2;

1006
	__SSE_DATATYPE q1 = _SSE_LOAD(0, (unsigned long int *)  &q[0]);
1007
	__SSE_DATATYPE y1 = _SSE_ADD(q1, _SSE_MUL(x1, h1));
1008
	__SSE_DATATYPE q2 = _SSE_LOAD(0, (unsigned long int *)  &q[offset]);
1009
	__SSE_DATATYPE y2 = _SSE_ADD(q2, _SSE_MUL(x2, h1));
1010
	__SSE_DATATYPE q3 = _SSE_LOAD(0, (unsigned long int *)  &q[2*offset]);
1011
	__SSE_DATATYPE y3 = _SSE_ADD(q3, _SSE_MUL(x3, h1));
1012
	__SSE_DATATYPE q4 = _SSE_LOAD(0, (unsigned long int *)  &q[3*offset]);
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
	__SSE_DATATYPE y4 = _SSE_ADD(q4, _SSE_MUL(x4, h1));
	for(i = 2; i < nb; i++)
	{
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
		h1 = _mm_set1_pd(hh[i-1]);
		h2 = _mm_set1_pd(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = _mm_set1_ps(hh[i-1]);
		h2 = _mm_set1_ps(hh[ldh+i]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#endif


1038
		q1 = _SSE_LOAD(0, (unsigned long int *)  &q[i*ldq]);
1039
1040
		x1 = _SSE_ADD(x1, _SSE_MUL(q1,h1));
		y1 = _SSE_ADD(y1, _SSE_MUL(q1,h2));
1041
		q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+offset]);
1042
1043
		x2 = _SSE_ADD(x2, _SSE_MUL(q2,h1));
		y2 = _SSE_ADD(y2, _SSE_MUL(q2,h2));
1044
		q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+2*offset]);
1045
1046
		x3 = _SSE_ADD(x3, _SSE_MUL(q3,h1));
		y3 = _SSE_ADD(y3, _SSE_MUL(q3,h2));
1047
		q4 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+3*offset]);
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
		x4 = _SSE_ADD(x4, _SSE_MUL(q4,h1));
		y4 = _SSE_ADD(y4, _SSE_MUL(q4,h2));
	}
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	h1 = _mm_set1_pd(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h1 = _mm_set1_ps(hh[nb-1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	h1 = vec_splats(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h1 = vec_splats(hh[nb-1]);
#endif
#endif
1067
	q1 = _SSE_LOAD(0, (unsigned long int *)  &q[nb*ldq]);
1068
	x1 = _SSE_ADD(x1, _SSE_MUL(q1,h1));
1069
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+offset]);
1070
	x2 = _SSE_ADD(x2, _SSE_MUL(q2,h1));
1071
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+2*offset]);
1072
	x3 = _SSE_ADD(x3, _SSE_MUL(q3,h1));
1073
	q4 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+3*offset]);
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
	x4 = _SSE_ADD(x4, _SSE_MUL(q4,h1));
	/////////////////////////////////////////////////////
	// Rank-2 update of Q [12 x nb+1]
	/////////////////////////////////////////////////////
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE tau1 = _mm_set1_pd(hh[0]);
	__SSE_DATATYPE tau2 = _mm_set1_pd(hh[ldh]);
	__SSE_DATATYPE vs = _mm_set1_pd(s);
#endif
#ifdef SINGLE_PRECISION_REAL
	__SSE_DATATYPE tau1 = _mm_set1_ps(hh[0]);
	__SSE_DATATYPE tau2 = _mm_set1_ps(hh[ldh]);
	__SSE_DATATYPE vs = _mm_set1_ps(s);

#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE tau1 = vec_splats(hh[0]);
	__SSE_DATATYPE tau2 = vec_splats(hh[ldh]);
	__SSE_DATATYPE vs = vec_splats(s);
#endif
#ifdef SINGLE_PRECISION_REAL
	__SSE_DATATYPE tau1 = vec_splats(hh[0]);
	__SSE_DATATYPE tau2 = vec_splats(hh[ldh]);
	__SSE_DATATYPE vs = vec_splats(s);

#endif
#endif

#ifdef HAVE_SSE_INTRINSICS
	h1 = _SSE_XOR(tau1, sign);
#endif
#ifdef HAVE_VSX_SSE
1109
1110
	// h1 = vec_neg(tau1);
	h1 = vec_mul(vec_splats(mone), tau1);
1111
1112
1113
1114
1115
1116
1117
1118
1119
#endif
	x1 = _SSE_MUL(x1, h1);
	x2 = _SSE_MUL(x2, h1);
	x3 = _SSE_MUL(x3, h1);
	x4 = _SSE_MUL(x4, h1);
#ifdef HAVE_SSE_INTRINSICS
	h1 = _SSE_XOR(tau2, sign);
#endif
#ifdef HAVE_VSX_SSE
1120
1121
	//h1 = vec_neg(tau2);
	h1 = vec_mul(vec_splats(mone), tau2);
1122
1123
1124
1125
1126
1127
1128
#endif
	h2 = _SSE_MUL(h1, vs);

	y1 = _SSE_ADD(_SSE_MUL(y1,h1), _SSE_MUL(x1,h2));
	y2 = _SSE_ADD(_SSE_MUL(y2,h1), _SSE_MUL(x2,h2));
	y3 = _SSE_ADD(_SSE_MUL(y3,h1), _SSE_MUL(x3,h2));
	y4 = _SSE_ADD(_SSE_MUL(y4,h1), _SSE_MUL(x4,h2));
1129
	q1 = _SSE_LOAD(0, (unsigned long int *) &q[0]);
1130
	q1 = _SSE_ADD(q1, y1);
1131
1132
	_SSE_STORE((__vector unsigned int) q1, 0, (unsigned int *) &q[0]);
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[offset]);
1133
	q2 = _SSE_ADD(q2, y2);
1134
1135
	_SSE_STORE((__vector unsigned int) q2, 0, (unsigned int *)  &q[offset]);
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[2*offset]);
1136
	q3 = _SSE_ADD(q3, y3);
1137
1138
	_SSE_STORE((__vector unsigned int) q3, 0, (unsigned int *)  &q[2*offset]);
	q4 = _SSE_LOAD(0,  (unsigned long int *) &q[3*offset]);
1139
	q4 = _SSE_ADD(q4, y4);
1140
	_SSE_STORE((__vector unsigned int) q4, 0, (unsigned int *)  &q[3*offset]);
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158

#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	h2 = _mm_set1_pd(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h2 = _mm_set1_ps(hh[ldh+1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	h2 = vec_splats(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h2 = vec_splats(hh[ldh+1]);
#endif
#endif

1159
	q1 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq]);
1160
	q1 = _SSE_ADD(q1, _SSE_ADD(x1, _SSE_MUL(y1, h2)));
1161
1162
	_SSE_STORE((__vector unsigned int) q1, 0, (unsigned int *)  &q[ldq]);
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+offset]);
1163
	q2 = _SSE_ADD(q2, _SSE_ADD(x2, _SSE_MUL(y2, h2)));
1164
1165
	_SSE_STORE((__vector unsigned int) q2, 0, (unsigned int *)  &q[ldq+offset]);
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+2*offset]);
1166
	q3 = _SSE_ADD(q3, _SSE_ADD(x3, _SSE_MUL(y3, h2)));
1167
1168
	_SSE_STORE((__vector unsigned int) q3, 0, (unsigned int *)  &q[ldq+2*offset]);
	q4 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+3*offset]);
1169
	q4 = _SSE_ADD(q4, _SSE_ADD(x4, _SSE_MUL(y4, h2)));
1170
	_SSE_STORE((__vector unsigned int) q4, 0, (unsigned int *)  &q[ldq+3*offset]);
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195

	for (i = 2; i < nb; i++)
	{
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
		h1 = _mm_set1_pd(hh[i-1]);
		h2 = _mm_set1_pd(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = _mm_set1_ps(hh[i-1]);
		h2 = _mm_set1_ps(hh[ldh+i]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#endif


1196
		q1 = _SSE_LOAD(0, (unsigned long int *)  &q[i*ldq]);
1197
		q1 = _SSE_ADD(q1, _SSE_ADD(_SSE_MUL(x1,h1), _SSE_MUL(y1, h2)));
1198
1199
		_SSE_STORE((__vector unsigned int) q1, 0, (unsigned int *)  &q[i*ldq]);
		q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+offset]);
1200
		q2 = _SSE_ADD(q2, _SSE_ADD(_SSE_MUL(x2,h1), _SSE_MUL(y2, h2)));
1201
1202
		_SSE_STORE((__vector unsigned int) q2, 0, (unsigned int *)  &q[(i*ldq)+offset]);
		q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+2*offset]);
1203
		q3 = _SSE_ADD(q3, _SSE_ADD(_SSE_MUL(x3,h1), _SSE_MUL(y3, h2)));
1204
1205
		_SSE_STORE((__vector unsigned int) q3, 0, (unsigned int *)  &q[(i*ldq)+2*offset]);
		q4 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+3*offset]);
1206
		q4 = _SSE_ADD(q4, _SSE_ADD(_SSE_MUL(x4,h1), _SSE_MUL(y4, h2)));
1207
		_SSE_STORE((__vector unsigned int) q4, 0, (unsigned int *)  &q[(i*ldq)+3*offset]);
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
	}
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	h1 = _mm_set1_pd(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h1 = _mm_set1_ps(hh[nb-1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	h1 = vec_splats(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h1 = vec_splats(hh[nb-1]);
#endif
#endif

1226
	q1 = _SSE_LOAD(0, (unsigned long int *)  &q[nb*ldq]);
1227
	q1 = _SSE_ADD(q1, _SSE_MUL(x1, h1));
1228
1229
	_SSE_STORE((__vector unsigned int) q1, 0, (unsigned int *)  &q[nb*ldq]);
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+offset]);
1230
	q2 = _SSE_ADD(q2, _SSE_MUL(x2, h1));
1231
1232
	_SSE_STORE((__vector unsigned int) q2, 0, (unsigned int *)  &q[(nb*ldq)+offset]);
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+2*offset]);
1233
	q3 = _SSE_ADD(q3, _SSE_MUL(x3, h1));
1234
1235
	_SSE_STORE((__vector unsigned int) q3, 0, (unsigned int *)  &q[(nb*ldq)+2*offset]);
	q4 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+3*offset]);
1236
	q4 = _SSE_ADD(q4, _SSE_MUL(x4, h1));
1237
	_SSE_STORE((__vector unsigned int) q4, 0, (unsigned int *)  &q[(nb*ldq)+3*offset]);
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
}

/**
 * Unrolled kernel that computes
#ifdef DOUBLE_PRECISION_REAL
 * 6 rows of Q simultaneously, a
#endif
#ifdef SINGLE_PRECISION_REAL
 * 12 rows of Q simultaneously, a
#endif
 * matrix Vector product with two householder
 * vectors + a rank 2 update is performed
 */
#ifdef DOUBLE_PRECISION_REAL
 __forceinline void hh_trafo_kernel_6_VSX_2hv_double(double* q, double* hh, int nb, int ldq, int ldh, double s)
#endif
#ifdef SINGLE_PRECISION_REAL
 __forceinline void hh_trafo_kernel_12_VSX_2hv_single(float* q, float* hh, int nb, int ldq, int ldh, float s)
#endif
{
	/////////////////////////////////////////////////////
	// Matrix Vector Multiplication, Q [12 x nb+1] * hh
	// hh contains two householder vectors, with offset 1
	/////////////////////////////////////////////////////
	int i;
1263
1264
1265
1266
1267
1268
1269
#ifdef DOUBLE_PRECISION_REAL
	double mone = 1.0;
#endif
#ifdef SINGLE_PRECISION_REAL
	float mone = 1.0;
#endif

1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
#ifdef HAVE_SSE_INTRINSICS
	// Needed bit mask for floating point sign flip
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE sign = (__SSE_DATATYPE)_mm_set1_epi64x(0x8000000000000000LL);
#endif
#ifdef SINGLE_PRECISION_REAL
        __SSE_DATATYPE sign = _mm_castsi128_ps(_mm_set_epi32(0x80000000, 0x80000000, 0x80000000, 0x80000000));
#endif
#endif

1280
1281
1282
	__SSE_DATATYPE x1 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq]);
	__SSE_DATATYPE x2 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+offset]);
	__SSE_DATATYPE x3 = _SSE_LOAD(0, (unsigned long int *)  &q[ldq+2*offset]);
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301

#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE h1 = _mm_set1_pd(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	__SSE_DATATYPE h1 = _mm_set1_ps(hh[ldh+1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	__SSE_DATATYPE h1 = vec_splats(hh[ldh+1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	__SSE_DATATYPE h1 = vec_splats(hh[ldh+1]);
#endif
#endif
	__SSE_DATATYPE h2;

1302
	__SSE_DATATYPE q1 = _SSE_LOAD(0, (unsigned long int *) &q[0]);
1303
	__SSE_DATATYPE y1 = _SSE_ADD(q1, _SSE_MUL(x1, h1));
1304
	__SSE_DATATYPE q2 = _SSE_LOAD(0, (unsigned long int *)  &q[offset]);
1305
	__SSE_DATATYPE y2 = _SSE_ADD(q2, _SSE_MUL(x2, h1));
1306
	__SSE_DATATYPE q3 = _SSE_LOAD(0, (unsigned long int *)  &q[2*offset]);
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
	__SSE_DATATYPE y3 = _SSE_ADD(q3, _SSE_MUL(x3, h1));
	for(i = 2; i < nb; i++)
	{
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
		h1 = _mm_set1_pd(hh[i-1]);
		h2 = _mm_set1_pd(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = _mm_set1_ps(hh[i-1]);
		h2 = _mm_set1_ps(hh[ldh+i]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#ifdef SINGLE_PRECISION_REAL
		h1 = vec_splats(hh[i-1]);
		h2 = vec_splats(hh[ldh+i]);
#endif
#endif


1332
		q1 = _SSE_LOAD(0, (unsigned long int *)  &q[i*ldq]);
1333
1334
		x1 = _SSE_ADD(x1, _SSE_MUL(q1,h1));
		y1 = _SSE_ADD(y1, _SSE_MUL(q1,h2));
1335
		q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+offset]);
1336
1337
		x2 = _SSE_ADD(x2, _SSE_MUL(q2,h1));
		y2 = _SSE_ADD(y2, _SSE_MUL(q2,h2));
1338
		q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(i*ldq)+2*offset]);
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
		x3 = _SSE_ADD(x3, _SSE_MUL(q3,h1));
		y3 = _SSE_ADD(y3, _SSE_MUL(q3,h2));
	}
#ifdef HAVE_SSE_INTRINSICS
#ifdef DOUBLE_PRECISION_REAL
	h1 = _mm_set1_pd(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h1 = _mm_set1_ps(hh[nb-1]);
#endif
#endif
#ifdef HAVE_VSX_SSE
#ifdef DOUBLE_PRECISION_REAL
	h1 = vec_splats(hh[nb-1]);
#endif
#ifdef SINGLE_PRECISION_REAL
	h1 = vec_splats(hh[nb-1]);
#endif
#endif

1359
	q1 = _SSE_LOAD(0, (unsigned long int *)  &q[nb*ldq]);
1360
	x1 = _SSE_ADD(x1, _SSE_MUL(q1,h1));
1361
	q2 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+offset]);
1362
	x2 = _SSE_ADD(x2, _SSE_MUL(q2,h1));
1363
	q3 = _SSE_LOAD(0, (unsigned long int *)  &q[(nb*ldq)+2*offset]);
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391