compute_hh_trafo.F90 76.5 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
48
#if 0
!    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
!
!
!    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.
!
! This file was written by A. Marek, MPCDF
#endif

       subroutine compute_hh_trafo_&
       &MATH_DATATYPE&
#ifdef WITH_OPENMP
Andreas Marek's avatar
Andreas Marek committed
49
       &_openmp_&
50
#else
Andreas Marek's avatar
Andreas Marek committed
51
       &_&
52
53
#endif
       &PRECISION &
Andreas Marek's avatar
Andreas Marek committed
54
       (obj, useGPU, wantDebug, a, a_dev, stripe_width, a_dim2, stripe_count,  &
55
56
57
#ifdef WITH_OPENMP
       max_threads, l_nev, &
#endif
Andreas Marek's avatar
Andreas Marek committed
58
       a_off, nbw, max_blk_size, bcast_buffer, bcast_buffer_dev, &
59
#if REALCASE == 1
Andreas Marek's avatar
Andreas Marek committed
60
       hh_dot_dev, &
61
#endif
Andreas Marek's avatar
Andreas Marek committed
62
       hh_tau_dev, kernel_flops, kernel_time, n_times, off, ncols, istripe, &
63
64
65
66
67
#ifdef WITH_OPENMP
       my_thread, thread_width, &
#else
       last_stripe_width, &
#endif
68
       kernel)
69
70

         use precision
71
         use elpa_abstract_impl
72
73
         use iso_c_binding
#if REALCASE == 1
74

75
         use single_hh_trafo_real
76
77
78
79
80
#if defined(WITH_REAL_GENERIC_SIMPLE_KERNEL) && !(defined(USE_ASSUMED_SIZE))
         use real_generic_simple_kernel !, only : double_hh_trafo_generic_simple
#endif

#if defined(WITH_REAL_GENERIC_KERNEL) && !(defined(USE_ASSUMED_SIZE))
81
         use real_generic_kernel !, only : double_hh_trafo_generic
82
83
84
85
86
87
88
89
90
#endif

#if defined(WITH_REAL_BGP_KERNEL)
         use real_bgp_kernel !, only : double_hh_trafo_bgp
#endif

#if defined(WITH_REAL_BGQ_KERNEL)
         use real_bgq_kernel !, only : double_hh_trafo_bgq
#endif
91
92
93
94
95

#endif /* REALCASE */

#if COMPLEXCASE == 1

96
#if defined(WITH_COMPLEX_GENERIC_SIMPLE_KERNEL) && !(defined(USE_ASSUMED_SIZE))
97
98
           use complex_generic_simple_kernel !, only : single_hh_trafo_complex_generic_simple
#endif
99
#if defined(WITH_COMPLEX_GENERIC_KERNEL) && !(defined(USE_ASSUMED_SIZE))
100
101
102
103
104
105
106
107
           use complex_generic_kernel !, only : single_hh_trafo_complex_generic
#endif

#endif /* COMPLEXCASE */

         use cuda_c_kernel
         use cuda_functions

Lorenz Huedepohl's avatar
Lorenz Huedepohl committed
108
         use elpa_generated_fortran_interfaces
109

110
         implicit none
Andreas Marek's avatar
Andreas Marek committed
111
112
113
114
115
         class(elpa_abstract_impl_t), intent(inout) :: obj
	 logical, intent(in)                        :: useGPU, wantDebug
         real(kind=c_double), intent(inout)         :: kernel_time  ! MPI_WTIME always needs double
         integer(kind=lik)                          :: kernel_flops
         integer(kind=ik), intent(in)               :: nbw, max_blk_size
116
#if REALCASE == 1
Andreas Marek's avatar
Andreas Marek committed
117
         real(kind=C_DATATYPE_KIND)                 :: bcast_buffer(nbw,max_blk_size)
118
119
#endif
#if COMPLEXCASE == 1
Andreas Marek's avatar
Andreas Marek committed
120
         complex(kind=C_DATATYPE_KIND)              :: bcast_buffer(nbw,max_blk_size)
121
#endif
Andreas Marek's avatar
Andreas Marek committed
122
         integer(kind=ik), intent(in)               :: a_off
123

Andreas Marek's avatar
Andreas Marek committed
124
         integer(kind=ik), intent(in)               :: stripe_width,a_dim2,stripe_count
125
126

#ifndef WITH_OPENMP
Andreas Marek's avatar
Andreas Marek committed
127
         integer(kind=ik), intent(in)               :: last_stripe_width
128
#if REALCASE == 1
Andreas Marek's avatar
Andreas Marek committed
129
130
!         real(kind=C_DATATYPE_KIND)                :: a(stripe_width,a_dim2,stripe_count)
         real(kind=C_DATATYPE_KIND), pointer        :: a(:,:,:)
131
132
#endif
#if COMPLEXCASE == 1
Andreas Marek's avatar
Andreas Marek committed
133
134
!          complex(kind=C_DATATYPE_KIND)            :: a(stripe_width,a_dim2,stripe_count)
          complex(kind=C_DATATYPE_KIND),pointer     :: a(:,:,:)
135
136
137
#endif

#else /* WITH_OPENMP */
Andreas Marek's avatar
Andreas Marek committed
138
         integer(kind=ik), intent(in)               :: max_threads, l_nev, thread_width
139
#if REALCASE == 1
Andreas Marek's avatar
Andreas Marek committed
140
141
!         real(kind=C_DATATYPE_KIND)                :: a(stripe_width,a_dim2,stripe_count,max_threads)
         real(kind=C_DATATYPE_KIND), pointer        :: a(:,:,:,:)
142
#endif
143
#if COMPLEXCASE == 1
Andreas Marek's avatar
Andreas Marek committed
144
145
!          complex(kind=C_DATATYPE_KIND)            :: a(stripe_width,a_dim2,stripe_count,max_threads)
          complex(kind=C_DATATYPE_KIND),pointer     :: a(:,:,:,:)
146
147
148
149
#endif

#endif /* WITH_OPENMP */

Andreas Marek's avatar
Andreas Marek committed
150
         integer(kind=ik), intent(in)               :: kernel
151

Andreas Marek's avatar
Andreas Marek committed
152
153
         integer(kind=c_intptr_t)                   :: a_dev
   integer(kind=c_intptr_t)                         :: bcast_buffer_dev
Andreas Marek's avatar
Andreas Marek committed
154
#if REALCASE == 1
Andreas Marek's avatar
Andreas Marek committed
155
         integer(kind=c_intptr_t)                   :: hh_dot_dev ! why not needed in complex case
156
#endif
Andreas Marek's avatar
Andreas Marek committed
157
158
         integer(kind=c_intptr_t)                   :: hh_tau_dev
         integer(kind=c_intptr_t)                   :: dev_offset, dev_offset_1, dev_offset_2
Andreas Marek's avatar
Andreas Marek committed
159

160
         ! Private variables in OMP regions (my_thread) should better be in the argument list!
Andreas Marek's avatar
Andreas Marek committed
161
         integer(kind=ik)                           :: off, ncols, istripe
162
#ifdef WITH_OPENMP
Andreas Marek's avatar
Andreas Marek committed
163
         integer(kind=ik)                           :: my_thread, noff
