mod_compute_hh_trafo_real.F90 54.2 KB
Newer Older
1
2
3
4
5
!    This file is part of ELPA.
!
!    The ELPA library was originally created by the ELPA consortium,
!    consisting of the following organizations:
!
6
7
!    - Max Planck Computing and Data Facility (MPCDF), formerly known as
!      Rechenzentrum Garching der Max-Planck-Gesellschaft (RZG),
8
9
10
11
12
!    - 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,
13
!    - Max-Plack-Institut für Mathematik in den Naturwissenschaften,
14
15
16
17
18
19
!      Leipzig, Abt. Komplexe Strukutren in Biologie und Kognition,
!      and
!    - IBM Deutschland GmbH
!
!
!    More information can be found here:
20
!    http://elpa.mpcdf.mpg.de/
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
!
!    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

44
45
module compute_hh_trafo_real
#include "config-f90.h"
46
  use elpa_mpi
47
48
49
  implicit none

#ifdef WITH_OPENMP
50
51
52
53
54
55
56
57
  public compute_hh_trafo_real_cpu_openmp_double
#else
  public compute_hh_trafo_real_cpu_double
#endif

#ifdef WANT_SINGLE_PRECISION_REAL
#ifdef WITH_OPENMP
  public compute_hh_trafo_real_cpu_openmp_single
58
#else
59
60
61
62
  public compute_hh_trafo_real_cpu_single
#endif


63
64
65
66
67
#endif

  contains

#ifdef WITH_OPENMP
68
       subroutine compute_hh_trafo_real_cpu_openmp_double(a, a_dev, stripe_width, a_dim2, stripe_count, max_threads, l_nev, &
69
                                                   a_off, nbw, max_blk_size, bcast_buffer, bcast_buffer_dev, hh_dot_dev,    &
70
                                                   hh_tau_dev, kernel_flops, kernel_time, off, ncols, istripe,              &
71
                                                   my_thread, thread_width, THIS_REAL_ELPA_KERNEL)
72
#else
73
       subroutine compute_hh_trafo_real_cpu_double       (a, a_dev, stripe_width, a_dim2, stripe_count,                       &
74
75
76
                                                   a_off, nbw, max_blk_size, bcast_buffer,  bcast_buffer_dev, hh_dot_dev,     &
                                                   hh_tau_dev, kernel_flops, kernel_time, off, ncols, istripe,                &
                                                   last_stripe_width, THIS_REAL_ELPA_KERNEL)
77
78
79
80
#endif


         use precision
81
         use iso_c_binding
82
83
         use elpa2_utilities
         use single_hh_trafo_real
84
85
86
         use cuda_c_kernel
         use cuda_functions

87
#if defined(WITH_REAL_GENERIC_SIMPLE_KERNEL) && !(defined(USE_ASSUMED_SIZE))
88
         use real_generic_simple_kernel !, only : double_hh_trafo_generic_simple
89
90
#endif

91
#if defined(WITH_REAL_GENERIC_KERNEL) && !(defined(USE_ASSUMED_SIZE))
92
        use real_generic_kernel !, only : double_hh_trafo_generic
93
#endif
94
95

#if defined(WITH_REAL_BGP_KERNEL)
96
         use real_bgp_kernel !, only : double_hh_trafo_bgp
97
98
99
#endif

#if defined(WITH_REAL_BGQ_KERNEL)
100
         use real_bgq_kernel !, only : double_hh_trafo_bgq
101
102
103
104
#endif
#ifdef HAVE_DETAILED_TIMINGS
         use timings
#endif
105

106
#if defined(HAVE_AVX) || defined(HAVE_AVX2) || defined(HAVE_SSE_INTRINSICS) || defined(HAVE_SSE_ASSEMBLY)
107
108
         use kernel_interfaces
#endif
109
         implicit none
110
         real(kind=c_double), intent(inout) :: kernel_time  ! MPI_WTIME always needs double
111
112
         integer(kind=lik)            :: kernel_flops
         integer(kind=ik), intent(in) :: nbw, max_blk_size
113
         real(kind=rk8)                :: bcast_buffer(nbw,max_blk_size)
114
115
116
117
118
119
         integer(kind=ik), intent(in) :: a_off

         integer(kind=ik), intent(in) :: stripe_width,a_dim2,stripe_count

#ifndef WITH_OPENMP
         integer(kind=ik), intent(in) :: last_stripe_width
120
!         real(kind=rk8)                :: a(stripe_width,a_dim2,stripe_count)
121
         real(kind=rk8), pointer      :: a(:,:,:)
122
#else
123
         integer(kind=ik), intent(in) :: max_threads, l_nev, thread_width
124
!         real(kind=rk8)                :: a(stripe_width,a_dim2,stripe_count,max_threads)
125
         real(kind=rk8), pointer      :: a(:,:,:,:)
126
127
128
#endif
         integer(kind=ik), intent(in) :: THIS_REAL_ELPA_KERNEL

129
130
131
132
133
         integer(kind=c_intptr_t)     :: a_dev
         integer(kind=c_intptr_t)     :: bcast_buffer_dev
         integer(kind=c_size_t)       :: dev_offset
         integer(kind=c_intptr_t)     :: hh_dot_dev
         integer(kind=c_intptr_t)     :: hh_tau_dev
134
135
136
137
138
139
         ! Private variables in OMP regions (my_thread) should better be in the argument list!
         integer(kind=ik)             :: off, ncols, istripe
#ifdef WITH_OPENMP
         integer(kind=ik)             :: my_thread, noff
#endif
         integer(kind=ik)             :: j, nl, jj, jjj
140
         real(kind=rk8)                :: w(nbw,6)
141
         real(kind=c_double)          :: ttt ! MPI_WTIME always needs double
142

143
144
145
146
147
         if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GPU) then
           ! ncols - indicates the number of HH reflectors to apply; at least 1 must be available
           if (ncols < 1) return
         endif

148
149
#ifdef HAVE_DETAILED_TIMINGS
#ifdef WITH_OPENMP
150
         call timer%start("compute_hh_trafo_real_cpu_openmp_double")
151
#else
152
         call timer%start("compute_hh_trafo_real_cpu_double")
153
154
155
156
157
158
159
#endif
#endif
         ttt = mpi_wtime()

#ifndef WITH_OPENMP
         nl = merge(stripe_width, last_stripe_width, istripe<stripe_count)
#else
160
161
162
163
         if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GPU) then
           print *,"compute_hh_trafo_real GPU OPENMP: not yet implemented"
           stop
         endif
164
165
166
167
168
169
170
171
172

         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
#ifdef HAVE_DETAILED_TIMINGS
#ifdef WITH_OPENMP
173
             call timer%stop("compute_hh_trafo_real_cpu_openmp_double")
174
#else
175
             call timer%stop("compute_hh_trafo_real_cpu_double")
176
177
178
179
180
#endif
#endif
             return
           endif
         endif
181
182
183
#endif /* not WITH_OPENMP */

         if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GPU) then
184
185
           dev_offset = (0 + (a_off * stripe_width) + ( (istripe - 1) * stripe_width *a_dim2 )) *size_of_double_real_datatype
           call launch_compute_hh_trafo_c_kernel_real_double(a_dev + dev_offset, bcast_buffer_dev, hh_dot_dev, &
186
187
                                                      hh_tau_dev, nl, nbw, stripe_width, off, ncols)
         else ! not CUDA kernel
188
189
190

#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
         if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX_BLOCK2 .or. &
191
             THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX2_BLOCK2 .or. &
192
             THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_SSE_BLOCK2 .or. &
193
194
195
196
197
198
199
             THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GENERIC    .or. &
             THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GENERIC_SIMPLE .or. &
             THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_SSE .or.        &
             THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_BGP .or.        &
             THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_BGQ) then
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */

200
             !FORTRAN CODE / X86 INRINISIC CODE / BG ASSEMBLER USING 2 HOUSEHOLDER VECTORS
201
202
#if defined(WITH_REAL_GENERIC_KERNEL)
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
203
             if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GENERIC) then
204
205
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */

206
207
208
               do j = ncols, 2, -2
                 w(:,1) = bcast_buffer(1:nbw,j+off)
                 w(:,2) = bcast_buffer(1:nbw,j+off-1)
209
210

#ifdef WITH_OPENMP
211
212

#ifdef USE_ASSUMED_SIZE
213
                 call double_hh_trafo_generic_double(a(1,j+off+a_off-1,istripe,my_thread), w, &
214
215
                                            nbw, nl, stripe_width, nbw)

216
#else
217
                 call double_hh_trafo_generic_double(a(1:stripe_width,j+off+a_off-1:j+off+a_off+nbw-1, &
218
                                              istripe,my_thread), w(1:nbw,1:6), &
219
                                              nbw, nl, stripe_width, nbw)
220
221
222
223
#endif

#else /* WITH_OPENMP */

224
#ifdef USE_ASSUMED_SIZE
225
                 call double_hh_trafo_generic_double(a(1,j+off+a_off-1,istripe),w, &
226
227
228
                                            nbw, nl, stripe_width, nbw)

#else
229
                 call double_hh_trafo_generic_double(a(1:stripe_width,j+off+a_off-1:j+off+a_off+nbw-1,istripe),w(1:nbw,1:6), &
230
                                            nbw, nl, stripe_width, nbw)
231
#endif
232
233
#endif /* WITH_OPENMP */

234
               enddo
235
236

#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
237
             endif
238
239
240
241
242
243
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_GENERIC_KERNEL */


#if defined(WITH_REAL_GENERIC_SIMPLE_KERNEL)
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
244
             if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GENERIC_SIMPLE) then
245
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
246
247
248
               do j = ncols, 2, -2
                 w(:,1) = bcast_buffer(1:nbw,j+off)
                 w(:,2) = bcast_buffer(1:nbw,j+off-1)
249
#ifdef WITH_OPENMP
250
251

#ifdef USE_ASSUMED_SIZE
252
                 call double_hh_trafo_generic_simple_double(a(1,j+off+a_off-1,istripe,my_thread), &
253
                                                       w, nbw, nl, stripe_width, nbw)
254
#else
255
                 call double_hh_trafo_generic_simple_double(a(1:stripe_width,j+off+a_off-1:j+off+a_off-1+nbw,istripe,my_thread), &
256
257
258
259
260
                                                     w, nbw, nl, stripe_width, nbw)

#endif

#else /* WITH_OPENMP */
261
262

#ifdef USE_ASSUMED_SIZE
263
                 call double_hh_trafo_generic_simple_double(a(1,j+off+a_off-1,istripe), &
264
                                                       w, nbw, nl, stripe_width, nbw)
265
#else
266
                 call double_hh_trafo_generic_simple_double(a(1:stripe_width,j+off+a_off-1:j+off+a_off-1+nbw,istripe), &
267
268
                                                     w, nbw, nl, stripe_width, nbw)

269
#endif
270
271
272

#endif /* WITH_OPENMP */

273
               enddo
274
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
275
             endif
276
277
278
279
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_GENERIC_SIMPLE_KERNEL */


280
#if defined(WITH_REAL_SSE_ASSEMBLY_KERNEL)
281
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
282
             if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_SSE) then
283
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
284
285
286
               do j = ncols, 2, -2
                 w(:,1) = bcast_buffer(1:nbw,j+off)
                 w(:,2) = bcast_buffer(1:nbw,j+off-1)
287
#ifdef WITH_OPENMP
288
                 call double_hh_trafo_double(c_loc(a(1,j+off+a_off-1,istripe,my_thread)), w, nbw, nl, &
289
290
                                      stripe_width, nbw)
#else
291
                 call double_hh_trafo_double(c_loc(a(1,j+off+a_off-1,istripe)), w, nbw, nl, &
292
293
                                      stripe_width, nbw)
#endif
294
               enddo
295
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
296
             endif
297
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
298
#endif /* WITH_REAL_SSE_ASSEMBLY_KERNEL */
299

