41 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
42 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
44 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_diag_cusolver'
46 INTEGER :: handle, n, nmo
47 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues_buffer
50 SUBROUTINE cp_fm_diag_cusolver_c(cusolver_context, fortran_comm, matrix_desc, &
51 nprow, npcol, myprow, mypcol, &
52 n, matrix, eigenvectors, eigenvalues) &
53 BIND(C, name="cp_fm_diag_cusolver")
54 IMPORT :: c_int, c_double, c_ptr
55 TYPE(c_ptr),
INTENT(INOUT) :: cusolver_context
56 INTEGER(KIND=C_INT),
VALUE :: fortran_comm
57 INTEGER(KIND=C_INT),
DIMENSION(*) :: matrix_desc
58 INTEGER(KIND=C_INT),
VALUE :: nprow
59 INTEGER(KIND=C_INT),
VALUE :: npcol
60 INTEGER(KIND=C_INT),
VALUE :: myprow
61 INTEGER(KIND=C_INT),
VALUE :: mypcol
62 INTEGER(KIND=C_INT),
VALUE :: n
63 REAL(kind=c_double),
DIMENSION(*) :: matrix
64 REAL(kind=c_double),
DIMENSION(*) :: eigenvectors
65 REAL(kind=c_double),
DIMENSION(*) :: eigenvalues
66 END SUBROUTINE cp_fm_diag_cusolver_c
69 CALL timeset(routinen, handle)
71#if defined(__CUSOLVERMP)
72 n = matrix%matrix_struct%nrow_global
73 context => matrix%matrix_struct%context
76 ALLOCATE (eigenvalues_buffer(n))
78 CALL cp_fm_diag_cusolver_c( &
79 cusolver_context=context%cusolver_context, &
80 fortran_comm=matrix%matrix_struct%para_env%get_handle(), &
81 matrix_desc=matrix%matrix_struct%descriptor, &
82 nprow=context%num_pe(1), &
83 npcol=context%num_pe(2), &
84 myprow=context%mepos(1), &
85 mypcol=context%mepos(2), &
86 n=matrix%matrix_struct%nrow_global, &
87 matrix=matrix%local_data, &
88 eigenvectors=eigenvectors%local_data, &
89 eigenvalues=eigenvalues_buffer)
91 nmo =
SIZE(eigenvalues)
92 eigenvalues(1:nmo) = eigenvalues_buffer(1:nmo)
96 mark_used(eigenvectors)
100 mark_used(eigenvalues_buffer)
102 cpabort(
"CP2K compiled without the cuSOLVERMp library.")
105 CALL timestop(handle)
116 USE iso_c_binding,
ONLY: c_int, c_double
117 TYPE(
cp_fm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
118 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
120 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_fm_general_cusolver'
122 INTEGER(KIND=C_INT) :: handle, n
125 SUBROUTINE cp_fm_general_cusolver_c(cusolver_context, fortran_comm, a_matrix_desc, b_matrix_desc, &
126 nprow, npcol, myprow, mypcol, &
127 n, nmo, aMatrix, bMatrix, eigenvectors, eigenvalues) &
128 BIND(C, name="cp_fm_diag_cusolver_sygvd")
129 IMPORT :: c_int, c_double, c_ptr
130 TYPE(c_ptr),
INTENT(INOUT) :: cusolver_context
131 INTEGER(KIND=C_INT),
VALUE :: fortran_comm
132 INTEGER(KIND=C_INT),
DIMENSION(*) :: a_matrix_desc, b_matrix_desc
133 INTEGER(KIND=C_INT),
VALUE :: nprow
134 INTEGER(KIND=C_INT),
VALUE :: npcol
135 INTEGER(KIND=C_INT),
VALUE :: myprow
136 INTEGER(KIND=C_INT),
VALUE :: mypcol
137 INTEGER(KIND=C_INT),
VALUE :: n
138 INTEGER(KIND=C_INT),
VALUE :: nmo
139 REAL(kind=c_double),
DIMENSION(*) :: amatrix
140 REAL(kind=c_double),
DIMENSION(*) :: bmatrix
141 REAL(kind=c_double),
DIMENSION(*) :: eigenvectors
142 REAL(kind=c_double),
DIMENSION(*) :: eigenvalues
143 END SUBROUTINE cp_fm_general_cusolver_c
146 CALL timeset(routinen, handle)
148#if defined(__CUSOLVERMP)
149 n = int(amatrix%matrix_struct%nrow_global, c_int)
150 context => amatrix%matrix_struct%context
152 CALL cp_fm_general_cusolver_c( &
153 cusolver_context=context%cusolver_context, &
154 fortran_comm=int(amatrix%matrix_struct%para_env%get_handle(), c_int), &
155 a_matrix_desc=int(amatrix%matrix_struct%descriptor, c_int), &
156 b_matrix_desc=int(bmatrix%matrix_struct%descriptor, c_int), &
157 nprow=int(context%num_pe(1), c_int), &
158 npcol=int(context%num_pe(2), c_int), &
159 myprow=int(context%mepos(1), c_int), &
160 mypcol=int(context%mepos(2), c_int), &
162 nmo=int(
SIZE(eigenvalues), c_int), &
163 amatrix=amatrix%local_data, &
164 bmatrix=bmatrix%local_data, &
165 eigenvectors=eigenvectors%local_data, &
166 eigenvalues=eigenvalues)
170 mark_used(eigenvectors)
174 cpabort(
"CP2K compiled without the cuSOLVERMp library.")
177 CALL timestop(handle)
189 USE iso_c_binding,
ONLY: c_double, c_double_complex, c_int
190 TYPE(
cp_cfm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
191 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
193 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_cfm_general_cusolver'
195 INTEGER(KIND=C_INT) :: handle, n
198 SUBROUTINE cp_cfm_general_cusolver_c(cusolver_context, fortran_comm, a_matrix_desc, b_matrix_desc, &
199 nprow, npcol, myprow, mypcol, &
200 n, nmo, aMatrix, bMatrix, eigenvectors, eigenvalues) &
201 BIND(C, name="cp_cfm_diag_cusolver_hegvd")
202 IMPORT :: c_double, c_double_complex, c_int, c_ptr
203 TYPE(c_ptr),
INTENT(INOUT) :: cusolver_context
204 INTEGER(KIND=C_INT),
VALUE :: fortran_comm
205 INTEGER(KIND=C_INT),
DIMENSION(*) :: a_matrix_desc, b_matrix_desc
206 INTEGER(KIND=C_INT),
VALUE :: nprow
207 INTEGER(KIND=C_INT),
VALUE :: npcol
208 INTEGER(KIND=C_INT),
VALUE :: myprow
209 INTEGER(KIND=C_INT),
VALUE :: mypcol
210 INTEGER(KIND=C_INT),
VALUE :: n
211 INTEGER(KIND=C_INT),
VALUE :: nmo
212 COMPLEX(KIND=C_DOUBLE_COMPLEX),
DIMENSION(*) :: amatrix
213 COMPLEX(KIND=C_DOUBLE_COMPLEX),
DIMENSION(*) :: bmatrix
214 COMPLEX(KIND=C_DOUBLE_COMPLEX),
DIMENSION(*) :: eigenvectors
215 REAL(kind=c_double),
DIMENSION(*) :: eigenvalues
216 END SUBROUTINE cp_cfm_general_cusolver_c
219 CALL timeset(routinen, handle)
221#if defined(__CUSOLVERMP)
222 n = int(amatrix%matrix_struct%nrow_global, c_int)
223 context => amatrix%matrix_struct%context
225 CALL cp_cfm_general_cusolver_c( &
226 cusolver_context=context%cusolver_context, &
227 fortran_comm=int(amatrix%matrix_struct%para_env%get_handle(), c_int), &
228 a_matrix_desc=int(amatrix%matrix_struct%descriptor, c_int), &
229 b_matrix_desc=int(bmatrix%matrix_struct%descriptor, c_int), &
230 nprow=int(context%num_pe(1), c_int), &
231 npcol=int(context%num_pe(2), c_int), &
232 myprow=int(context%mepos(1), c_int), &
233 mypcol=int(context%mepos(2), c_int), &
235 nmo=int(
SIZE(eigenvalues), c_int), &
236 amatrix=amatrix%local_data, &
237 bmatrix=bmatrix%local_data, &
238 eigenvectors=eigenvectors%local_data, &
239 eigenvalues=eigenvalues)
243 mark_used(eigenvectors)
247 cpabort(
"CP2K compiled without the cuSOLVERMp library.")
250 CALL timestop(handle)
subroutine, public cp_cfm_general_cusolver(amatrix, bmatrix, eigenvectors, eigenvalues)
Driver routine to solve generalized complex eigenvalue problem A*x = lambda*B*x with cuSOLVERMp.