164
#endif
Andreas Marek's avatar
Andreas Marek committed
165
         integer(kind=ik)                           :: j, nl, jj, jjj, n_times
166
#if REALCASE == 1
Andreas Marek's avatar
Andreas Marek committed
167
         real(kind=C_DATATYPE_KIND)                 :: w(nbw,6)
168
169
#endif
#if COMPLEXCASE == 1
Andreas Marek's avatar
Andreas Marek committed
170
         complex(kind=C_DATATYPE_KIND)              :: w(nbw,2)
171
#endif
Andreas Marek's avatar
Andreas Marek committed
172
         real(kind=c_double)                        :: ttt ! MPI_WTIME always needs double
173

Andreas Marek's avatar
Andreas Marek committed
174

Andreas Marek's avatar
Andreas Marek committed
175
176
177

         if (wantDebug) then
           if (useGPU .and. &
178
#if REALCASE == 1
Andreas Marek's avatar
Andreas Marek committed
179
180
181
182
183
184
185
186
             ( kernel .ne. ELPA_2STAGE_REAL_GPU)) then
#endif
#if COMPLEXCASE == 1
             ( kernel .ne. ELPA_2STAGE_COMPLEX_GPU)) then
#endif
             print *,"ERROR: useGPU is set in conpute_hh_trafo but not GPU kernel!"
	     stop
	   endif
187
         endif
Andreas Marek's avatar
Andreas Marek committed
188
189
190

#if REALCASE == 1
         if (kernel .eq. ELPA_2STAGE_REAL_GPU) then
191
#endif
Andreas Marek's avatar
Andreas Marek committed
192
#if COMPLEXCASE == 1
193
         if (kernel .eq. ELPA_2STAGE_COMPLEX_GPU) then
Andreas Marek's avatar
Andreas Marek committed
194
#endif
Andreas Marek's avatar
Andreas Marek committed
195
           ! ncols - indicates the number of HH reflectors to apply; at least 1 must be available
Andreas Marek's avatar
Andreas Marek committed
196
197
198
199
200
201
           if (ncols < 1) then
	     if (wantDebug) then
	       print *, "Returning early from compute_hh_trafo"
	     endif
	     return
	   endif
Andreas Marek's avatar
Andreas Marek committed
202
         endif
203

204
         if (wantDebug) call obj%timer%start("compute_hh_trafo_&
Andreas Marek's avatar
Retab    
Andreas Marek committed
205
   &MATH_DATATYPE&
206
#ifdef WITH_OPENMP
Andreas Marek's avatar
Andreas Marek committed
207
         &_openmp" // &
208
#else
Andreas Marek's avatar
Andreas Marek committed
209
         &" // &
210
211
212
213
214
215
216
217
218
219
220
221
222
#endif
         &PRECISION_SUFFIX &
         )


#ifdef WITH_OPENMP
         if (my_thread==1) then
#endif
           ttt = mpi_wtime()
#ifdef WITH_OPENMP
         endif
#endif

223
#ifdef WITH_OPENMP
224
225

#if REALCASE == 1
226
         if (kernel .eq. ELPA_2STAGE_REAL_GPU) then
227
           print *,"compute_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
228
229
                   &MATH_DATATYPE&
                   &_GPU OPENMP: not yet implemented"
230
231
           stop 1
         endif
Andreas Marek's avatar
Andreas Marek committed
232
233
#endif
#if COMPLEXCASE == 1
234
         if (kernel .eq. ELPA_2STAGE_COMPLEX_GPU) then
Andreas Marek's avatar
Andreas Marek committed
235
           print *,"compute_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
236
237
                   &MATH_DATATYPE&
                   &_GPU OPENMP: not yet implemented"
Andreas Marek's avatar
Andreas Marek committed
238
239
           stop 1
         endif
240
#endif
241
242
243
244
245
246
#endif /* WITH_OPENMP */

#ifndef WITH_OPENMP
         nl = merge(stripe_width, last_stripe_width, istripe<stripe_count)
#else /* WITH_OPENMP */

247
248
249
250
251
252
         if (istripe<stripe_count) then
           nl = stripe_width
         else
           noff = (my_thread-1)*thread_width + (istripe-1)*stripe_width
           nl = min(my_thread*thread_width-noff, l_nev-noff)
           if (nl<=0) then
253
             if (wantDebug) call obj%timer%stop("compute_hh_trafo_&
Andreas Marek's avatar
Retab    
Andreas Marek committed
254
       &MATH_DATATYPE&
255
#ifdef WITH_OPENMP
Andreas Marek's avatar
Andreas Marek committed
256
             &_openmp" // &
257
#else
Andreas Marek's avatar
Andreas Marek committed
258
             &" // &
259
260
261
262
263
264
265
266
267
#endif
             &PRECISION_SUFFIX &
             )

             return
           endif
         endif
#endif /* not WITH_OPENMP */

268
#if REALCASE == 1
Andreas Marek's avatar
Andreas Marek committed
269
! GPU kernel real
270
         if (kernel .eq. ELPA_2STAGE_REAL_GPU) then
Andreas Marek's avatar
Andreas Marek committed
271
272
273
	   if (wantDebug) then
	     call obj%timer%start("compute_hh_trafo: GPU")
	   endif
274
           dev_offset = (0 + (a_off * stripe_width) + ( (istripe - 1) * stripe_width *a_dim2 )) *size_of_&
Andreas Marek's avatar
Retab    
Andreas Marek committed
275
                  &PRECISION&
Andreas Marek's avatar
Andreas Marek committed
276
277
278
                  &_&
                  &MATH_DATATYPE

Andreas Marek's avatar
Andreas Marek committed
279
           call launch_compute_hh_trafo_gpu_kernel_&
Andreas Marek's avatar
Andreas Marek committed
280
281
282
283
                &MATH_DATATYPE&
                &_&
                &PRECISION&
                & (a_dev + dev_offset, bcast_buffer_dev, hh_dot_dev, hh_tau_dev, nl, nbw, stripe_width, off, ncols)
284
#endif /* REALCASE */
Andreas Marek's avatar
Andreas Marek committed
285
286
#if COMPLEXCASE == 1
! GPU kernel complex
287
         if (kernel .eq. ELPA_2STAGE_COMPLEX_GPU) then
Andreas Marek's avatar
Andreas Marek committed
288
289
290
	   if (wantDebug) then
	     call obj%timer%start("compute_hh_trafo: GPU")
	   endif
Andreas Marek's avatar
Andreas Marek committed
291
292

           dev_offset = (0 + ( (  a_off + off-1 )* stripe_width) + ( (istripe - 1)*stripe_width*a_dim2 )) * size_of_&
Andreas Marek's avatar
Retab    
Andreas Marek committed
293
                  &PRECISION&
Andreas Marek's avatar
Andreas Marek committed
294
295
                  &_&
                  &MATH_DATATYPE
Andreas Marek's avatar
Andreas Marek committed
296
297

           dev_offset_1 = (0 +  (  off-1 )* nbw) * size_of_&
Andreas Marek's avatar
Retab    
Andreas Marek committed
298
                  &PRECISION&
Andreas Marek's avatar
Andreas Marek committed
299
300
                  &_&
                  &MATH_DATATYPE
Andreas Marek's avatar
Andreas Marek committed
301
302

           dev_offset_2 =( off-1 )* size_of_&