300
301
302
303
#if defined(WITH_REAL_SSE_BLOCK2_KERNEL)
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
           if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_SSE_BLOCK2) then
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
304
305

#if defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_SSE_BLOCK6_KERNEL) && !defined(WITH_REAL_SSE_BLOCK4_KERNEL))
306
307
308
309
             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
310
               call double_hh_trafo_real_sse_2hv_double(c_loc(a(1,j+off+a_off-1,istripe,my_thread)), &
311
312
                                                       w, nbw, nl, stripe_width, nbw)
#else
313
               call double_hh_trafo_real_sse_2hv_double(c_loc(a(1,j+off+a_off-1,istripe)), &
314
315
316
                                                       w, nbw, nl, stripe_width, nbw)
#endif
             enddo
317
318
#endif /* defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_SSE_BLOCK6_KERNEL) && !defined(WITH_REAL_SSE_BLOCK4_KERNEL)) */

319
320
321
322
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
           endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_SSE_BLOCK2_KERNEL */
323

324
#if defined(WITH_REAL_AVX_BLOCK2_KERNEL) || defined(WITH_REAL_AVX2_BLOCK2_KERNEL)
325
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
326

327
328
           if ((THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX_BLOCK2) .or. &
               (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX2_BLOCK2))  then
329
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
330
331

#if defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_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))
332
333
334
               do j = ncols, 2, -2
                 w(:,1) = bcast_buffer(1:nbw,j+off)
                 w(:,2) = bcast_buffer(1:nbw,j+off-1)
335
#ifdef WITH_OPENMP
336

337
               call double_hh_trafo_real_avx_avx2_2hv_double(c_loc(a(1,j+off+a_off-1,istripe,my_thread)), &
338
339
                                                       w, nbw, nl, stripe_width, nbw)
#else
340
               call double_hh_trafo_real_avx_avx2_2hv_double(c_loc(a(1,j+off+a_off-1,istripe)), &
341
342
343
                                                       w, nbw, nl, stripe_width, nbw)
#endif
               enddo
344
345
#endif /* defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) ... */

346
347
348
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
349
#endif /* WITH_REAL_AVX_BLOCK2_KERNEL || WITH_REAL_AVX2_BLOCK2_KERNEL */
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392

#if defined(WITH_REAL_BGP_KERNEL)
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_BGP) then
#endif /* WITH_NO_SPECIFIC_REAL_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_bgp_double(a(1,j+off+a_off-1,istripe,my_thread), w, nbw, nl, &
                                          stripe_width, nbw)
#else
                 call double_hh_trafo_bgp_double(a(1,j+off+a_off-1,istripe), w, nbw, nl, &
                                          stripe_width, nbw)
#endif
               enddo
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_BGP_KERNEL */

#if defined(WITH_REAL_BGQ_KERNEL)
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_BGQ) then
#endif /* WITH_NO_SPECIFIC_REAL_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_bgq_double(a(1,j+off+a_off-1,istripe,my_thread), w, nbw, nl, &
                                          stripe_width, nbw)
#else
                 call double_hh_trafo_bgq_double(a(1,j+off+a_off-1,istripe), w, nbw, nl, &
                                          stripe_width, nbw)
#endif
               enddo
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_BGQ_KERNEL */


!#if defined(WITH_AVX_SANDYBRIDGE)
393
!              call double_hh_trafo_real_avx_avx2_2hv(a(1,j+off+a_off-1,istripe), w, nbw, nl, stripe_width, nbw)
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
!#endif

#ifdef WITH_OPENMP
             if (j==1) call single_hh_trafo_real_cpu_openmp_double(a(1:stripe_width, &
                                      1+off+a_off:1+off+a_off+nbw-1,istripe,my_thread), &
                                      bcast_buffer(1:nbw,off+1), nbw, nl,     &
                                      stripe_width)
#else
             if (j==1) call single_hh_trafo_real_cpu_double(a(1:stripe_width,1+off+a_off:1+off+a_off+nbw-1,istripe),           &
                                      bcast_buffer(1:nbw,off+1), nbw, nl,     &
                                      stripe_width)
#endif


#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
           endif !
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */

412
413
414
415
#if defined(WITH_REAL_SSE_BLOCK4_KERNEL)
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
           if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_SSE_BLOCK4) then
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
416
417

#if defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_SSE_BLOCK6_KERNEL))
418
419
420
421
422
423
424
             ! X86 INTRINSIC CODE, USING 4 HOUSEHOLDER VECTORS
             do j = ncols, 4, -4
               w(:,1) = bcast_buffer(1:nbw,j+off)
               w(:,2) = bcast_buffer(1:nbw,j+off-1)
               w(:,3) = bcast_buffer(1:nbw,j+off-2)
               w(:,4) = bcast_buffer(1:nbw,j+off-3)
#ifdef WITH_OPENMP
425
               call quad_hh_trafo_real_sse_4hv_double(c_loc(a(1,j+off+a_off-3,istripe,my_thread)), w, &
426
427
                                                  nbw, nl, stripe_width, nbw)
#else
428
               call quad_hh_trafo_real_sse_4hv_double(c_loc(a(1,j+off+a_off-3,istripe)), w, &
429
430
431
432
433
434
435
                                                  nbw, nl, stripe_width, nbw)
#endif
             enddo
             do jj = j, 2, -2
               w(:,1) = bcast_buffer(1:nbw,jj+off)
               w(:,2) = bcast_buffer(1:nbw,jj+off-1)
#ifdef WITH_OPENMP
436
               call double_hh_trafo_real_sse_2hv_double(c_loc(a(1,jj+off+a_off-1,istripe,my_thread)), &
437
438
                                                    w, nbw, nl, stripe_width, nbw)
#else
439
               call double_hh_trafo_real_sse_2hv_double(c_loc(a(1,jj+off+a_off-1,istripe)), &
440
441
442
443
                                                    w, nbw, nl, stripe_width, nbw)
#endif
             enddo
