elpa1_template.X90 5.69 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
55
#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

#include "../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
111
112
113
114
115
116
   call timer%start("elpa_solve_evp_&
   &MATH_DATATYPE&
   &_1stage_&
   &PRECISION&
   &")

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

   success = .true.
117
118
119
120
   if (elpa_init(20170403) /= ELPA_OK) then
     success = .false.
     error stop "ELPA API version not supported"
   endif
Andreas Marek's avatar
Andreas Marek committed
121

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.
     stop
     return
Andreas Marek's avatar
Andreas Marek committed
129
130
   endif

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

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

159
160
161
162
163
164
   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"
     stop
     success = .false.
     return
Andreas Marek's avatar
Andreas Marek committed
165
166
   endif

167
   call elpa1stage%destroy()
Andreas Marek's avatar
Andreas Marek committed
168

169
   call elpa_uninit()
Andreas Marek's avatar
Andreas Marek committed
170
171
172
173
174
175
176
177
178
179

   call timer%stop("elpa_solve_evp_&
   &MATH_DATATYPE&
   &_1stage_&
   &PRECISION&
   &")

end function