Andreas Marek's avatar
Retab    
Andreas Marek committed
303
                  &PRECISION&
Andreas Marek's avatar
Andreas Marek committed
304
305
                  &_&
                  &MATH_DATATYPE
Andreas Marek's avatar
Andreas Marek committed
306

Andreas Marek's avatar
Andreas Marek committed
307
           call launch_compute_hh_trafo_gpu_kernel_&
Andreas Marek's avatar
Andreas Marek committed
308
309
310
311
                &MATH_DATATYPE&
                &_&
                &PRECISION&
                & (a_dev + dev_offset,bcast_buffer_dev + dev_offset_1, &
Andreas Marek's avatar
Andreas Marek committed
312
313
314
315
                                                         hh_tau_dev + dev_offset_2, nl, nbw,stripe_width, off,ncols)


#endif /* COMPLEXCASE */
316
317
318
           if (wantDebug) then
             call obj%timer%stop("compute_hh_trafo: GPU")
           endif
Andreas Marek's avatar
Andreas Marek committed
319
320

         else ! not CUDA kernel
321

322
323
324
           if (wantDebug) then
             call obj%timer%start("compute_hh_trafo: CPU")
           endif
325
#if REALCASE == 1
326
#ifndef WITH_FIXED_REAL_KERNEL
327
328
329
330
         if (kernel .eq. ELPA_2STAGE_REAL_AVX_BLOCK2 .or. &
             kernel .eq. ELPA_2STAGE_REAL_AVX2_BLOCK2 .or. &
             kernel .eq. ELPA_2STAGE_REAL_AVX512_BLOCK2 .or. &
             kernel .eq. ELPA_2STAGE_REAL_SSE_BLOCK2 .or. &
331
             kernel .eq. ELPA_2STAGE_REAL_SPARC64_BLOCK2 .or. &
332
             kernel .eq. ELPA_2STAGE_REAL_VSX_BLOCK2 .or. &
333
334
335
336
337
             kernel .eq. ELPA_2STAGE_REAL_GENERIC    .or. &
             kernel .eq. ELPA_2STAGE_REAL_GENERIC_SIMPLE .or. &
             kernel .eq. ELPA_2STAGE_REAL_SSE_ASSEMBLY .or. &
             kernel .eq. ELPA_2STAGE_REAL_BGP .or.        &
             kernel .eq. ELPA_2STAGE_REAL_BGQ) then
338
#endif /* not WITH_FIXED_REAL_KERNEL */
339

340
341
342
#endif /* REALCASE */
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

343
             !FORTRAN CODE / X86 INRINISIC CODE / BG ASSEMBLER USING 2 HOUSEHOLDER VECTORS
344
345
#if REALCASE == 1
! generic kernel real case
346
#if defined(WITH_REAL_GENERIC_KERNEL)
347
#ifndef WITH_FIXED_REAL_KERNEL
348
             if (kernel .eq. ELPA_2STAGE_REAL_GENERIC) then
349
#endif /* not WITH_FIXED_REAL_KERNEL */
350
351
352
353
354
355
356
357

               do j = ncols, 2, -2
                 w(:,1) = bcast_buffer(1:nbw,j+off)
                 w(:,2) = bcast_buffer(1:nbw,j+off-1)

#ifdef WITH_OPENMP

#ifdef USE_ASSUMED_SIZE
Andreas Marek's avatar
Andreas Marek committed
358
                 call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
359
360
361
362
                      &MATH_DATATYPE&
                      &_generic_&
                      &PRECISION&
                      & (a(1,j+off+a_off-1,istripe,my_thread), w, nbw, nl, stripe_width, nbw)
363
364

#else
Andreas Marek's avatar
Andreas Marek committed
365
                 call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
366
367
368
369
                      &MATH_DATATYPE&
                      &_generic_&
                      &PRECISION&
                      & (a(1:stripe_width,j+off+a_off-1:j+off+a_off+nbw-1, istripe,my_thread), w(1:nbw,1:6), &
370
371
372
373
374
375
                    nbw, nl, stripe_width, nbw)
#endif

#else /* WITH_OPENMP */

#ifdef USE_ASSUMED_SIZE
Andreas Marek's avatar
Andreas Marek committed
376
                 call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
377
378
379
380
                      &MATH_DATATYPE&
                      &_generic_&
                      &PRECISION&
                      & (a(1,j+off+a_off-1,istripe),w, nbw, nl, stripe_width, nbw)
381
382

#else
Andreas Marek's avatar
Andreas Marek committed
383
                 call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
384
385
386
387
                      &MATH_DATATYPE&
                      &_generic_&
                      &PRECISION&
                      & (a(1:stripe_width,j+off+a_off-1:j+off+a_off+nbw-1,istripe),w(1:nbw,1:6), nbw, nl, stripe_width, nbw)
388
389
390
391
392
#endif
#endif /* WITH_OPENMP */

               enddo

393
#ifndef WITH_FIXED_REAL_KERNEL
394
             endif
395
#endif /* not WITH_FIXED_REAL_KERNEL */
396
397
#endif /* WITH_REAL_GENERIC_KERNEL */

398
399
400
401
402
#endif /* REALCASE == 1 */

#if COMPLEXCASE == 1
! generic kernel complex case
#if defined(WITH_COMPLEX_GENERIC_KERNEL)
403
#ifndef WITH_FIXED_COMPLEX_KERNEL
404
405
406
           if (kernel .eq. ELPA_2STAGE_COMPLEX_GENERIC .or. &
               kernel .eq. ELPA_2STAGE_COMPLEX_BGP .or. &
               kernel .eq. ELPA_2STAGE_COMPLEX_BGQ ) then
407
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
408
409
410
411
412
413
             ttt = mpi_wtime()
             do j = ncols, 1, -1
#ifdef WITH_OPENMP
#ifdef USE_ASSUMED_SIZE

              call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
414
415
416
417
                   &MATH_DATATYPE&
                   &_generic_&
                   &PRECISION&
                   & (a(1,j+off+a_off,istripe,my_thread), bcast_buffer(1,j+off),nbw,nl,stripe_width)
418
419
#else
              call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
420
421
422
423
424
                   &MATH_DATATYPE&
                   &_generic_&
                   &PRECISION&
                   & (a(1:stripe_width,j+off+a_off:j+off+a_off+nbw-1,istripe,my_thread), &
		     bcast_buffer(1:nbw,j+off), nbw, nl, stripe_width)
425
#endif
426

427
428
429
430
#else /* WITH_OPENMP */

#ifdef USE_ASSUMED_SIZE
              call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
431
432
433
434
                   &MATH_DATATYPE&
                   &_generic_&
                   &PRECISION&
                   & (a(1,j+off+a_off,istripe), bcast_buffer(1,j+off),nbw,nl,stripe_width)
435
436
#else
              call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
437
438
439
440
441
                   &MATH_DATATYPE&
                   &_generic_&
                   &PRECISION&
                   & (a(1:stripe_width,j+off+a_off:j+off+a_off+nbw-1,istripe), bcast_buffer(1:nbw,j+off), &
		      nbw, nl, stripe_width)
442
443
444
445
#endif
#endif /* WITH_OPENMP */

            enddo