#ifdef WITH_OPENMP
444
445
             if (jj==1) call single_hh_trafo_real_cpu_openmp_double(a(1:stripe_width,1+off+a_off:1+off+a_off+nbw-1, &
                                                                     istripe,my_thread), &
446
447
448
449
450
                                          bcast_buffer(1:nbw,off+1), nbw, nl, stripe_width)
#else
             if (jj==1) call single_hh_trafo_real_cpu_double(a(1:stripe_width,1+off+a_off:1+off+a_off+nbw-1,istripe), &
                                          bcast_buffer(1:nbw,off+1), nbw, nl, stripe_width)
#endif
451
452
453

#endif /* defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_SSE_BLOCK6_KERNEL)) */

454
455
456
457
458
459
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
           endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_SSE_BLOCK4_KERNEL */


460
#if defined(WITH_REAL_AVX_BLOCK4_KERNEL) || defined(WITH_REAL_AVX2_BLOCK4_KERNEL)
461
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
462
463
           if ((THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX_BLOCK4) .or. &
               (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX2_BLOCK4) ) then
464
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
465
466

#if defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_AVX_BLOCK6_KERNEL) && !defined(WITH_REAL_AVX2_BLOCK6_KERNEL))
467
468
469
470
471
472
473
             ! X86 INTRINSIC CODE, USING 4 HOUSEHOLDER VECTORS
             do j = ncols, 4, -4
               w(:,1) = bcast_buffer(1:nbw,j+off)
               w(:,2) = bcast_buffer(1:nbw,j+off-1)
               w(:,3) = bcast_buffer(1:nbw,j+off-2)
               w(:,4) = bcast_buffer(1:nbw,j+off-3)
#ifdef WITH_OPENMP
474
               call quad_hh_trafo_real_avx_avx2_4hv_double(c_loc(a(1,j+off+a_off-3,istripe,my_thread)), w, &
475
476
                                                  nbw, nl, stripe_width, nbw)
#else
477
               call quad_hh_trafo_real_avx_avx2_4hv_double(c_loc(a(1,j+off+a_off-3,istripe)), w, &
478
479
480
481
482
483
484
                                                  nbw, nl, stripe_width, nbw)
#endif
             enddo
             do jj = j, 2, -2
               w(:,1) = bcast_buffer(1:nbw,jj+off)
               w(:,2) = bcast_buffer(1:nbw,jj+off-1)
#ifdef WITH_OPENMP
485
               call double_hh_trafo_real_avx_avx2_2hv_double(c_loc(a(1,jj+off+a_off-1,istripe,my_thread)), &
486
487
                                                    w, nbw, nl, stripe_width, nbw)
#else
488
               call double_hh_trafo_real_avx_avx2_2hv_double(c_loc(a(1,jj+off+a_off-1,istripe)), &
489
490
491
492
                                                    w, nbw, nl, stripe_width, nbw)
#endif
             enddo
#ifdef WITH_OPENMP
493
494
             if (jj==1) call single_hh_trafo_real_cpu_openmp_double(a(1:stripe_width,1+off+a_off:1+off+a_off+nbw-1, &
                                                                      istripe,my_thread), &
495
496
497
498
499
                                          bcast_buffer(1:nbw,off+1), nbw, nl, stripe_width)
#else
             if (jj==1) call single_hh_trafo_real_cpu_double(a(1:stripe_width,1+off+a_off:1+off+a_off+nbw-1,istripe), &
                                          bcast_buffer(1:nbw,off+1), nbw, nl, stripe_width)
#endif
500
501
502

#endif /* defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_AVX_BLOCK6_KERNEL) && !defined(WITH_REAL_AVX2_BLOCK6_KERNEL)) */

503
504
505
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
           endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
506
#endif /* WITH_REAL_AVX_BLOCK4_KERNEL || WITH_REAL_AVX2_BLOCK4_KERNEL */
507

508
509
510
511
512
513
514
515
516
517
518
519
520
#if defined(WITH_REAL_SSE_BLOCK6_KERNEL)
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
           if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_SSE_BLOCK6) then
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
             ! X86 INTRINSIC CODE, USING 6 HOUSEHOLDER VECTORS
             do j = ncols, 6, -6
               w(:,1) = bcast_buffer(1:nbw,j+off)
               w(:,2) = bcast_buffer(1:nbw,j+off-1)
               w(:,3) = bcast_buffer(1:nbw,j+off-2)
               w(:,4) = bcast_buffer(1:nbw,j+off-3)
               w(:,5) = bcast_buffer(1:nbw,j+off-4)
               w(:,6) = bcast_buffer(1:nbw,j+off-5)
#ifdef WITH_OPENMP
521
               call hexa_hh_trafo_real_sse_6hv_double(c_loc(a(1,j+off+a_off-5,istripe,my_thread)), w, &
522
523
                                                  nbw, nl, stripe_width, nbw)
#else
524
               call hexa_hh_trafo_real_sse_6hv_double(c_loc(a(1,j+off+a_off-5,istripe)), w, &
525
526
527
528
529
530
531
532
533
                                                  nbw, nl, stripe_width, nbw)
#endif
             enddo
             do jj = j, 4, -4
               w(:,1) = bcast_buffer(1:nbw,jj+off)
               w(:,2) = bcast_buffer(1:nbw,jj+off-1)
               w(:,3) = bcast_buffer(1:nbw,jj+off-2)
               w(:,4) = bcast_buffer(1:nbw,jj+off-3)
#ifdef WITH_OPENMP
534
               call quad_hh_trafo_real_sse_4hv_double(c_loc(a(1,jj+off+a_off-3,istripe,my_thread)), w, &
535
536
                                                  nbw, nl, stripe_width, nbw)
#else
537
               call quad_hh_trafo_real_sse_4hv_double(c_loc(a(1,jj+off+a_off-3,istripe)), w, &
538
539
540
541
542
543
544
                                                  nbw, nl, stripe_width, nbw)
#endif
             enddo
             do jjj = jj, 2, -2
               w(:,1) = bcast_buffer(1:nbw,jjj+off)
               w(:,2) = bcast_buffer(1:nbw,jjj+off-1)
