elpa1_template_legacy.X90 6.09 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
49
50
51
52
53
54
#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
!
!    This particular source code file contains additions, changes and
!    enhancements authored by Intel Corporation which is not part of
!    the ELPA consortium.
!
!    More information can be found here:
!    http://elpa.mpcdf.mpg.de/
!
!    ELPA is free software: you can redistribute it and/or modify
!    it under the terms of the version 3 of the license of the
!    GNU Lesser General Public License as published by the Free
!    Software Foundation.
!
!    ELPA is distributed in the hope that it will be useful,
!    but WITHOUT ANY WARRANTY; without even the implied warranty of
!    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!    GNU Lesser General Public License for more details.
!
!    You should have received a copy of the GNU Lesser General Public License
!    along with ELPA.  If not, see <http://www.gnu.org/licenses/>
!
!    ELPA reflects a substantial effort on the part of the original
!    ELPA consortium, and we ask you to respect the spirit of the
!    license that we chose: i.e., please contribute any changes you
!    may have back to the original ELPA library distribution, and keep
!    any derivatives of ELPA under the same license that we chose for
!    the original distribution, the GNU Lesser General Public License.
!
!
! ELPA1 -- Faster replacements for ScaLAPACK symmetric eigenvalue routines
!
! Copyright of the original code rests with the authors inside the ELPA
! consortium. The copyright of any additional modifications shall rest
! with their original authors, but shall adhere to the licensing terms
! distributed along with the original code in the file "COPYING".
#endif

55
#include "../../general/sanity.X90"
Andreas Marek's avatar
Andreas Marek committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

function elpa_solve_evp_&
         &MATH_DATATYPE&
	 &_1stage_&
	 &PRECISION&
	 & (na, nev, a, lda, ev, q, ldq, nblk, matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all, &
            useGPU) result(success)
   use precision
#ifdef HAVE_DETAILED_TIMINGS
   use timings
#else
   use timings_dummy
#endif
   use iso_c_binding
   use elpa_mpi
71
   use elpa_type
Andreas Marek's avatar
Andreas Marek committed
72
73
74
75
   implicit none

   integer(kind=c_int), intent(in)                 :: na, nev, lda, ldq, nblk, matrixCols, mpi_comm_rows, &
                                                      mpi_comm_cols, mpi_comm_all
Andreas Marek's avatar
Andreas Marek committed
76
   real(kind=REAL_DATATYPE), intent(out)           :: ev(na)
77
78
79

   integer(kind=c_int)                             :: my_pe, n_pes, my_prow, my_pcol, mpierr

Andreas Marek's avatar
Andreas Marek committed
80
#if REALCASE == 1
81
82
83
84
#ifdef USE_ASSUMED_SIZE
   real(kind=C_DATATYPE_KIND), intent(inout)       :: a(lda,*)
   real(kind=C_DATATYPE_KIND), intent(out)         :: q(ldq,*)
#else
Andreas Marek's avatar
Andreas Marek committed
85
86
   real(kind=C_DATATYPE_KIND), intent(inout)       :: a(lda,matrixCols)
   real(kind=C_DATATYPE_KIND), intent(out)         :: q(ldq,matrixCols)
87
#endif
Andreas Marek's avatar
Andreas Marek committed
88
89
90
#endif /* REALCASE */

#if COMPLEXCASE == 1
91
92
93
94
#ifdef USE_ASSUMED_SIZE
   complex(kind=C_DATATYPE_KIND), intent(inout)    :: a(lda,*)
   complex(kind=C_DATATYPE_KIND), intent(out)      :: q(ldq,*)
#else
Andreas Marek's avatar
Andreas Marek committed
95
96
   complex(kind=C_DATATYPE_KIND), intent(inout)    :: a(lda,matrixCols)
   complex(kind=C_DATATYPE_KIND), intent(out)      :: q(ldq,matrixCols)