446
#ifndef WITH_FIXED_COMPLEX_KERNEL
447
          endif ! (kernel .eq. ELPA_2STAGE_COMPLEX_GENERIC .or. kernel .eq. ELPA_2STAGE_COMPLEX_BGP .or. kernel .eq. ELPA_2STAGE_COMPLEX_BGQ )
448
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
449
450
451
452
453
#endif /* WITH_COMPLEX_GENERIC_KERNEL */

#endif /* COMPLEXCASE */

#if REALCASE == 1
Andreas Marek's avatar
Andreas Marek committed
454
455


456
! generic simple real kernel
457
#if defined(WITH_REAL_GENERIC_SIMPLE_KERNEL)
458
#ifndef WITH_FIXED_REAL_KERNEL
459
             if (kernel .eq. ELPA_2STAGE_REAL_GENERIC_SIMPLE) then
460
#endif /* not WITH_FIXED_REAL_KERNEL */
461
462
463
464
465
466
               do j = ncols, 2, -2
                 w(:,1) = bcast_buffer(1:nbw,j+off)
                 w(:,2) = bcast_buffer(1:nbw,j+off-1)
#ifdef WITH_OPENMP

#ifdef USE_ASSUMED_SIZE
467
                 call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
468
469
470
471
                      &MATH_DATATYPE&
                      &_generic_simple_&
                      &PRECISION&
                      & (a(1,j+off+a_off-1,istripe,my_thread), w, nbw, nl, stripe_width, nbw)
472
#else
473
                 call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
474
475
476
477
                      &MATH_DATATYPE&
                      &_generic_simple_&
                      &PRECISION&
                      & (a(1:stripe_width,j+off+a_off-1:j+off+a_off-1+nbw,istripe,my_thread), w, nbw, nl, stripe_width, nbw)
478
479
480
481
482
483

#endif

#else /* WITH_OPENMP */

#ifdef USE_ASSUMED_SIZE
484
                 call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
485
486
487
488
                      &MATH_DATATYPE&
                      &_generic_simple_&
                      &PRECISION&
                      & (a(1,j+off+a_off-1,istripe), w, nbw, nl, stripe_width, nbw)
489
#else
490
                 call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
491
492
493
494
                      &MATH_DATATYPE&
                      &_generic_simple_&
                      &PRECISION&
                      & (a(1:stripe_width,j+off+a_off-1:j+off+a_off-1+nbw,istripe), w, nbw, nl, stripe_width, nbw)
495
496
497
498
499
500

#endif

#endif /* WITH_OPENMP */

               enddo
501
#ifndef WITH_FIXED_REAL_KERNEL
502
             endif
503
#endif /* not WITH_FIXED_REAL_KERNEL */
504
505
#endif /* WITH_REAL_GENERIC_SIMPLE_KERNEL */

506
507
508
509
#endif /* REALCASE */

#if COMPLEXCASE == 1
! generic simple complex case
510

511
#if defined(WITH_COMPLEX_GENERIC_SIMPLE_KERNEL)
512
#ifndef WITH_FIXED_COMPLEX_KERNEL
513
            if (kernel .eq. ELPA_2STAGE_COMPLEX_GENERIC_SIMPLE) then
514
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
515
516
517
518
519
             ttt = mpi_wtime()
             do j = ncols, 1, -1
#ifdef WITH_OPENMP
#ifdef USE_ASSUMED_SIZE
               call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
520
521
522
523
                    &MATH_DATATYPE&
                    &_generic_simple_&
                    &PRECISION&
                    & (a(1,j+off+a_off,istripe,my_thread), bcast_buffer(1,j+off),nbw,nl,stripe_width)
524
525
#else
               call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
526
527
528
529
530
                    &MATH_DATATYPE&
                    &_generic_simple_&
                    &PRECISION&
                    & (a(1:stripe_width, j+off+a_off:j+off+a_off+nbw-1,istripe,my_thread), bcast_buffer(1:nbw,j+off), &
		       nbw, nl, stripe_width)
531
532
533
534
535
536
#endif

#else /* WITH_OPENMP */

#ifdef USE_ASSUMED_SIZE
               call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
537
538
539
540
                     &MATH_DATATYPE&
                     &_generic_simple_&
                     &PRECISION&
                     & (a(1,j+off+a_off,istripe), bcast_buffer(1,j+off),nbw,nl,stripe_width)
541
542
#else
               call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
543
544
545
546
                    &MATH_DATATYPE&
                    &_generic_simple_&
                    &PRECISION&
                    & (a(1:stripe_width,j+off+a_off:j+off+a_off+nbw-1,istripe), bcast_buffer(1:nbw,j+off), &
Andreas Marek's avatar
Andreas Marek committed
547
                       nbw, nl, stripe_width)
548
549
550
551
#endif

#endif /* WITH_OPENMP */
             enddo
552
#ifndef WITH_FIXED_COMPLEX_KERNEL
553
           endif ! (kernel .eq. ELPA_2STAGE_COMPLEX_GENERIC_SIMPLE)
554
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
555
#endif /* WITH_COMPLEX_GENERIC_SIMPLE_KERNEL */
Andreas Marek's avatar
Andreas Marek committed
556

557
558
559
560
#endif /* COMPLEXCASE */

#if REALCASE == 1
! sse assembly kernel real case
561
#if defined(WITH_REAL_SSE_ASSEMBLY_KERNEL)
562
#ifndef WITH_FIXED_REAL_KERNEL
563
             if (kernel .eq. ELPA_2STAGE_REAL_SSE_ASSEMBLY) then
Andreas Marek's avatar
Andreas Marek committed
564

565
#endif /* not WITH_FIXED_REAL_KERNEL */
566
567
568
569
570
               do j = ncols, 2, -2
                 w(:,1) = bcast_buffer(1:nbw,j+off)
                 w(:,2) = bcast_buffer(1:nbw,j+off-1)
#ifdef WITH_OPENMP
                 call double_hh_trafo_&
571
                 &MATH_DATATYPE&
Andreas Marek's avatar
Andreas Marek committed
572
573
574
575
                 &_&
                 &PRECISION&
                 &_sse_assembly&
                 & (c_loc(a(1,j+off+a_off-1,istripe,my_thread)), w, nbw, nl, stripe_width, nbw)
576
577
#else
                 call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
578
579
580
581
582
                      &MATH_DATATYPE&
                      &_&
                      &PRECISION&
                      &_sse_assembly&
                      & (c_loc(a(1,j+off+a_off-1,istripe)), w, nbw, nl, stripe_width, nbw)
583
584
#endif
               enddo
585
#ifndef WITH_FIXED_REAL_KERNEL
586
             endif
587
#endif /* not WITH_FIXED_REAL_KERNEL */
588
589
#endif /* WITH_REAL_SSE_ASSEMBLY_KERNEL */

590
591
592
#endif /* REALCASE */

#if COMPLEXCASE == 1
Andreas Marek's avatar
Andreas Marek committed
593

594
595
! sse assembly kernel complex case
#if defined(WITH_COMPLEX_SSE_ASSEMBLY_KERNEL)
596
#ifndef WITH_FIXED_COMPLEX_KERNEL
597
           if (kernel .eq. ELPA_2STAGE_COMPLEX_SSE_ASSEMBLY) then
598
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
599
600
601
602
             ttt = mpi_wtime()
             do j = ncols, 1, -1