#ifdef WITH_OPENMP
545
               call double_hh_trafo_real_sse_2hv_double(c_loc(a(1,jjj+off+a_off-1,istripe,my_thread)), &
546
547
                                                    w, nbw, nl, stripe_width, nbw)
#else
548
               call double_hh_trafo_real_sse_2hv_double(c_loc(a(1,jjj+off+a_off-1,istripe)), &
549
550
551
552
                                                    w, nbw, nl, stripe_width, nbw)
#endif
             enddo
#ifdef WITH_OPENMP
553
554
             if (jjj==1) call single_hh_trafo_real_cpu_openmp_double(a(1:stripe_width,1+off+a_off:1+off+a_off+nbw-1, &
                                                                        istripe,my_thread), &
555
556
557
558
559
560
561
562
563
564
                                           bcast_buffer(1:nbw,off+1), nbw, nl, stripe_width)
#else
             if (jjj==1) call single_hh_trafo_real_cpu_double(a(1:stripe_width,1+off+a_off:1+off+a_off+nbw-1,istripe), &
                                           bcast_buffer(1:nbw,off+1), nbw, nl, stripe_width)
#endif
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
           endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_SSE_BLOCK4_KERNEL */

565

566
#if defined(WITH_REAL_AVX_BLOCK6_KERNEL) || defined(WITH_REAL_AVX2_BLOCK6_KERNEL)
567
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
568
569
           if ((THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX_BLOCK6) .or. &
               (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX2_BLOCK6)) then
570
571
572
573
574
575
576
577
578
579
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
             ! X86 INTRINSIC CODE, USING 6 HOUSEHOLDER VECTORS
             do j = ncols, 6, -6
               w(:,1) = bcast_buffer(1:nbw,j+off)
               w(:,2) = bcast_buffer(1:nbw,j+off-1)
               w(:,3) = bcast_buffer(1:nbw,j+off-2)
               w(:,4) = bcast_buffer(1:nbw,j+off-3)
               w(:,5) = bcast_buffer(1:nbw,j+off-4)
               w(:,6) = bcast_buffer(1:nbw,j+off-5)
#ifdef WITH_OPENMP
580
               call hexa_hh_trafo_real_avx_avx2_6hv_double(c_loc(a(1,j+off+a_off-5,istripe,my_thread)), w, &
581
582
                                                  nbw, nl, stripe_width, nbw)
#else
583
               call hexa_hh_trafo_real_avx_avx2_6hv_double(c_loc(a(1,j+off+a_off-5,istripe)), w, &
584
585
586
587
588
589
590
591
592
                                                  nbw, nl, stripe_width, nbw)
#endif
             enddo
             do jj = j, 4, -4
               w(:,1) = bcast_buffer(1:nbw,jj+off)
               w(:,2) = bcast_buffer(1:nbw,jj+off-1)
               w(:,3) = bcast_buffer(1:nbw,jj+off-2)
               w(:,4) = bcast_buffer(1:nbw,jj+off-3)
#ifdef WITH_OPENMP
593
               call quad_hh_trafo_real_avx_avx2_4hv_double(c_loc(a(1,jj+off+a_off-3,istripe,my_thread)), w, &
594
595
                                                  nbw, nl, stripe_width, nbw)
#else
596
               call quad_hh_trafo_real_avx_avx2_4hv_double(c_loc(a(1,jj+off+a_off-3,istripe)), w, &
597
598
599
600
601
602
603
                                                  nbw, nl, stripe_width, nbw)
#endif
             enddo
             do jjj = jj, 2, -2
               w(:,1) = bcast_buffer(1:nbw,jjj+off)
               w(:,2) = bcast_buffer(1:nbw,jjj+off-1)
#ifdef WITH_OPENMP
604
               call double_hh_trafo_real_avx_avx2_2hv_double(c_loc(a(1,jjj+off+a_off-1,istripe,my_thread)), &
605
606
                                                    w, nbw, nl, stripe_width, nbw)
#else
607
               call double_hh_trafo_real_avx_avx2_2hv_double(c_loc(a(1,jjj+off+a_off-1,istripe)), &
608
609
610
611
                                                    w, nbw, nl, stripe_width, nbw)
#endif
             enddo
#ifdef WITH_OPENMP
612
613
             if (jjj==1) call single_hh_trafo_real_cpu_openmp_double(a(1:stripe_width,1+off+a_off:1+off+a_off+nbw-1, &
                                                                       istripe,my_thread), &
614
615
616
617
618
619
620
621
                                           bcast_buffer(1:nbw,off+1), nbw, nl, stripe_width)
#else
             if (jjj==1) call single_hh_trafo_real_cpu_double(a(1:stripe_width,1+off+a_off:1+off+a_off+nbw-1,istripe), &
                                           bcast_buffer(1:nbw,off+1), nbw, nl, stripe_width)
#endif
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
           endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
622
#endif /* WITH_REAL_AVX_BLOCK6_KERNEL || WITH_REAL_AVX2_BLOCK6_KERNEL */
623
624
625
626
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
662
663
664
665
666
667
668
669
670

         endif ! GPU_KERNEL

#ifdef WITH_OPENMP
         if (my_thread==1) then
#endif
           kernel_flops = kernel_flops + 4*int(nl,8)*int(ncols,8)*int(nbw,8)
           kernel_time = kernel_time + mpi_wtime()-ttt
#ifdef WITH_OPENMP
         endif
#endif
#ifdef HAVE_DETAILED_TIMINGS
#ifdef WITH_OPENMP
         call timer%stop("compute_hh_trafo_real_cpu_openmp_double")
#else
         call timer%stop("compute_hh_trafo_real_cpu_double")
#endif
#endif

#ifdef WITH_OPENMP
       end subroutine compute_hh_trafo_real_cpu_openmp_double
#else
       end subroutine compute_hh_trafo_real_cpu_double
#endif

#ifdef WANT_SINGLE_PRECISION_REAL
! SINGLE PRECISION IMPLEMENTATION AT THE MOMENT DUPLICATED !!!

