40 TYPE(
cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
41 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
43 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_fm_diag_cusolver'
45 INTEGER :: handle, n, nmo
46 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues_buffer
49 SUBROUTINE cp_fm_diag_cusolver_c(fortran_comm, matrix_desc, &
50 nprow, npcol, myprow, mypcol, &
51 n, matrix, eigenvectors, eigenvalues) &
52 BIND(C, name="cp_fm_diag_cusolver")
53 IMPORT :: c_int, c_double
54 INTEGER(kind=C_INT),
VALUE :: fortran_comm
55 INTEGER(kind=C_INT),
DIMENSION(*) :: matrix_desc
56 INTEGER(kind=C_INT),
VALUE :: nprow
57 INTEGER(kind=C_INT),
VALUE :: npcol
58 INTEGER(kind=C_INT),
VALUE :: myprow
59 INTEGER(kind=C_INT),
VALUE :: mypcol
60 INTEGER(kind=C_INT),
VALUE :: n
61 REAL(kind=c_double),
DIMENSION(*) :: matrix
62 REAL(kind=c_double),
DIMENSION(*) :: eigenvectors
63 REAL(kind=c_double),
DIMENSION(*) :: eigenvalues
64 END SUBROUTINE cp_fm_diag_cusolver_c
67 CALL timeset(routinen, handle)
69#if defined(__CUSOLVERMP)
70 n = matrix%matrix_struct%nrow_global
71 context => matrix%matrix_struct%context
74 ALLOCATE (eigenvalues_buffer(n))
76 CALL cp_fm_diag_cusolver_c( &
77 fortran_comm=matrix%matrix_struct%para_env%get_handle(), &
78 matrix_desc=matrix%matrix_struct%descriptor, &
79 nprow=context%num_pe(1), &
80 npcol=context%num_pe(2), &
81 myprow=context%mepos(1), &
82 mypcol=context%mepos(2), &
83 n=matrix%matrix_struct%nrow_global, &
84 matrix=matrix%local_data, &
85 eigenvectors=eigenvectors%local_data, &
86 eigenvalues=eigenvalues_buffer)
88 nmo =
SIZE(eigenvalues)
89 eigenvalues(1:nmo) = eigenvalues_buffer(1:nmo)
93 mark_used(eigenvectors)
97 mark_used(eigenvalues_buffer)
99 cpabort(
"CP2K compiled without the cuSOLVERMp library.")
102 CALL timestop(handle)
113 USE iso_c_binding,
ONLY: c_int, c_double
114 TYPE(
cp_fm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
115 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
117 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_fm_general_cusolver'
119 INTEGER(kind=C_INT) :: handle, n, nmo
120 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues_buffer
123 SUBROUTINE cp_fm_general_cusolver_c(fortran_comm, a_matrix_desc, b_matrix_desc, &
124 nprow, npcol, myprow, mypcol, &
125 n, aMatrix, bMatrix, eigenvectors, eigenvalues) &
126 BIND(C, name="cp_fm_diag_cusolver_sygvd")
127 IMPORT :: c_int, c_double
128 INTEGER(kind=C_INT),
VALUE :: fortran_comm
129 INTEGER(kind=C_INT),
DIMENSION(*) :: a_matrix_desc, b_matrix_desc
130 INTEGER(kind=C_INT),
VALUE :: nprow
131 INTEGER(kind=C_INT),
VALUE :: npcol
132 INTEGER(kind=C_INT),
VALUE :: myprow
133 INTEGER(kind=C_INT),
VALUE :: mypcol
134 INTEGER(kind=C_INT),
VALUE :: n
135 REAL(kind=c_double),
DIMENSION(*) :: amatrix
136 REAL(kind=c_double),
DIMENSION(*) :: bmatrix
137 REAL(kind=c_double),
DIMENSION(*) :: eigenvectors
138 REAL(kind=c_double),
DIMENSION(*) :: eigenvalues
139 END SUBROUTINE cp_fm_general_cusolver_c
142 CALL timeset(routinen, handle)
144#if defined(__CUSOLVERMP)
145 n = int(amatrix%matrix_struct%nrow_global, c_int)
146 context => amatrix%matrix_struct%context
149 ALLOCATE (eigenvalues_buffer(n))
151 CALL cp_fm_general_cusolver_c( &
152 fortran_comm=int(amatrix%matrix_struct%para_env%get_handle(), c_int), &
153 a_matrix_desc=int(amatrix%matrix_struct%descriptor, c_int), &
154 b_matrix_desc=int(bmatrix%matrix_struct%descriptor, c_int), &
155 nprow=int(context%num_pe(1), c_int), &
156 npcol=int(context%num_pe(2), c_int), &
157 myprow=int(context%mepos(1), c_int), &
158 mypcol=int(context%mepos(2), c_int), &
160 amatrix=amatrix%local_data, &
161 bmatrix=bmatrix%local_data, &
162 eigenvectors=eigenvectors%local_data, &
163 eigenvalues=eigenvalues_buffer)
165 nmo =
SIZE(eigenvalues)
166 eigenvalues(1:nmo) = eigenvalues_buffer(1:nmo)
168 DEALLOCATE (eigenvalues_buffer)
172 mark_used(eigenvectors)
176 mark_used(eigenvalues_buffer)
178 cpabort(
"CP2K compiled without the cuSOLVERMp library.")
181 CALL timestop(handle)
193 USE iso_c_binding,
ONLY: c_double, c_double_complex, c_int
194 TYPE(
cp_cfm_type),
INTENT(IN) :: amatrix, bmatrix, eigenvectors
195 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
197 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_cfm_general_cusolver'
199 INTEGER(kind=C_INT) :: handle, n, nmo
200 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues_buffer
203 SUBROUTINE cp_cfm_general_cusolver_c(fortran_comm, a_matrix_desc, b_matrix_desc, &
204 nprow, npcol, myprow, mypcol, &
205 n, aMatrix, bMatrix, eigenvectors, eigenvalues) &
206 BIND(C, name="cp_cfm_diag_cusolver_hegvd")
207 IMPORT :: c_double, c_double_complex, c_int
208 INTEGER(kind=C_INT),
VALUE :: fortran_comm
209 INTEGER(kind=C_INT),
DIMENSION(*) :: a_matrix_desc, b_matrix_desc
210 INTEGER(kind=C_INT),
VALUE :: nprow
211 INTEGER(kind=C_INT),
VALUE :: npcol
212 INTEGER(kind=C_INT),
VALUE :: myprow
213 INTEGER(kind=C_INT),
VALUE :: mypcol
214 INTEGER(kind=C_INT),
VALUE :: n
215 COMPLEX(kind=C_DOUBLE_COMPLEX),
DIMENSION(*) :: amatrix
216 COMPLEX(kind=C_DOUBLE_COMPLEX),
DIMENSION(*) :: bmatrix
217 COMPLEX(kind=C_DOUBLE_COMPLEX),
DIMENSION(*) :: eigenvectors
218 REAL(kind=c_double),
DIMENSION(*) :: eigenvalues
219 END SUBROUTINE cp_cfm_general_cusolver_c
222 CALL timeset(routinen, handle)
224#if defined(__CUSOLVERMP)
225 n = int(amatrix%matrix_struct%nrow_global, c_int)
226 context => amatrix%matrix_struct%context
228 ALLOCATE (eigenvalues_buffer(n))
230 CALL cp_cfm_general_cusolver_c( &
231 fortran_comm=int(amatrix%matrix_struct%para_env%get_handle(), c_int), &
232 a_matrix_desc=int(amatrix%matrix_struct%descriptor, c_int), &
233 b_matrix_desc=int(bmatrix%matrix_struct%descriptor, c_int), &
234 nprow=int(context%num_pe(1), c_int), &
235 npcol=int(context%num_pe(2), c_int), &
236 myprow=int(context%mepos(1), c_int), &
237 mypcol=int(context%mepos(2), c_int), &
239 amatrix=amatrix%local_data, &
240 bmatrix=bmatrix%local_data, &
241 eigenvectors=eigenvectors%local_data, &
242 eigenvalues=eigenvalues_buffer)
244 nmo =
SIZE(eigenvalues)
245 eigenvalues(1:nmo) = eigenvalues_buffer(1:nmo)
247 DEALLOCATE (eigenvalues_buffer)
251 mark_used(eigenvectors)
255 mark_used(eigenvalues_buffer)
257 cpabort(
"CP2K compiled without the cuSOLVERMp library.")
260 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.