#ifdef WITH_OPENMP
              call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
603
604
605
606
607
                   &MATH_DATATYPE&
                   &_&
                   &PRECISION&
                   &_sse_assembly&
                   & (c_loc(a(1,j+off+a_off,istripe,my_thread)), bcast_buffer(1,j+off),nbw,nl,stripe_width)
608
609
#else
              call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
610
611
612
613
614
                   &MATH_DATATYPE&
                   &_&
                   &PRECISION&
                   &_sse_assembly&
                   & (c_loc(a(1,j+off+a_off,istripe)), bcast_buffer(1,j+off),nbw,nl,stripe_width)
615
616
#endif
            enddo
617
#ifndef WITH_FIXED_COMPLEX_KERNEL
618
          endif ! (kernel .eq. ELPA_2STAGE_COMPLEX_SSE)
619
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
620
621
622
623
#endif /* WITH_COMPLEX_SSE_ASSEMBLY_KERNEL */
#endif /* COMPLEXCASE */

#if REALCASE == 1
624
! no sse, vsx, sparc64 block1 real kernel
625
626
#endif

627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
#if COMPLEXCASE == 1

! sparc64 block1 complex kernel
#if defined(WITH_COMPLEX_SPARC64_BLOCK1_KERNEL)
#ifndef WITH_FIXED_COMPLEX_KERNEL
          if (kernel .eq. ELPA_2STAGE_COMPLEX_SPARC64_BLOCK1) then
#endif /* not WITH_FIXED_COMPLEX_KERNEL */

#if (!defined(WITH_FIXED_COMPLEX_KERNEL)) || (defined(WITH_FIXED_COMPLEX_KERNEL) && !defined(WITH_COMPLEX_SPARC64_BLOCK2_KERNEL))
            ttt = mpi_wtime()
            do j = ncols, 1, -1
#ifdef WITH_OPENMP
              call single_hh_trafo_&
                   &MATH_DATATYPE&
                   &_sparc64_1hv_&
                   &PRECISION&
                   & (c_loc(a(1,j+off+a_off,istripe,my_thread)), bcast_buffer(1,j+off),nbw,nl,stripe_width)
#else
              call single_hh_trafo_&
                   &MATH_DATATYPE&
                   &_sparc64_1hv_&
                   &PRECISION&
                   & (c_loc(a(1,j+off+a_off,istripe)), bcast_buffer(1,j+off),nbw,nl,stripe_width)
#endif
            enddo
#endif /* (!defined(WITH_FIXED_COMPLEX_KERNEL)) || (defined(WITH_FIXED_COMPLEX_KERNEL) && !defined(WITH_COMPLEX_SPARC64_BLOCK2_KERNEL)) */

#ifndef WITH_FIXED_COMPLEX_KERNEL
          endif ! (kernel .eq. ELPA_2STAGE_COMPLEX_SPARC64_BLOCK1)
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
#endif /* WITH_COMPLEX_SPARC64_BLOCK1_KERNEL */

#endif /* COMPLEXCASE */


662
663
664
665
#if COMPLEXCASE == 1

! vsx block1 complex kernel
#if defined(WITH_COMPLEX_VSX_BLOCK1_KERNEL)
666
667
668
669
670
671
672
!#ifndef WITH_FIXED_COMPLEX_KERNEL
!          if (kernel .eq. ELPA_2STAGE_COMPLEX_VSX_BLOCK1) then
!#endif /* not WITH_FIXED_COMPLEX_KERNEL */
!
!#if (!defined(WITH_FIXED_COMPLEX_KERNEL)) || (defined(WITH_FIXED_COMPLEX_KERNEL) && !defined(WITH_COMPLEX_VSX_BLOCK2_KERNEL))
!            ttt = mpi_wtime()
!            do j = ncols, 1, -1
673
674
675
676
677
678
679
680
681
682
683
684
685
!#ifdef WITH_OPENMP
!              call single_hh_trafo_&
!                   &MATH_DATATYPE&
!                   &_vsx_1hv_&
!                   &PRECISION&
!                   & (c_loc(a(1,j+off+a_off,istripe,my_thread)), bcast_buffer(1,j+off),nbw,nl,stripe_width)
!#else
!              call single_hh_trafo_&
!                   &MATH_DATATYPE&
!                   &_vsx_1hv_&
!                   &PRECISION&
!                   & (c_loc(a(1,j+off+a_off,istripe)), bcast_buffer(1,j+off),nbw,nl,stripe_width)
!#endif
686
687
688
689
690
691
!            enddo
!#endif /* (!defined(WITH_FIXED_COMPLEX_KERNEL)) || (defined(WITH_FIXED_COMPLEX_KERNEL) && !defined(WITH_COMPLEX_VSX_BLOCK2_KERNEL)) */
!
!#ifndef WITH_FIXED_COMPLEX_KERNEL
!          endif ! (kernel .eq. ELPA_2STAGE_COMPLEX_VSX_BLOCK1)
!#endif /* not WITH_FIXED_COMPLEX_KERNEL */
692
693
694
695
696
#endif /* WITH_COMPLEX_VSX_BLOCK1_KERNEL */

#endif /* COMPLEXCASE */


697
#if COMPLEXCASE == 1
Andreas Marek's avatar
Andreas Marek committed
698

699
700
! sse block1 complex kernel
#if defined(WITH_COMPLEX_SSE_BLOCK1_KERNEL)
701
#ifndef WITH_FIXED_COMPLEX_KERNEL
702
          if (kernel .eq. ELPA_2STAGE_COMPLEX_SSE_BLOCK1) then
703
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
704

705
#if (!defined(WITH_FIXED_COMPLEX_KERNEL)) || (defined(WITH_FIXED_COMPLEX_KERNEL) && !defined(WITH_COMPLEX_SSE_BLOCK2_KERNEL))
706
707
708
709
            ttt = mpi_wtime()
            do j = ncols, 1, -1
#ifdef WITH_OPENMP
              call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
710
711
712
713
                   &MATH_DATATYPE&
                   &_sse_1hv_&
                   &PRECISION&
                   & (c_loc(a(1,j+off+a_off,istripe,my_thread)), bcast_buffer(1,j+off),nbw,nl,stripe_width)
714
715
#else
              call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
716
717
718
719
                   &MATH_DATATYPE&
                   &_sse_1hv_&
                   &PRECISION&
                   & (c_loc(a(1,j+off+a_off,istripe)), bcast_buffer(1,j+off),nbw,nl,stripe_width)
720
721
#endif
            enddo
722
#endif /* (!defined(WITH_FIXED_COMPLEX_KERNEL)) || (defined(WITH_FIXED_COMPLEX_KERNEL) && !defined(WITH_COMPLEX_SSE_BLOCK2_KERNEL)) */
723

724
#ifndef WITH_FIXED_COMPLEX_KERNEL
725
          endif ! (kernel .eq. ELPA_2STAGE_COMPLEX_SSE_BLOCK1)
726
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
727
728
729
730
731
732
733
734
735
#endif /* WITH_COMPLEX_SSE_BLOCK1_KERNEL */

#endif /* COMPLEXCASE */

#if REALCASE == 1
!no avx block1 real kernel
#endif /* REALCASE */

#if COMPLEXCASE == 1
Andreas Marek's avatar
Andreas Marek committed
736

