Commit d77edd75 authored by Victor Yu's avatar Victor Yu

Add solver to GENERIC_COO conversions

parent 37da163c
......@@ -203,6 +203,7 @@ module ELSI_DATATYPE
type(Matrix_ps) :: nt_ovlp
type(Matrix_ps) :: nt_ovlp_copy
type(Matrix_ps) :: nt_dm
type(Matrix_ps) :: nt_map
type(SolverParameters_t) :: nt_options
type(Permutation_t) :: nt_perm
type(ProcessGrid_t) :: nt_pgrid
......@@ -246,6 +247,9 @@ module ELSI_DATATYPE
real(kind=r8), allocatable :: occ(:,:,:)
integer(kind=i4), allocatable :: row_map(:)
integer(kind=i4), allocatable :: col_map(:)
integer(kind=i4), allocatable :: map_den(:,:)
integer(kind=i4), allocatable :: map_sp1(:)
integer(kind=i4), allocatable :: perm_sp3(:)
real(kind=r8), allocatable :: omm_c_real(:,:)
complex(kind=r8), allocatable :: omm_c_cmplx(:,:)
real(kind=r8), allocatable :: pexsi_ne_vec(:)
......
......@@ -1392,13 +1392,13 @@ subroutine elsi_get_edm_real(eh,edm)
call elsi_compute_edm_omm(eh%ph,eh%bh,eh%omm_c_real,edm)
case(PEXSI_SOLVER)
call elsi_compute_edm_pexsi(eh%ph,eh%bh,eh%pexsi_ne_vec,eh%dm_real_sp)
call elsi_pexsi_to_blacs_dm(eh%ph,eh%bh,eh%row_ind_sp1,eh%col_ptr_sp1,&
eh%dm_real_sp,edm)
call elsi_pexsi_to_blacs_dm(eh%ph,eh%bh,eh%dm_real_sp,eh%row_ind_sp1,&
eh%col_ptr_sp1,edm)
case(SIPS_SOLVER)
call elsi_build_edm_sips(eh%ph,eh%bh,eh%row_ind_sp1,eh%col_ptr_sp1,&
eh%occ(:,eh%ph%i_spin,eh%ph%i_kpt),eh%dm_real_sp)
call elsi_sips_to_blacs_dm(eh%ph,eh%bh,eh%row_ind_sp1,eh%col_ptr_sp1,&
eh%dm_real_sp,edm)
call elsi_sips_to_blacs_dm(eh%ph,eh%bh,eh%dm_real_sp,eh%row_ind_sp1,&
eh%col_ptr_sp1,edm)
case(NTPOLY_SOLVER)
call elsi_compute_edm_ntpoly(eh%ph,eh%bh,eh%ph%nt_ham,eh%ph%nt_dm)
call elsi_ntpoly_to_blacs_dm(eh%bh,eh%ph%nt_dm,edm)
......@@ -1453,11 +1453,11 @@ subroutine elsi_get_edm_real_sparse(eh,edm)
select case(eh%ph%matrix_format)
case(PEXSI_CSC)
call elsi_blacs_to_sips_dm(eh%ph,eh%bh,eh%row_ind_sp1,&
eh%col_ptr_sp1,eh%dm_real_den,edm)
call elsi_blacs_to_sips_dm(eh%ph,eh%bh,eh%dm_real_den,edm,&
eh%row_ind_sp1,eh%col_ptr_sp1)
case(SIESTA_CSC)
call elsi_blacs_to_siesta_dm(eh%bh,eh%row_ind_sp2,eh%col_ptr_sp2,&
eh%dm_real_den,edm)
call elsi_blacs_to_siesta_dm(eh%bh,eh%dm_real_den,edm,&
eh%row_ind_sp2,eh%col_ptr_sp2)
case default
call elsi_stop(eh%bh,"Unsupported matrix format.",caller)
end select
......@@ -1466,11 +1466,11 @@ subroutine elsi_get_edm_real_sparse(eh,edm)
select case(eh%ph%matrix_format)
case(PEXSI_CSC)
call elsi_blacs_to_sips_dm(eh%ph,eh%bh,eh%row_ind_sp1,&
eh%col_ptr_sp1,eh%dm_real_den,edm)
call elsi_blacs_to_sips_dm(eh%ph,eh%bh,eh%dm_real_den,edm,&
eh%row_ind_sp1,eh%col_ptr_sp1)
case(SIESTA_CSC)
call elsi_blacs_to_siesta_dm(eh%bh,eh%row_ind_sp2,eh%col_ptr_sp2,&
eh%dm_real_den,edm)
call elsi_blacs_to_siesta_dm(eh%bh,eh%dm_real_den,edm,&
eh%row_ind_sp2,eh%col_ptr_sp2)
case default
call elsi_stop(eh%bh,"Unsupported matrix format.",caller)
end select
......@@ -1481,8 +1481,9 @@ subroutine elsi_get_edm_real_sparse(eh,edm)
case(SIESTA_CSC)
call elsi_compute_edm_pexsi(eh%ph,eh%bh,eh%pexsi_ne_vec,&
eh%dm_real_sp)
call elsi_pexsi_to_siesta_dm(eh%ph,eh%bh,eh%row_ind_sp1,&
eh%col_ptr_sp1,eh%dm_real_sp,eh%row_ind_sp2,eh%col_ptr_sp2,edm)
call elsi_pexsi_to_siesta_dm(eh%ph,eh%bh,eh%dm_real_sp,&
eh%row_ind_sp1,eh%col_ptr_sp1,edm,eh%row_ind_sp2,&
eh%col_ptr_sp2)
case default
call elsi_stop(eh%bh,"Unsupported matrix format.",caller)
end select
......@@ -1494,8 +1495,9 @@ subroutine elsi_get_edm_real_sparse(eh,edm)
case(SIESTA_CSC)
call elsi_build_edm_sips(eh%ph,eh%bh,eh%row_ind_sp1,eh%col_ptr_sp1,&
eh%occ(:,eh%ph%i_spin,eh%ph%i_kpt),eh%dm_real_sp)
call elsi_sips_to_siesta_dm(eh%ph,eh%bh,eh%row_ind_sp1,&
eh%col_ptr_sp1,eh%dm_real_sp,eh%row_ind_sp2,eh%col_ptr_sp2,edm)
call elsi_sips_to_siesta_dm(eh%ph,eh%bh,eh%dm_real_sp,&
eh%row_ind_sp1,eh%col_ptr_sp1,edm,eh%row_ind_sp2,&
eh%col_ptr_sp2)
case default
call elsi_stop(eh%bh,"Unsupported matrix format.",caller)
end select
......@@ -1504,11 +1506,11 @@ subroutine elsi_get_edm_real_sparse(eh,edm)
select case(eh%ph%matrix_format)
case(PEXSI_CSC)
call elsi_ntpoly_to_sips_dm(eh%ph,eh%bh,eh%row_ind_sp1,&
eh%col_ptr_sp1,eh%ph%nt_dm,edm)
call elsi_ntpoly_to_sips_dm(eh%ph,eh%bh,eh%ph%nt_dm,edm,&
eh%row_ind_sp1,eh%col_ptr_sp1)
case(SIESTA_CSC)
call elsi_ntpoly_to_siesta_dm(eh%bh,eh%row_ind_sp2,eh%col_ptr_sp2,&
eh%ph%nt_dm,edm)
call elsi_ntpoly_to_siesta_dm(eh%bh,eh%ph%nt_dm,edm,eh%row_ind_sp2,&
eh%col_ptr_sp2)
end select
case default
call elsi_stop(eh%bh,"Unsupported density matrix solver.",caller)
......@@ -1557,8 +1559,8 @@ subroutine elsi_get_edm_complex(eh,edm)
call elsi_compute_edm_omm(eh%ph,eh%bh,eh%omm_c_cmplx,edm)
case(PEXSI_SOLVER)
call elsi_compute_edm_pexsi(eh%ph,eh%bh,eh%pexsi_ne_vec,eh%dm_cmplx_sp)
call elsi_pexsi_to_blacs_dm(eh%ph,eh%bh,eh%row_ind_sp1,eh%col_ptr_sp1,&
eh%dm_cmplx_sp,edm)
call elsi_pexsi_to_blacs_dm(eh%ph,eh%bh,eh%dm_cmplx_sp,eh%row_ind_sp1,&
eh%col_ptr_sp1,edm)
case(NTPOLY_SOLVER)
call elsi_compute_edm_ntpoly(eh%ph,eh%bh,eh%ph%nt_ham,eh%ph%nt_dm)
call elsi_ntpoly_to_blacs_dm(eh%bh,eh%ph%nt_dm,edm)
......@@ -1608,11 +1610,11 @@ subroutine elsi_get_edm_complex_sparse(eh,edm)
select case(eh%ph%matrix_format)
case(PEXSI_CSC)
call elsi_blacs_to_sips_dm(eh%ph,eh%bh,eh%row_ind_sp1,&
eh%col_ptr_sp1,eh%dm_cmplx_den,edm)
call elsi_blacs_to_sips_dm(eh%ph,eh%bh,eh%dm_cmplx_den,edm,&
eh%row_ind_sp1,eh%col_ptr_sp1)
case(SIESTA_CSC)
call elsi_blacs_to_siesta_dm(eh%bh,eh%row_ind_sp2,eh%col_ptr_sp2,&
eh%dm_cmplx_den,edm)
call elsi_blacs_to_siesta_dm(eh%bh,eh%dm_cmplx_den,edm,&
eh%row_ind_sp2,eh%col_ptr_sp2)
case default
call elsi_stop(eh%bh,"Unsupported matrix format.",caller)
end select
......@@ -1621,11 +1623,11 @@ subroutine elsi_get_edm_complex_sparse(eh,edm)
select case(eh%ph%matrix_format)
case(PEXSI_CSC)
call elsi_blacs_to_sips_dm(eh%ph,eh%bh,eh%row_ind_sp1,&
eh%col_ptr_sp1,eh%dm_cmplx_den,edm)
call elsi_blacs_to_sips_dm(eh%ph,eh%bh,eh%dm_cmplx_den,edm,&
eh%row_ind_sp1,eh%col_ptr_sp1)
case(SIESTA_CSC)
call elsi_blacs_to_siesta_dm(eh%bh,eh%row_ind_sp2,eh%col_ptr_sp2,&
eh%dm_cmplx_den,edm)
call elsi_blacs_to_siesta_dm(eh%bh,eh%dm_cmplx_den,edm,&
eh%row_ind_sp2,eh%col_ptr_sp2)
case default
call elsi_stop(eh%bh,"Unsupported matrix format.",caller)
end select
......@@ -1636,9 +1638,9 @@ subroutine elsi_get_edm_complex_sparse(eh,edm)
case(SIESTA_CSC)
call elsi_compute_edm_pexsi(eh%ph,eh%bh,eh%pexsi_ne_vec,&
eh%dm_cmplx_sp)
call elsi_pexsi_to_siesta_dm(eh%ph,eh%bh,eh%row_ind_sp1,&
eh%col_ptr_sp1,eh%dm_cmplx_sp,eh%row_ind_sp2,eh%col_ptr_sp2,&
edm)
call elsi_pexsi_to_siesta_dm(eh%ph,eh%bh,eh%dm_cmplx_sp,&
eh%row_ind_sp1,eh%col_ptr_sp1,edm,eh%row_ind_sp2,&
eh%col_ptr_sp2)
case default
call elsi_stop(eh%bh,"Unsupported matrix format.",caller)
end select
......@@ -1647,11 +1649,11 @@ subroutine elsi_get_edm_complex_sparse(eh,edm)
select case(eh%ph%matrix_format)
case(PEXSI_CSC)
call elsi_ntpoly_to_sips_dm(eh%ph,eh%bh,eh%row_ind_sp1,&
eh%col_ptr_sp1,eh%ph%nt_dm,edm)
call elsi_ntpoly_to_sips_dm(eh%ph,eh%bh,eh%ph%nt_dm,edm,&
eh%row_ind_sp1,eh%col_ptr_sp1)
case(SIESTA_CSC)
call elsi_ntpoly_to_siesta_dm(eh%bh,eh%row_ind_sp2,eh%col_ptr_sp2,&
eh%ph%nt_dm,edm)
call elsi_ntpoly_to_siesta_dm(eh%bh,eh%ph%nt_dm,edm,eh%row_ind_sp2,&
eh%col_ptr_sp2)
end select
case default
call elsi_stop(eh%bh,"Unsupported density matrix solver.",caller)
......
......@@ -274,6 +274,7 @@ subroutine elsi_cleanup_ntpoly(ph)
call DestructMatrix(ph%nt_ovlp)
call DestructMatrix(ph%nt_ovlp_copy)
call DestructMatrix(ph%nt_dm)
call DestructMatrix(ph%nt_map)
call DestructPermutation(ph%nt_perm)
call DestructProcessGrid(ph%nt_pgrid)
end if
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -691,7 +691,7 @@ subroutine elsi_read_mat_real_mp(rwh,f_name,mat)
eh%bh%n_lcol_sp = rwh%bh%n_lcol_sp
eh%bh%n_lcol_sp1 = rwh%bh%n_lcol_sp
call elsi_sips_to_blacs_dm(eh%ph,eh%bh,row_ind,col_ptr,nnz_val,mat)
call elsi_sips_to_blacs_dm(eh%ph,eh%bh,nnz_val,row_ind,col_ptr,mat)
call elsi_deallocate(rwh%bh,col_ptr,"col_ptr")
call elsi_deallocate(rwh%bh,row_ind,"row_ind")
......@@ -875,7 +875,7 @@ subroutine elsi_read_mat_complex_mp(rwh,f_name,mat)
eh%bh%n_lcol_sp = rwh%bh%n_lcol_sp
eh%bh%n_lcol_sp1 = rwh%bh%n_lcol_sp
call elsi_sips_to_blacs_dm(eh%ph,eh%bh,row_ind,col_ptr,nnz_val,mat)
call elsi_sips_to_blacs_dm(eh%ph,eh%bh,nnz_val,row_ind,col_ptr,mat)
call elsi_deallocate(rwh%bh,col_ptr,"col_ptr")
call elsi_deallocate(rwh%bh,row_ind,"row_ind")
......
......@@ -19,8 +19,9 @@ module ELSI_SETUP
use ELSI_NTPOLY, only: elsi_cleanup_ntpoly
use ELSI_OMM, only: elsi_cleanup_omm
use ELSI_PEXSI, only: elsi_set_pexsi_default,elsi_cleanup_pexsi
use ELSI_PRECISION, only: r8,i4
use ELSI_PRECISION, only: r8,i4,i8
use ELSI_SIPS, only: elsi_cleanup_sips
use ELSI_SORT, only: elsi_heapsort
use ELSI_UTILS, only: elsi_check_init,elsi_reset_param,elsi_reset_basic
implicit none
......@@ -336,6 +337,9 @@ subroutine elsi_set_coo(eh,nnz_g,nnz_l,row_ind,col_ind)
integer(kind=i4), intent(in) :: row_ind(nnz_l) !< Row index
integer(kind=i4), intent(in) :: col_ind(nnz_l) !< Column index
integer(kind=i4), allocatable :: perm(:)
integer(kind=i8), allocatable :: gid(:) ! Global 1D id
character(len=*), parameter :: caller = "elsi_set_coo"
call elsi_check_init(eh%bh,eh%handle_init,caller)
......@@ -352,12 +356,29 @@ subroutine elsi_set_coo(eh,nnz_g,nnz_l,row_ind,col_ind)
call elsi_deallocate(eh%bh,eh%col_ind_sp3,"col_ind_sp3")
end if
if(allocated(eh%perm_sp3)) then
call elsi_deallocate(eh%bh,eh%perm_sp3,"perm_sp3")
end if
call elsi_allocate(eh%bh,eh%row_ind_sp3,nnz_l,"row_ind_sp3",caller)
call elsi_allocate(eh%bh,eh%col_ind_sp3,nnz_l,"col_ind_sp3",caller)
call elsi_allocate(eh%bh,eh%perm_sp3,nnz_l,"perm_sp3",caller)
call elsi_allocate(eh%bh,gid,nnz_l,"gid",caller)
call elsi_allocate(eh%bh,perm,nnz_l,"perm",caller)
eh%row_ind_sp3 = row_ind
eh%col_ind_sp3 = col_ind
! Compute global 1D id
gid = int(col_ind-1,kind=i8)*int(eh%ph%n_basis,kind=i8)+int(row_ind,kind=i8)
! Sort
call elsi_heapsort(nnz_l,gid,perm)
call elsi_heapsort(nnz_l,perm,eh%perm_sp3)
call elsi_deallocate(eh%bh,gid,"gid")
call elsi_deallocate(eh%bh,perm,"perm")
eh%bh%generic_coo_ready = .true.
end subroutine
......@@ -456,11 +477,23 @@ subroutine elsi_reinit(eh)
end if
if(allocated(eh%row_ind_sp3)) then
call elsi_deallocate(eh%bh,eh%row_ind_sp2,"row_ind_sp3")
call elsi_deallocate(eh%bh,eh%row_ind_sp3,"row_ind_sp3")
end if
if(allocated(eh%col_ind_sp3)) then
call elsi_deallocate(eh%bh,eh%col_ptr_sp2,"col_ind_sp3")
call elsi_deallocate(eh%bh,eh%col_ind_sp3,"col_ind_sp3")
end if
if(allocated(eh%map_den)) then
call elsi_deallocate(eh%bh,eh%map_den,"map_den")
end if
if(allocated(eh%map_sp1)) then
call elsi_deallocate(eh%bh,eh%map_sp1,"map_sp1")
end if
if(allocated(eh%perm_sp3)) then
call elsi_deallocate(eh%bh,eh%perm_sp3,"perm_sp3")
end if
if(.not. eh%ph%solver == ELPA_SOLVER) then
......@@ -591,11 +624,11 @@ subroutine elsi_cleanup(eh)
end if
if(allocated(eh%row_ind_sp3)) then
call elsi_deallocate(eh%bh,eh%row_ind_sp2,"row_ind_sp3")
call elsi_deallocate(eh%bh,eh%row_ind_sp3,"row_ind_sp3")
end if
if(allocated(eh%col_ind_sp3)) then
call elsi_deallocate(eh%bh,eh%col_ptr_sp2,"col_ind_sp3")
call elsi_deallocate(eh%bh,eh%col_ind_sp3,"col_ind_sp3")
end if
! Auxiliary arrays
......@@ -631,6 +664,18 @@ subroutine elsi_cleanup(eh)
call elsi_deallocate(eh%bh,eh%pexsi_ne_vec,"pexsi_ne_vec")
end if
if(allocated(eh%map_den)) then
call elsi_deallocate(eh%bh,eh%map_den,"map_den")
end if
if(allocated(eh%map_sp1)) then
call elsi_deallocate(eh%bh,eh%map_sp1,"map_sp1")
end if
if(allocated(eh%perm_sp3)) then
call elsi_deallocate(eh%bh,eh%perm_sp3,"perm_sp3")
end if
if(eh%bh%json_init) then
call fjson_finish_array(eh%jh)
call fjson_close_file(eh%jh)
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment