elpa1_template.X90 6.38 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

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
   use iso_c_binding
   use elpa_mpi
66
   use elpa
Andreas Marek's avatar
Andreas Marek committed
67
68
69
70
   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
71
   real(kind=REAL_DATATYPE), intent(out)           :: ev(na)
72

73
   integer(kind=c_int)                             :: my_prow, my_pcol, mpierr
74

Andreas Marek's avatar
Andreas Marek committed
75
#if REALCASE == 1
76
77
78
79
#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
80
81
   real(kind=C_DATATYPE_KIND), intent(inout)       :: a(lda,matrixCols)
   real(kind=C_DATATYPE_KIND), intent(out)         :: q(ldq,matrixCols)
82
#endif
Andreas Marek's avatar
Andreas Marek committed
83
84
85
#endif /* REALCASE */

#if COMPLEXCASE == 1
86
87
88
89
#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
90
91
   complex(kind=C_DATATYPE_KIND), intent(inout)    :: a(lda,matrixCols)
   complex(kind=C_DATATYPE_KIND), intent(out)      :: q(ldq,matrixCols)
92
#endif
Andreas Marek's avatar
Andreas Marek committed
93
94
95
96
97
98

#endif /* COMPLEXCASE */

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

99
   integer(kind=c_int)                             :: successInternal
Andreas Marek's avatar
Andreas Marek committed
100

101
   class(elpa_t), pointer                          :: e
102

Andreas Marek's avatar
Andreas Marek committed
103
104
105
106
   call mpi_comm_rank(mpi_comm_rows,my_prow,mpierr)
   call mpi_comm_rank(mpi_comm_cols,my_pcol,mpierr)

   success = .true.
107
   if (elpa_init(CURRENT_API_VERSION) /= ELPA_OK) then
Pavel Kus's avatar
fix    
Pavel Kus committed
108
     print *,  "ELPA API version not supported"
109
     success = .false.
Pavel Kus's avatar
fix    
Pavel Kus committed
110
     return
111
   endif
Andreas Marek's avatar
Andreas Marek committed
112

113
   e => elpa_allocate()
114
115

   call e%set("na", na)
116
   call e%set("nev", nev)
117
118
119
120
121
122
123
124
   call e%set("local_nrows", lda)
   call e%set("local_ncols", matrixCols)
   call e%set("nblk", nblk)

   call e%set("mpi_comm_parent", mpi_comm_all)
   call e%set("process_row", my_prow)
   call e%set("process_col", my_pcol)

125
   if (e%setup() .ne. ELPA_OK) then
126
     print *, "Cannot setup ELPA instance"
127
128
     success = .false.
     return
Andreas Marek's avatar
Andreas Marek committed
129
130
   endif

131
   call e%set("solver", ELPA_SOLVER_1STAGE, successInternal)
132
133
134
135
136
   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
       call e%set("gpu", 1, successInternal)
141
142
143
144
145
146
       if (successInternal .ne. ELPA_OK) then
         print *, "Cannot set gpu"
         success = .false.
         return
       endif
     else
147
       call e%set("gpu", 0, successInternal)
148
149
       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
   call e%set("print_flops", 1,successInternal)
157
   if (successInternal .ne. ELPA_OK) then
158
     print *, "Cannot set print_flops"
159
160
     success = .false.
     return
161
162
   endif

163
164
   call e%set("timings", 1)

165
   call e%eigenvectors(a(1:lda,1:matrixCols), ev, q(1:ldq,1:matrixCols), successInternal)
166

167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
   time_evp_fwd = e%get_time("elpa_solve_evp_&
   &MATH_DATATYPE&
   &_1stage_&
   &PRECISION&
   &","forward")

   if(my_prow==0 .and. my_pcol==0 .and. elpa_print_times) write(error_unit,*) 'Time tridiag_real :',time_evp_fwd

   time_evp_solve = e%get_time("elpa_solve_evp_&
   &MATH_DATATYPE&
   &_1stage_&
   &PRECISION&
   &","solve")

   if(my_prow==0 .and. my_pcol==0 .and. elpa_print_times) write(error_unit,*) 'Time solve_tridi  :',time_evp_solve

   time_evp_back = e%get_time("elpa_solve_evp_&
   &MATH_DATATYPE&
   &_1stage_&
   &PRECISION&
   &","back")

   if(my_prow==0 .and. my_pcol==0 .and. elpa_print_times) write(error_unit,*) 'Time trans_ev_real:',time_evp_back

191
192
193
194
   if (successInternal .ne. ELPA_OK) then
     print *, "Cannot solve with ELPA 1stage"
     success = .false.
     return
Andreas Marek's avatar
Andreas Marek committed
195
196
   endif

197
   call elpa_deallocate(e)
Andreas Marek's avatar
Andreas Marek committed
198

199
   call elpa_uninit()
Andreas Marek's avatar
Andreas Marek committed
200
201
202

end function

203
! vim: syntax=fortran