737
738
! avx block1 complex kernel
#if defined(WITH_COMPLEX_AVX_BLOCK1_KERNEL) || defined(WITH_COMPLEX_AVX2_BLOCK1_KERNEL)
739
#ifndef WITH_FIXED_COMPLEX_KERNEL
740
741
          if ((kernel .eq. ELPA_2STAGE_COMPLEX_AVX_BLOCK1) .or. &
              (kernel .eq. ELPA_2STAGE_COMPLEX_AVX2_BLOCK1)) then
742
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
743

744
#if (!defined(WITH_FIXED_COMPLEX_KERNEL)) || (defined(WITH_FIXED_COMPLEX_KERNEL) && !defined(WITH_COMPLEX_AVX_BLOCK2_KERNEL) && !defined(WITH_COMPLEX_AVX2_BLOCK2_KERNEL))
745
746
747
748
            ttt = mpi_wtime()
            do j = ncols, 1, -1
#ifdef WITH_OPENMP
              call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
749
750
751
752
                   &MATH_DATATYPE&
                   &_avx_avx2_1hv_&
                   &PRECISION&
                   & (c_loc(a(1,j+off+a_off,istripe,my_thread)), bcast_buffer(1,j+off),nbw,nl,stripe_width)
753
754
#else
              call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
755
756
757
758
                   &MATH_DATATYPE&
                   &_avx_avx2_1hv_&
                   &PRECISION&
                   & (c_loc(a(1,j+off+a_off,istripe)), bcast_buffer(1,j+off),nbw,nl,stripe_width)
759
760
#endif
            enddo
761
#endif /* (!defined(WITH_FIXED_COMPLEX_KERNEL)) || (defined(WITH_FIXED_COMPLEX_KERNEL) && !defined(WITH_COMPLEX_AVX_BLOCK2_KERNEL) && !defined(WITH_COMPLEX_AVX2_BLOCK2_KERNEL)) */
762

763
#ifndef WITH_FIXED_COMPLEX_KERNEL
764
          endif ! ((kernel .eq. ELPA_2STAGE_COMPLEX_AVX_BLOCK1) .or. (kernel .eq. ELPA_2STAGE_COMPLEX_AVX2_BLOCK1))
765
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
766
767
768
769
770
771
772
773
774
#endif /* WITH_COMPLEX_AVX_BLOCK1_KERNEL || WITH_COMPLEX_AVX2_BLOCK1_KERNEL */

#endif /* COMPLEXCASE */

#if REALCASE == 1
! no avx512 block1 real kernel
#endif /* REALCASE */

#if COMPLEXCASE == 1
Andreas Marek's avatar
Andreas Marek committed
775

776
777
! avx512 block1 complex kernel
#if defined(WITH_COMPLEX_AVX512_BLOCK1_KERNEL)
778
#ifndef WITH_FIXED_COMPLEX_KERNEL
779
          if ((kernel .eq. ELPA_2STAGE_COMPLEX_AVX512_BLOCK1)) then
780
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
781

782
#if (!defined(WITH_FIXED_COMPLEX_KERNEL)) || (defined(WITH_FIXED_COMPLEX_KERNEL) && !defined(WITH_COMPLEX_AVX512_BLOCK2_KERNEL) )
783
784
785
786
            ttt = mpi_wtime()
            do j = ncols, 1, -1
#ifdef WITH_OPENMP
              call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
787
788
789
790
                   &MATH_DATATYPE&
                   &_avx512_1hv_&
                   &PRECISION&
                   & (c_loc(a(1,j+off+a_off,istripe,my_thread)), bcast_buffer(1,j+off),nbw,nl,stripe_width)
791
792
#else
              call single_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
793
794
795
796
                   &MATH_DATATYPE&
                   &_avx512_1hv_&
                   &PRECISION&
                   & (c_loc(a(1,j+off+a_off,istripe)), bcast_buffer(1,j+off),nbw,nl,stripe_width)
797
798
#endif
            enddo
799
#endif /* (!defined(WITH_FIXED_COMPLEX_KERNEL)) || (defined(WITH_FIXED_COMPLEX_KERNEL) && !defined(WITH_COMPLEX_AVX512_BLOCK2_KERNEL) ) */
800

801
#ifndef WITH_FIXED_COMPLEX_KERNEL
802
          endif ! ((kernel .eq. ELPA_2STAGE_COMPLEX_AVX512_BLOCK1))
803
#endif /* not WITH_FIXED_COMPLEX_KERNEL */
804
805
806
807
#endif /* WITH_COMPLEX_AVX512_BLOCK1_KERNEL  */
#endif /* COMPLEXCASE */

#if REALCASE == 1
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
! implementation of sparc64 block 2 real case
#if defined(WITH_REAL_SPARC64_BLOCK2_KERNEL)

#ifndef WITH_FIXED_REAL_KERNEL
           if (kernel .eq. ELPA_2STAGE_REAL_SPARC64_BLOCK2) then

#endif /* not WITH_FIXED_REAL_KERNEL */

#if (!defined(WITH_FIXED_REAL_KERNEL)) || (defined(WITH_FIXED_REAL_KERNEL) && !defined(WITH_REAL_SPARC64_BLOCK6_KERNEL) && !defined(WITH_REAL_SPARC64_BLOCK4_KERNEL))
             do j = ncols, 2, -2
               w(:,1) = bcast_buffer(1:nbw,j+off)
               w(:,2) = bcast_buffer(1:nbw,j+off-1)
#ifdef WITH_OPENMP
               call double_hh_trafo_&
                    &MATH_DATATYPE&
                    &_sparc64_2hv_&
                    &PRECISION &
                    & (c_loc(a(1,j+off+a_off-1,istripe,my_thread)), w, nbw, nl, stripe_width, nbw)
#else
               call double_hh_trafo_&
                    &MATH_DATATYPE&
                    &_sparc64_2hv_&
                    &PRECISION &
                    & (c_loc(a(1,j+off+a_off-1,istripe)), w, nbw, nl, stripe_width, nbw)
#endif
             enddo
#endif /* (!defined(WITH_FIXED_REAL_KERNEL)) || (defined(WITH_FIXED_REAL_KERNEL) && !defined(WITH_REAL_SPARC64_BLOCK6_KERNEL) && !defined(WITH_REAL_SPARC64_BLOCK4_KERNEL)) */

#ifndef WITH_FIXED_REAL_KERNEL
           endif
#endif /* not WITH_FIXED_REAL_KERNEL */
#endif /* WITH_REAL_SPARC64_BLOCK2_KERNEL */

#endif /* REALCASE == 1 */
842
843


844
#if REALCASE == 1
845
846
! implementation of vsx block 2 real case
#if defined(WITH_REAL_VSX_BLOCK2_KERNEL)
847

848
#ifndef WITH_FIXED_REAL_KERNEL
849
           if (kernel .eq. ELPA_2STAGE_REAL_VSX_BLOCK2) then
Andreas Marek's avatar
Andreas Marek committed
850

851
#endif /* not WITH_FIXED_REAL_KERNEL */
852