97
#endif
Andreas Marek's avatar
Andreas Marek committed
98
99
100
101
102
103

#endif /* COMPLEXCASE */

   logical, intent(in), optional                   :: useGPU
   logical                                         :: success

104
   integer(kind=c_int)                             :: successInternal
Andreas Marek's avatar
Andreas Marek committed
105

106
   type(elpa_t)                                    :: elpa1stage
Andreas Marek's avatar
Andreas Marek committed
107
108
109
110
   call timer%start("elpa_solve_evp_&
   &MATH_DATATYPE&
   &_1stage_&
   &PRECISION&
111
   &_legacy_interface")
Andreas Marek's avatar
Andreas Marek committed
112
113
114
115
116

   call mpi_comm_rank(mpi_comm_rows,my_prow,mpierr)
   call mpi_comm_rank(mpi_comm_cols,my_pcol,mpierr)

   success = .true.
117
   if (elpa_init(20170403) /= ELPA_OK) then
Pavel Kus's avatar
fix    
Pavel Kus committed
118
     print *,  "ELPA API version not supported"
119
     success = .false.
Pavel Kus's avatar
fix    
Pavel Kus committed
120
     return
121
   endif
Andreas Marek's avatar
Andreas Marek committed
122

123
124
125
126
127
128
   elpa1stage = elpa_create(na, nev, lda, matrixCols, nblk, mpi_comm_all, &
                            my_prow, my_pcol, successInternal)
   if (successInternal .ne. ELPA_OK) then
     print *, "Cannot create elpa object"
     success = .false.
     return
Andreas Marek's avatar
Andreas Marek committed
129
130
   endif

131
132
133
134
135
136
   call elpa1stage%set("solver", ELPA_SOLVER_1STAGE, successInternal)
   if (successInternal .ne. ELPA_OK) then
     print *, "Cannot set ELPA 1stage solver"
     success = .false.
     return
   endif
Andreas Marek's avatar
Andreas Marek committed
137
138
139

   if (present(useGPU)) then
     if (useGPU) then
140
141
142
143
144
145
146
147
148
149
       call elpa1stage%set("gpu", 1, successInternal)
       if (successInternal .ne. ELPA_OK) then
         print *, "Cannot set gpu"
         success = .false.
         return
       endif
     else
       call elpa1stage%set("gpu", 0, successInternal)
       if (successInternal .ne. ELPA_OK) then
         print *, "Cannot set gpu"
Andreas Marek's avatar
Andreas Marek committed
150
151
152
153
154
155
         success = .false.
         return
       endif
     endif
   endif

156
157
158
159
160
161
162
163
164
   if (elpa_print_times) then
     call elpa1stage%set("summary_timings", 1,successInternal)
     if (successInternal .ne. ELPA_OK) then
       print *, "Cannot set summary_timings"
       success = .false.
       return
     endif
   endif

165
166
167
168
169
   call elpa1stage%solve(a(1:lda,1:matrixCols), ev, q(1:ldq,1:matrixCols), successInternal)
   if (successInternal .ne. ELPA_OK) then
     print *, "Cannot solve with ELPA 1stage"
     success = .false.
     return
Andreas Marek's avatar
Andreas Marek committed
170
171
   endif

172
173
174
175
176
   if (elpa_print_times) then
     time_evp_fwd = elpa1stage%time_evp_fwd
     time_evp_solve = elpa1stage%time_evp_solve
     time_evp_back = elpa1stage%time_evp_back
   endif
177
   call elpa1stage%destroy()
Andreas Marek's avatar
Andreas Marek committed
178

179
   call elpa_uninit()
Andreas Marek's avatar
Andreas Marek committed
180
181
182
183
184

   call timer%stop("elpa_solve_evp_&
   &MATH_DATATYPE&
   &_1stage_&
   &PRECISION&
185
   &_legacy_interface")
Andreas Marek's avatar
Andreas Marek committed
186
187
188
189

end function