13 USE iso_c_binding,
ONLY: c_double,&
18 #include "../base/base_uses.f90"
36 TYPE(cp_fm_type),
INTENT(IN) :: matrix, eigenvectors
37 REAL(kind=
dp),
DIMENSION(:),
INTENT(OUT) :: eigenvalues
39 CHARACTER(len=*),
PARAMETER :: routinen =
'cp_fm_diag_cusolver'
41 INTEGER :: handle, n, nmo
42 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:) :: eigenvalues_buffer
43 TYPE(cp_blacs_env_type),
POINTER :: context
45 SUBROUTINE cp_fm_diag_cusolver_c(fortran_comm, matrix_desc, &
46 nprow, npcol, myprow, mypcol, &
47 n, matrix, eigenvectors, eigenvalues) &
48 BIND(C, name="cp_fm_diag_cusolver")
49 IMPORT :: c_int, c_double
50 INTEGER(kind=C_INT),
VALUE :: fortran_comm
51 INTEGER(kind=C_INT),
DIMENSION(*) :: matrix_desc
52 INTEGER(kind=C_INT),
VALUE :: nprow
53 INTEGER(kind=C_INT),
VALUE :: npcol
54 INTEGER(kind=C_INT),
VALUE :: myprow
55 INTEGER(kind=C_INT),
VALUE :: mypcol
56 INTEGER(kind=C_INT),
VALUE :: n
57 REAL(kind=c_double),
DIMENSION(*) :: matrix
58 REAL(kind=c_double),
DIMENSION(*) :: eigenvectors
59 REAL(kind=c_double),
DIMENSION(*) :: eigenvalues
60 END SUBROUTINE cp_fm_diag_cusolver_c
63 CALL timeset(routinen, handle)
65 #if defined(__CUSOLVERMP)
66 n = matrix%matrix_struct%nrow_global
67 context => matrix%matrix_struct%context
70 ALLOCATE (eigenvalues_buffer(n))
72 CALL cp_fm_diag_cusolver_c( &
73 fortran_comm=matrix%matrix_struct%para_env%get_handle(), &
74 matrix_desc=matrix%matrix_struct%descriptor, &
75 nprow=context%num_pe(1), &
76 npcol=context%num_pe(2), &
77 myprow=context%mepos(1), &
78 mypcol=context%mepos(2), &
79 n=matrix%matrix_struct%nrow_global, &
80 matrix=matrix%local_data, &
81 eigenvectors=eigenvectors%local_data, &
82 eigenvalues=eigenvalues_buffer)
84 nmo =
SIZE(eigenvalues)
85 eigenvalues(1:nmo) = eigenvalues_buffer(1:nmo)
89 mark_used(eigenvectors)
90 mark_used(eigenvalues)
93 mark_used(eigenvalues_buffer)
95 cpabort(
"CP2K compiled without the cuSOLVERMp library.")
methods related to the blacs parallel environment
subroutine, public cp_fm_diag_cusolver(matrix, eigenvectors, eigenvalues)
Driver routine to diagonalize a FM matrix with the cuSOLVERMp library.
represent a full matrix distributed on many processors
Defines the basic variable types.
integer, parameter, public dp