853
#if (!defined(WITH_FIXED_REAL_KERNEL)) || (defined(WITH_FIXED_REAL_KERNEL) && !defined(WITH_REAL_VSX_BLOCK6_KERNEL) && !defined(WITH_REAL_VSX_BLOCK4_KERNEL))
854
855
856
857
858
             do j = ncols, 2, -2
               w(:,1) = bcast_buffer(1:nbw,j+off)
               w(:,2) = bcast_buffer(1:nbw,j+off-1)
#ifdef WITH_OPENMP
               call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
859
                    &MATH_DATATYPE&
860
                    &_vsx_2hv_&
Andreas Marek's avatar
Andreas Marek committed
861
862
                    &PRECISION &
                    & (c_loc(a(1,j+off+a_off-1,istripe,my_thread)), w, nbw, nl, stripe_width, nbw)
863
864
#else
               call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
865
                    &MATH_DATATYPE&
866
                    &_vsx_2hv_&
Andreas Marek's avatar
Andreas Marek committed
867
868
                    &PRECISION &
                    & (c_loc(a(1,j+off+a_off-1,istripe)), w, nbw, nl, stripe_width, nbw)
869
870
#endif
             enddo
871
#endif /* (!defined(WITH_FIXED_REAL_KERNEL)) || (defined(WITH_FIXED_REAL_KERNEL) && !defined(WITH_REAL_VSX_BLOCK6_KERNEL) && !defined(WITH_REAL_VSX_BLOCK4_KERNEL)) */
872

873
#ifndef WITH_FIXED_REAL_KERNEL
874
           endif
875
#endif /* not WITH_FIXED_REAL_KERNEL */
876
#endif /* WITH_REAL_VSX_BLOCK2_KERNEL */
877

878
879
#endif /* REALCASE == 1 */

Andreas Marek's avatar
Andreas Marek committed
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
#if REALCASE == 1
! implementation of sse block 2 real case
#if defined(WITH_REAL_SSE_BLOCK2_KERNEL)

#ifndef WITH_FIXED_REAL_KERNEL
           if (kernel .eq. ELPA_2STAGE_REAL_SSE_BLOCK2) then

#endif /* not WITH_FIXED_REAL_KERNEL */

#if (!defined(WITH_FIXED_REAL_KERNEL)) || (defined(WITH_FIXED_REAL_KERNEL) && !defined(WITH_REAL_SSE_BLOCK6_KERNEL) && !defined(WITH_REAL_SSE_BLOCK4_KERNEL))
             do j = ncols, 2, -2
               w(:,1) = bcast_buffer(1:nbw,j+off)
               w(:,2) = bcast_buffer(1:nbw,j+off-1)
#ifdef WITH_OPENMP
               call double_hh_trafo_&
                    &MATH_DATATYPE&
                    &_sse_2hv_&
                    &PRECISION &
                    & (c_loc(a(1,j+off+a_off-1,istripe,my_thread)), w, nbw, nl, stripe_width, nbw)
#else
               call double_hh_trafo_&
                    &MATH_DATATYPE&
                    &_sse_2hv_&
                    &PRECISION &
                    & (c_loc(a(1,j+off+a_off-1,istripe)), w, nbw, nl, stripe_width, nbw)
#endif
             enddo
#endif /* (!defined(WITH_FIXED_REAL_KERNEL)) || (defined(WITH_FIXED_REAL_KERNEL) && !defined(WITH_REAL_SSE_BLOCK6_KERNEL) && !defined(WITH_REAL_SSE_BLOCK4_KERNEL)) */

#ifndef WITH_FIXED_REAL_KERNEL
           endif
#endif /* not WITH_FIXED_REAL_KERNEL */
#endif /* WITH_REAL_SSE_BLOCK2_KERNEL */

#endif /* REALCASE == 1 */


917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
#if COMPLEXCASE == 1
! implementation of sparc64 block 2 complex case

#if defined(WITH_COMPLEX_SPARC64_BLOCK2_KERNEL)
#ifndef WITH_FIXED_COMPLEX_KERNEL
           if (kernel .eq. ELPA_2STAGE_COMPLEX_SPARC64_BLOCK2) then
#endif  /* not WITH_FIXED_COMPLEX_KERNEL */

             ttt = mpi_wtime()
             do j = ncols, 2, -2
               w(:,1) = bcast_buffer(1:nbw,j+off)
               w(:,2) = bcast_buffer(1:nbw,j+off-1)
#ifdef WITH_OPENMP
               call double_hh_trafo_&
                    &MATH_DATATYPE&
                    &_sparc64_2hv_&
                    &PRECISION&
                    & (c_loc(a(1,j+off+a_off-1,istripe,my_thread)), w, nbw, nl, stripe_width, nbw)
#else
               call double_hh_trafo_&
                    &MATH_DATATYPE&
                    &_sparc64_2hv_&
                    &PRECISION&
                    & (c_loc(a(1,j+off+a_off-1,istripe)), w, nbw, nl, stripe_width, nbw)
#endif
             enddo
#ifdef WITH_OPENMP
             if (j==1) call single_hh_trafo_&
                 &MATH_DATATYPE&
                       &_sparc64_1hv_&
                       &PRECISION&
                       & (c_loc(a(1,1+off+a_off,istripe,my_thread)), bcast_buffer(1,off+1), nbw, nl, stripe_width)
#else
             if (j==1) call single_hh_trafo_&
                 &MATH_DATATYPE&
                            &_sparc64_1hv_&
                            &PRECISION&
                            & (c_loc(a(1,1+off+a_off,istripe)), bcast_buffer(1,off+1), nbw, nl, stripe_width)
#endif

#ifndef WITH_FIXED_COMPLEX_KERNEL
           endif ! (kernel .eq. ELPA_2STAGE_COMPLEX_SPARC64_BLOCK2)
#endif  /* not WITH_FIXED_COMPLEX_KERNEL */
#endif /* WITH_COMPLEX_SPARC64_BLOCK2_KERNEL */
#endif /* COMPLEXCASE == 1 */

963
964
965
966
967

#if COMPLEXCASE == 1
! implementation of vsx block 2 complex case

#if defined(WITH_COMPLEX_VSX_BLOCK2_KERNEL)
968
969
970
971
972
973
974
975
!#ifndef WITH_FIXED_COMPLEX_KERNEL
!           if (kernel .eq. ELPA_2STAGE_COMPLEX_VSX_BLOCK2) then
!#endif  /* not WITH_FIXED_COMPLEX_KERNEL */
!
!             ttt = mpi_wtime()
!             do j = ncols, 2, -2
!               w(:,1) = bcast_buffer(1:nbw,j+off)
!               w(:,2) = bcast_buffer(1:nbw,j+off-1)
976
977
978
979
980
981
982
983
984
985
986
987
988
!#ifdef WITH_OPENMP
!               call double_hh_trafo_&
!                    &MATH_DATATYPE&
!                    &_vsx_2hv_&
!                    &PRECISION&
!                    & (c_loc(a(1,j+off+a_off-1,istripe,my_thread)), w, nbw, nl, stripe_width, nbw)
!#else
!               call double_hh_trafo_&
!                    &MATH_DATATYPE&
!                    &_vsx_2hv_&
!                    &PRECISION&
!                    & (c_loc(a(1,j+off+a_off-1,istripe)), w, nbw, nl, stripe_width, nbw)
!#endif
989
!             enddo
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
!#ifdef WITH_OPENMP
!             if (j==1) call single_hh_trafo_&
!                 &MATH_DATATYPE&
!                       &_vsx_1hv_&
!                       &PRECISION&
!                       & (c_loc(a(1,1+off+a_off,istripe,my_thread)), bcast_buffer(1,off+1), nbw, nl, stripe_width)
!#else
!             if (j==1) call single_hh_trafo_&
!                 &MATH_DATATYPE&
!                            &_vsx_1hv_&
!                            &PRECISION&
!                            & (c_loc(a(1,1+off+a_off,istripe)), bcast_buffer(1,off+1), nbw, nl, stripe_width)
!#endif
1003
1004
1005
1006
!
!#ifndef WITH_FIXED_COMPLEX_KERNEL
!           endif ! (kernel .eq. ELPA_2STAGE_COMPLEX_VSX_BLOCK2)
!#endif  /* not WITH_FIXED_COMPLEX_KERNEL */
1007
1008
1009
#endif /* WITH_COMPLEX_VSX_BLOCK2_KERNEL */
#endif /* COMPLEXCASE == 1 */

1010
1011
1012
1013
#if COMPLEXCASE == 1
! implementation of sse block 2 complex case

#if defined(WITH_COMPLEX_SSE_BLOCK2_KERNEL)
1014
#ifndef WITH_FIXED_COMPLEX_KERNEL
1015
           if (kernel .eq. ELPA_2STAGE_COMPLEX_SSE_BLOCK2) then
1016
#endif  /* not WITH_FIXED_COMPLEX_KERNEL */
1017
1018
1019
1020
1021
1022
1023

             ttt = mpi_wtime()
             do j = ncols, 2, -2
               w(:,1) = bcast_buffer(1:nbw,j+off)
               w(:,2) = bcast_buffer(1:nbw,j+off-1)
#ifdef WITH_OPENMP
               call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
1024
1025
1026
1027
                    &MATH_DATATYPE&
                    &_sse_2hv_&
                    &PRECISION&
                    & (c_loc(a(1,j+off+a_off-1,istripe,my_thread)), w, nbw, nl, stripe_width, nbw)
1028
1029
#else
               call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
1030
1031
1032
1033
                    &MATH_DATATYPE&
                    &_sse_2hv_&
                    &PRECISION&
                    & (c_loc(a(1,j+off+a_off-1,istripe)), w, nbw, nl, stripe_width, nbw)
1034
1035
1036
1037
#endif
             enddo
#ifdef WITH_OPENMP
             if (j==1) call single_hh_trafo_&
Andreas Marek's avatar
Retab    
Andreas Marek committed
1038
                 &MATH_DATATYPE&
Andreas Marek's avatar
Andreas Marek committed
1039
1040
1041
                       &_sse_1hv_&
                       &PRECISION&
                       & (c_loc(a(1,1+off+a_off,istripe,my_thread)), bcast_buffer(1,off+1), nbw, nl, stripe_width)
1042
1043
#else
             if (j==1) call single_hh_trafo_&
Andreas Marek's avatar
Retab    
Andreas Marek committed
1044
                 &MATH_DATATYPE&
Andreas Marek's avatar
Andreas Marek committed
1045
1046
1047
                            &_sse_1hv_&
                            &PRECISION&
                            & (c_loc(a(1,1+off+a_off,istripe)), bcast_buffer(1,off+1), nbw, nl, stripe_width)
1048
1049
#endif

1050
#ifndef WITH_FIXED_COMPLEX_KERNEL
1051
           endif ! (kernel .eq. ELPA_2STAGE_COMPLEX_SSE_BLOCK2)
1052
#endif  /* not WITH_FIXED_COMPLEX_KERNEL */
1053
1054
1055
1056
1057
1058
#endif /* WITH_COMPLEX_SSE_BLOCK2_KERNEL */
#endif /* COMPLEXCASE == 1 */

#if REALCASE == 1
! implementation of avx block 2 real case

1059
#if defined(WITH_REAL_AVX_BLOCK2_KERNEL) || defined(WITH_REAL_AVX2_BLOCK2_KERNEL)
1060
#ifndef WITH_FIXED_REAL_KERNEL
1061

1062
1063
           if ((kernel .eq. ELPA_2STAGE_REAL_AVX_BLOCK2) .or. &
               (kernel .eq. ELPA_2STAGE_REAL_AVX2_BLOCK2))  then
Andreas Marek's avatar
Andreas Marek committed
1064

1065
#endif /* not WITH_FIXED_REAL_KERNEL */
1066

1067
#if (!defined(WITH_FIXED_REAL_KERNEL)) || (defined(WITH_FIXED_REAL_KERNEL) && !defined(WITH_REAL_AVX_BLOCK6_KERNEL) && !defined(WITH_REAL_AVX_BLOCK4_KERNEL) && !defined(WITH_REAL_AVX2_BLOCK6_KERNEL) && !defined(WITH_REAL_AVX2_BLOCK4_KERNEL))
1068
1069
1070
1071
1072
1073
               do j = ncols, 2, -2
                 w(:,1) = bcast_buffer(1:nbw,j+off)
                 w(:,2) = bcast_buffer(1:nbw,j+off-1)
#ifdef WITH_OPENMP

               call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
1074
1075
1076
1077
                    &MATH_DATATYPE&
                    &_avx_avx2_2hv_&
                    &PRECISION&
                    & (c_loc(a(1,j+off+a_off-1,istripe,my_thread)), w, nbw, nl, stripe_width, nbw)
1078
1079
#else
               call double_hh_trafo_&
Andreas Marek's avatar
Andreas Marek committed
1080
1081
1082
1083
                    &MATH_DATATYPE&
                    &_avx_avx2_2hv_&
                    &PRECISION&
                    & (c_loc(a(1,j+off+a_off-1,istripe)), w, nbw, nl, stripe_width, nbw)
1084
1085
#endif
               enddo
1086
#endif /* (!defined(WITH_FIXED_REAL_KERNEL)) || (defined(WITH_FIXED_REAL_KERNEL) ... */
1087

1088
#ifndef WITH_FIXED_REAL_KERNEL
1089
             endif
1090
#endif /* not WITH_FIXED_REAL_KERNEL */
1091
1092
#endif /* WITH_REAL_AVX_BLOCK2_KERNEL || WITH_REAL_AVX2_BLOCK2_KERNEL */

1093
1094
1095
#endif /* REALCASE */

#if COMPLEXCASE == 1
Andreas Marek's avatar
Andreas Marek committed
1096

1097
1098
! implementation of avx block 2 complex case
#if defined(WITH_COMPLEX_AVX_BLOCK2_KERNEL) || defined(WITH_COMPLEX_AVX2_BLOCK2_KERNEL)
1099
#ifndef WITH_FIXED_COMPLEX_KERNEL
1100
1101
           if ( (kernel .eq. ELPA_2STAGE_COMPLEX_AVX_BLOCK2) .or. &
                (kernel .eq. ELPA_2STAGE_COMPLEX_AVX2_BLOCK2) ) then
1102
#endif  /* not WITH_FIXED_COMPLEX_KERNEL */
1103
1104
1105
1106
1107
1108
1109

              ttt = mpi_wtime()
             do j = ncols, 2, -2
               w(:,1) = bcast_buffer(1:nbw,j+off)