LCOV - code coverage report
Current view: top level - diagonalization - magma.F90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 0 2 0.0 %
Date: 2019-09-08 04:53:50 Functions: 0 1 0.0 %

          Line data    Source code
       1             : !--------------------------------------------------------------------------------
       2             : ! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
       3             : ! This file is part of FLEUR and available as free software under the conditions
       4             : ! of the MIT license as expressed in the LICENSE file in more detail.
       5             : !--------------------------------------------------------------------------------
       6             : 
       7             : MODULE m_magma
       8             :   use m_juDFT
       9             :   INTEGER,PARAMETER :: NGPU_CONST=1
      10             :   !**********************************************************
      11             :   !     Solve the generalized eigenvalue problem
      12             :   !     using the MAGMA library for multiple GPUs
      13             :   !**********************************************************
      14             : CONTAINS
      15           0 :   SUBROUTINE magma_diag(hmat,smat,ne,eig,zmat)
      16             : #ifdef CPP_MAGMA
      17             :     use magma
      18             : #endif    
      19             :     use m_types_mat
      20             :     IMPLICIT NONE
      21             : 
      22             :     ! ... Arguments ...
      23             :     TYPE(t_mat),INTENT(INOUT)  :: hmat,smat
      24             :     INTEGER,INTENT(INOUT)      :: ne
      25             :     CLASS(t_mat),ALLOCATABLE,INTENT(OUT)    :: zmat
      26             :     REAL,INTENT(OUT)           :: eig(:)
      27             :   
      28             : #ifdef CPP_MAGMA
      29             : 
      30             :     ! ... Local Variables ..
      31             :     INTEGER :: lwork,liwork,lrwork,err,mout(1)
      32             :     REAL    :: eigTemp(hmat%matsize1)
      33             :     LOGICAL :: initialized=.false.
      34             : 
      35             :     REAL,    ALLOCATABLE :: rwork(:)
      36             :     INTEGER, ALLOCATABLE :: iwork(:)
      37             :     COMPLEX, ALLOCATABLE :: work(:)
      38             :     
      39             : 
      40             :     IF (.NOT.initialized) THEN
      41             :        initialized=.TRUE.
      42             :        CALL magmaf_init()
      43             :     ENDIF
      44             : 
      45             :     IF (hmat%l_real) THEN
      46             :        CALL juDFT_error("REAL diagonalization not implemented in magma.F90")
      47             :     ELSE
      48             :        !Query the workspace size 
      49             :        ALLOCATE(work(1),rwork(1),iwork(1))
      50             :        CALL magmaf_zhegvdx(1,'v','i','l',hmat%matsize1,hmat%data_c,SIZE(hmat%data_c,1),smat%data_c,SIZE(smat%data_c,1),&
      51             :             0.0,0.0,1,ne,mout,eigTemp,work,-1,rwork,-1,iwork,-1,err)
      52             :        IF (err/=0) CALL juDFT_error("Failed to query workspaces",calledby="magma.F90")
      53             :        lwork=work(1)
      54             :        lrwork=rwork(1)
      55             :        liwork=iwork(1)
      56             :        DEALLOCATE(work,rwork,iwork)
      57             :        ALLOCATE(work(lwork),rwork(lrwork),iwork(liwork))
      58             :        !Now the diagonalization
      59             :        CALL magmaf_zhegvdx(1,'v','i','l',hmat%matsize1,hmat%data_c,SIZE(hmat%data_c,1),smat%data_c,SIZE(smat%data_c,1),&
      60             :             0.0,0.0,1,ne,mout,eigTemp,work,lwork,rwork,lrwork,iwork,liwork,err)
      61             :        IF (err/=0) CALL juDFT_error("Magma failed to diagonalize Hamiltonian")
      62             :     ENDIF
      63             :     ALLOCATE(t_mat::zmat)
      64             :     CALL zmat%alloc(hmat%l_real,hmat%matsize1,ne)
      65             :     DO i = 1, ne
      66             :        eig(i) = eigTemp(i)
      67             :        IF (hmat%l_real) THEN
      68             :           zmat%data_r(:,i)=hmat%data_r(:nsize,i)
      69             :        ELSE
      70             :           zmat%data_c(:,i)=hmat%data_c(:nsize,i)
      71             :        ENDIF
      72             :     END DO
      73             : #endif
      74           0 :   END SUBROUTINE magma_diag
      75             : END MODULE m_magma
      76             : 

Generated by: LCOV version 1.13