#ifdef WITH_OPENMP
       subroutine compute_hh_trafo_real_cpu_openmp_single(a, a_dev, stripe_width, a_dim2, stripe_count, max_threads, l_nev, &
                                                   a_off, nbw, max_blk_size, bcast_buffer, bcast_buffer_dev, hh_dot_dev,    &
                                                   hh_tau_dev, kernel_flops, kernel_time, off, ncols, istripe,              &
                                                   my_thread, thread_width, THIS_REAL_ELPA_KERNEL)
#else
       subroutine compute_hh_trafo_real_cpu_single       (a, a_dev, stripe_width, a_dim2, stripe_count,                      &
                                                   a_off, nbw, max_blk_size, bcast_buffer,  bcast_buffer_dev, hh_dot_dev,     &
                                                   hh_tau_dev, kernel_flops, kernel_time, off, ncols, istripe,                &
                                                   last_stripe_width, THIS_REAL_ELPA_KERNEL)
#endif


         use precision
         use iso_c_binding
         use elpa2_utilities
         use single_hh_trafo_real
         use cuda_c_kernel
         use cuda_functions

671
#if defined(WITH_REAL_GENERIC_SIMPLE_KERNEL) && !(defined(USE_ASSUMED_SIZE))
672
673
674
         use real_generic_simple_kernel !, only : double_hh_trafo_generic_simple
#endif

675
#if defined(WITH_REAL_GENERIC_KERNEL) && !(defined(USE_ASSUMED_SIZE))
676
677
678
679
680
681
682
683
684
685
686
687
688
        use real_generic_kernel !, only : double_hh_trafo_generic
#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
#ifdef HAVE_DETAILED_TIMINGS
         use timings
#endif
689

690
#if defined(HAVE_AVX) || defined(HAVE_AVX2) || defined(HAVE_SSE_INTRINSICS) || defined(HAVE_SSE_ASSEMBLY)
691
692
         use kernel_interfaces
#endif
693
694
695
696
697
698
699
700
701
702
703
704
         implicit none
         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
         real(kind=rk4)                :: bcast_buffer(nbw,max_blk_size)
         integer(kind=ik), intent(in) :: a_off

         integer(kind=ik), intent(in) :: stripe_width,a_dim2,stripe_count

#ifndef WITH_OPENMP
         integer(kind=ik), intent(in) :: last_stripe_width
!         real(kind=rk4)                :: a(stripe_width,a_dim2,stripe_count)
705
         real(kind=rk4), pointer      :: a(:,:,:)
706
707
708
#else
         integer(kind=ik), intent(in) :: max_threads, l_nev, thread_width
!         real(kind=rk8)                :: a(stripe_width,a_dim2,stripe_count,max_threads)
709
         real(kind=rk4), pointer      :: a(:,:,:,:)
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
#endif
         integer(kind=ik), intent(in) :: THIS_REAL_ELPA_KERNEL

         integer(kind=c_intptr_t)     :: a_dev
         integer(kind=c_intptr_t)     :: bcast_buffer_dev
         integer(kind=c_size_t)       :: dev_offset
         integer(kind=c_intptr_t)     :: hh_dot_dev
         integer(kind=c_intptr_t)     :: hh_tau_dev
         ! Private variables in OMP regions (my_thread) should better be in the argument list!
         integer(kind=ik)             :: off, ncols, istripe
#ifdef WITH_OPENMP
         integer(kind=ik)             :: my_thread, noff
#endif
         integer(kind=ik)             :: j, nl, jj, jjj
         real(kind=rk4)                :: w(nbw,6)
         real(kind=c_double)          :: ttt ! MPI_WTIME always needs double

         if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GPU) then
           ! ncols - indicates the number of HH reflectors to apply; at least 1 must be available
           if (ncols < 1) return
         endif

#ifdef HAVE_DETAILED_TIMINGS
#ifdef WITH_OPENMP
         call timer%start("compute_hh_trafo_real_cpu_openmp_single")
#else
         call timer%start("compute_hh_trafo_real_cpu_single")
#endif
#endif
         ttt = mpi_wtime()

#ifndef WITH_OPENMP
         nl = merge(stripe_width, last_stripe_width, istripe<stripe_count)
#else
         if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GPU) then
           print *,"compute_hh_trafo_real GPU OPENMP: not yet implemented"
           stop
         endif

         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
#ifdef HAVE_DETAILED_TIMINGS
#ifdef WITH_OPENMP
             call timer%stop("compute_hh_trafo_real_cpu_openmp_single")
#else
             call timer%stop("compute_hh_trafo_real_cpu_single")
#endif
#endif
             return
           endif
         endif
#endif /* not WITH_OPENMP */

         if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GPU) then
           dev_offset = (0 + (a_off * stripe_width) + ( (istripe - 1) * stripe_width *a_dim2 )) *size_of_single_real_datatype
           call launch_compute_hh_trafo_c_kernel_real_single(a_dev + dev_offset, bcast_buffer_dev, hh_dot_dev, &
                                                      hh_tau_dev, nl, nbw, stripe_width, off, ncols)
         else ! not CUDA kernel

#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
           if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX_BLOCK2 .or. &
775
               THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_SSE_BLOCK2 .or. &
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
               THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GENERIC    .or. &
               THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GENERIC_SIMPLE .or. &
               THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_SSE .or.        &
               THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_BGP .or.        &
               THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_BGQ) then
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */

             !FORTRAN CODE / X86 INRINISIC CODE / BG ASSEMBLER USING 2 HOUSEHOLDER VECTORS
#if defined(WITH_REAL_GENERIC_KERNEL)
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GENERIC) then
#endif /* WITH_NO_SPECIFIC_REAL_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
794
#ifdef USE_ASSUMED_SIZE
795
796
797
798
799
800
801
802
803
804
805
                 call double_hh_trafo_generic_single(a(1,j+off+a_off-1,istripe,my_thread), w, &
                                            nbw, nl, stripe_width, nbw)

#else
                 call double_hh_trafo_generic_single(a(1:stripe_width,j+off+a_off-1:j+off+a_off+nbw-1, &
                                              istripe,my_thread), w(1:nbw,1:6), &
                                              nbw, nl, stripe_width, nbw)
#endif

#else /* WITH_OPENMP */

806
#ifdef USE_ASSUMED_SIZE
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
                 call double_hh_trafo_generic_single(a(1,j+off+a_off-1,istripe),w, &
                                            nbw, nl, stripe_width, nbw)

#else
                 call double_hh_trafo_generic_single(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)
#endif
#endif /* WITH_OPENMP */

               enddo

#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_GENERIC_KERNEL */


#if defined(WITH_REAL_GENERIC_SIMPLE_KERNEL)
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_GENERIC_SIMPLE) then
#endif /* WITH_NO_SPECIFIC_REAL_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
832
#ifdef USE_ASSUMED_SIZE
833
834
835
836
837
838
839
840
841
                 call double_hh_trafo_generic_simple_single(a(1,j+off+a_off-1,istripe,my_thread), &
                                                       w, nbw, nl, stripe_width, nbw)
#else
                 call double_hh_trafo_generic_simple_single(a(1:stripe_width,j+off+a_off-1:j+off+a_off-1+nbw,istripe,my_thread), &
                                                     w, nbw, nl, stripe_width, nbw)

#endif

#else /* WITH_OPENMP */
842
#ifdef USE_ASSUMED_SIZE
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
                 call double_hh_trafo_generic_simple_single(a(1,j+off+a_off-1,istripe), &
                                                       w, nbw, nl, stripe_width, nbw)
#else
                 call double_hh_trafo_generic_simple_single(a(1:stripe_width,j+off+a_off-1:j+off+a_off-1+nbw,istripe), &
                                                     w, nbw, nl, stripe_width, nbw)

#endif

#endif /* WITH_OPENMP */

               enddo
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_GENERIC_SIMPLE_KERNEL */


860
#if defined(WITH_REAL_SSE_ASSEMBLY_KERNEL)
861
862
863
864
865
866
867
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_SSE) then
#endif /* WITH_NO_SPECIFIC_REAL_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
868
                 call double_hh_trafo_single(c_loc(a(1,j+off+a_off-1,istripe,my_thread)), w, nbw, nl, &
869
                                      stripe_width, nbw)
870
#else
871
                 call double_hh_trafo_single(c_loc(a(1,j+off+a_off-1,istripe)), w, nbw, nl, &
872
                                      stripe_width, nbw)
873
874
875
876
877
#endif
               enddo
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
878
#endif /* WITH_REAL_SSE_ASSEMBLY_KERNEL */
879

880
881
882
883
#if defined(WITH_REAL_SSE_BLOCK2_KERNEL)
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_SSE_BLOCK2) then
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
884
885

#if defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_SSE_BLOCK6_KERNEL) && !defined(WITH_REAL_SSE_BLOCK4_KERNEL)) 
886
887
888
889
               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
890
                 call double_hh_trafo_real_sse_2hv_single(c_loc(a(1,j+off+a_off-1,istripe,my_thread)), &
891
892
                                                       w, nbw, nl, stripe_width, nbw)
#else
893
                 call double_hh_trafo_real_sse_2hv_single(c_loc(a(1,j+off+a_off-1,istripe)), &
894
895
896
                                                       w, nbw, nl, stripe_width, nbw)
#endif
               enddo
897
898
#endif /* defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_SSE_BLOCK6_KERNEL) && !defined(WITH_REAL_SSE_BLOCK4_KERNEL)) */

899
900
901
902
903
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
             endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_SSE_BLOCK2_KERNEL */

Andreas Marek's avatar
Typo    
Andreas Marek committed
904
#if defined(WITH_REAL_AVX_BLOCK2_KERNEL) || defined(WITH_REAL_AVX2_BLOCK2_KERNEL)
905
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
Andreas Marek's avatar
Andreas Marek committed
906
907
             if ((THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX_BLOCK2) .or.  &
                 (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX2_BLOCK2))then
908
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
909
910

#if defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_AVX_BLOCK6_KERNEL) && !defined(WITH_REAL_AVX2_BLOCK6_KERNEL) && !defined(WITH_REAL_AVX_BLOCK4_KERNEL) && !defined(WITH_REAL_AVX2_BLOCK4_KERNEL) )
911
912
913
914
               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
915
                 call double_hh_trafo_real_avx_avx2_2hv_single(c_loc(a(1,j+off+a_off-1,istripe,my_thread)), &
916
917
                                                       w, nbw, nl, stripe_width, nbw)
#else
918
                 call double_hh_trafo_real_avx_avx2_2hv_single(c_loc(a(1,j+off+a_off-1,istripe)), &
919
920
                                                       w, nbw, nl, stripe_width, nbw)
#endif
921
               enddo
922
923
924

#endif /* defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_AVX_BLOCK6_KERNEL) && !defined(WITH_REAL_AVX2_BLOCK6_KERNEL) && !defined(WITH_REAL_AVX_BLOCK4_KERNEL) && !defined(WITH_REAL_AVX2_BLOCK4_KERNEL) ) */

925
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
926
             endif
927
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
Andreas Marek's avatar
Andreas Marek committed
928
#endif /* WITH_REAL_AVX_BLOCK2_KERNEL || WITH_REAL_AVX2_BLOCK2_KERNEL */
929
930
931

#if defined(WITH_REAL_BGP_KERNEL)
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
932
             if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_BGP) then
933
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
934
935
936
               do j = ncols, 2, -2
                 w(:,1) = bcast_buffer(1:nbw,j+off)
                 w(:,2) = bcast_buffer(1:nbw,j+off-1)
937
#ifdef WITH_OPENMP
938
                 call double_hh_trafo_bgp_single(a(1,j+off+a_off-1,istripe,my_thread), w, nbw, nl, &
939
940
                                          stripe_width, nbw)
#else
941
                 call double_hh_trafo_bgp_single(a(1,j+off+a_off-1,istripe), w, nbw, nl, &
942
943
                                          stripe_width, nbw)
#endif
944
               enddo
945
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
946
             endif
947
948
949
950
951
952
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_BGP_KERNEL */


#if defined(WITH_REAL_BGQ_KERNEL)
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
953
             if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_BGQ) then
954
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
955
956
957
               do j = ncols, 2, -2
                 w(:,1) = bcast_buffer(1:nbw,j+off)
                 w(:,2) = bcast_buffer(1:nbw,j+off-1)
958
#ifdef WITH_OPENMP
959
                 call double_hh_trafo_bgq_single(a(1,j+off+a_off-1,istripe,my_thread), w, nbw, nl, &
960
961
                                          stripe_width, nbw)
#else
962
                 call double_hh_trafo_bgq_single(a(1,j+off+a_off-1,istripe), w, nbw, nl, &
963
964
                                          stripe_width, nbw)
#endif
965
               enddo
966
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
967
             endif
968
969
970
971
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_BGQ_KERNEL */

#ifdef WITH_OPENMP
972
973
             if (j==1) call single_hh_trafo_real_cpu_openmp_single(a(1:stripe_width, &
                                   1+off+a_off:1+off+a_off+nbw-1,istripe,my_thread), &
974
975
976
                                      bcast_buffer(1:nbw,off+1), nbw, nl,     &
                                      stripe_width)
#else
977
978
             if (j==1) call single_hh_trafo_real_cpu_single(a(1:stripe_width, &
                                    1+off+a_off:1+off+a_off+nbw-1,istripe),           &
979
980
981
982
983
984
                                      bcast_buffer(1:nbw,off+1), nbw, nl,     &
                                      stripe_width)
#endif


#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
985
           endif !
986
987
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */

988
#if defined(WITH_REAL_SSE_BLOCK4_KERNEL)
989
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
990
991
         if (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_SSE_BLOCK4) then
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
992
993
994

#if defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_SSE_BLOCK6_KERNEL) )

995
996
997
998
999
1000
1001
           ! X86 INTRINSIC CODE, USING 4 HOUSEHOLDER VECTORS
           do j = ncols, 4, -4
             w(:,1) = bcast_buffer(1:nbw,j+off)
             w(:,2) = bcast_buffer(1:nbw,j+off-1)
             w(:,3) = bcast_buffer(1:nbw,j+off-2)
             w(:,4) = bcast_buffer(1:nbw,j+off-3)
#ifdef WITH_OPENMP
1002
             call quad_hh_trafo_real_sse_4hv_single(c_loc(a(1,j+off+a_off-3,istripe,my_thread)), w, &
1003
1004
                                                  nbw, nl, stripe_width, nbw)
#else
1005
             call quad_hh_trafo_real_sse_4hv_single(c_loc(a(1,j+off+a_off-3,istripe)), w, &
1006
1007
1008
1009
1010
1011
1012
                                                  nbw, nl, stripe_width, nbw)
#endif
           enddo
           do jj = j, 2, -2
             w(:,1) = bcast_buffer(1:nbw,jj+off)
             w(:,2) = bcast_buffer(1:nbw,jj+off-1)
#ifdef WITH_OPENMP
1013
             call double_hh_trafo_real_sse_2hv_single(c_loc(a(1,jj+off+a_off-1,istripe,my_thread)), &
1014
1015
                                                    w, nbw, nl, stripe_width, nbw)
#else
1016
             call double_hh_trafo_real_sse_2hv_single(c_loc(a(1,jj+off+a_off-1,istripe)), &
1017
1018
1019
1020
                                                    w, nbw, nl, stripe_width, nbw)
#endif
           enddo
#ifdef WITH_OPENMP
1021
1022
           if (jj==1) call single_hh_trafo_real_cpu_openmp_single(a(1:stripe_width,1+off+a_off:1+off+a_off+nbw-1, &
                                                                    istripe,my_thread), &
1023
1024
                                          bcast_buffer(1:nbw,off+1), nbw, nl, stripe_width)
#else
1025
           if (jj==1) call single_hh_trafo_real_cpu_single(a(1:stripe_width,1+off+a_off:1+off+a_off+nbw-1,istripe), &
1026
1027
                                          bcast_buffer(1:nbw,off+1), nbw, nl, stripe_width)
#endif
1028
1029
1030

#endif /* defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_SSE_BLOCK6_KERNEL) ) */

1031
1032
1033
1034
1035
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
         endif
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
#endif /* WITH_REAL_SSE_BLOCK4_KERNEL */

1036
#if defined(WITH_REAL_AVX_BLOCK4_KERNEL) || defined(WITH_REAL_AVX2_BLOCK4_KERNEL)
1037
#if defined(WITH_NO_SPECIFIC_REAL_KERNEL)
1038
1039
         if ((THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX_BLOCK4) .or. &
             (THIS_REAL_ELPA_KERNEL .eq. REAL_ELPA_KERNEL_AVX2_BLOCK4)) then
1040
#endif /* WITH_NO_SPECIFIC_REAL_KERNEL */
1041
1042
1043

#if defined(WITH_NO_SPECIFIC_REAL_KERNEL) || (defined(WITH_ONE_SPECIFIC_REAL_KERNEL) && !defined(WITH_REAL_AVX_BLOCK6_KERNEL) && !defined(WITH_REAL_AVX2_BLOCK6_KERNEL))

1044
1045
1046
1047
1048
1049
             ! X86 INTRINSIC CODE, USING 4 HOUSEHOLDER VECTORS
             do j = ncols, 4, -4
               w(:,1) = bcast_buffer(1:nbw,j+off)
               w(:,2) = bcast_buffer(1:nbw,j+off-1)
               w(:,3) = bcast_buffer(1:nbw,j+off-2)
               w(:,4) = bcast_buffer(1:nbw,j+off-3)
1050
#ifdef WITH_OPENMP
1051

1052
             call quad_hh_trafo_real_avx_avx2_4hv_single(c_loc(a(1,j+off+a_off-3,istripe,