LCOV - code coverage report
Current view: top level - shared/common/src/28_numeric_noabirule - abi_xcopy.f90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 77.1 % 48 37
Test Date: 2026-11-06 14:42:53 Functions: 80.0 % 10 8
Branches: 24.0 % 146 35

             Branch data     Line data    Source code
       1                 :             : !{\src2tex{textfont=tt}}
       2                 :             : !!****f* m_abi_linalg/abi_xcopy
       3                 :             : !! NAME
       4                 :             : !!  abi_xcopy
       5                 :             : !!
       6                 :             : !! FUNCTION
       7                 :             : !! abi_xcopy is the generic function for vector copy
       8                 :             : !! It performs the data copy: dst(1:n:incdst) = src(1:n:incsrc)
       9                 :             : !!
      10                 :             : !! COPYRIGHT
      11                 :             : !!  Copyright (C) 2001-2026 ABINIT group (LNguyen,FDahm (CS))
      12                 :             : !!  This file is distributed under the terms of the
      13                 :             : !!  GNU General Public License, see ~abinit/COPYING
      14                 :             : !!  or http://www.gnu.org/copyleft/gpl.txt .
      15                 :             : !!
      16                 :             : !! SOURCE
      17                 :             : 
      18                 :             : !!***
      19                 :             : 
      20                 :             : !!****f* m_abi_linalg/abi_zcopy
      21                 :             : !! NAME
      22                 :             : !! abi_zcopy
      23                 :             : !!
      24                 :             : !! FUNCTION
      25                 :             : !!
      26                 :             : !! INPUTS
      27                 :             : !!
      28                 :             : !! SOURCE
      29                 :             : !!
      30                 :     4841898 : subroutine abi_zcopy(size,tsrc,incsrc,tdest,incdest)
      31                 :             : 
      32                 :             : !Arguments-------------------------------------
      33                 :             :  integer, intent(in) :: size
      34                 :             :  integer, intent(in) :: incsrc
      35                 :             :  integer, intent(in) :: incdest
      36                 :             :  complex(dp),intent(in) :: tsrc
      37                 :             :  complex(dp),intent(inout) :: tdest
      38                 :             : 
      39                 :             :  !Local variables-------------------------------
      40                 :             : #ifdef DEV_LINALG_TIMING
      41                 :             :  real(dp) :: tsec(2)
      42                 :             :  call timab(TIMAB_XCOPY,1,tsec)
      43                 :             : #endif
      44                 :             : 
      45                 :           0 :  call zcopy(size,tsrc,incsrc,tdest,incdest)
      46                 :             : 
      47                 :             : #ifdef DEV_LINALG_TIMING
      48                 :             :  call timab(TIMAB_XCOPY,2,tsec)
      49                 :             : #endif
      50                 :             : 
      51                 :     4841898 : end subroutine abi_zcopy
      52                 :             : !!***
      53                 :             : 
      54                 :             : !!****f* m_abi_linalg/abi_zcopy_1d
      55                 :             : !! NAME
      56                 :             : !! abi_zcopy_1d
      57                 :             : !!
      58                 :             : !! FUNCTION
      59                 :             : !!
      60                 :             : !! INPUTS
      61                 :             : !!
      62                 :             : !! SOURCE
      63                 :             : 
      64                 :           0 : subroutine abi_zcopy_1d(size,tsrc,incsrc,tdest,incdest)
      65                 :             : 
      66                 :             : !Arguments-------------------------------------
      67                 :             :  integer, intent(in) :: size
      68                 :             :  integer, intent(in) :: incsrc
      69                 :             :  integer, intent(in) :: incdest
      70                 :             :  complex(dp), intent(in) :: tsrc(*)
      71                 :             :  complex(dp), intent(inout) :: tdest(*)
      72                 :             : 
      73                 :           0 :  call abi_zcopy(size,tsrc(1),incsrc,tdest(1),incdest)
      74                 :             : 
      75                 :           0 : end subroutine abi_zcopy_1d
      76                 :             : !!***
      77                 :             : 
      78                 :             : !!****f* m_abi_linalg/abi_dcopy
      79                 :             : !! NAME
      80                 :             : !! abi_dcopy
      81                 :             : !!
      82                 :             : !! FUNCTION
      83                 :             : !!
      84                 :             : !! INPUTS
      85                 :             : !!
      86                 :             : !! SOURCE
      87                 :             : 
      88                 :     3680405 : subroutine abi_dcopy(size,tsrc,incsrc,tdest,incdest,x_cplx)
      89                 :             : 
      90                 :             : !Arguments-------------------------------------
      91                 :             :  integer, intent(in) :: size
      92                 :             :  integer, intent(in) :: incsrc
      93                 :             :  integer, intent(in) :: incdest
      94                 :             :  real(dp),intent(in) :: tsrc
      95                 :             :  real(dp),intent(inout) :: tdest
      96                 :             :  integer, intent(in), optional :: x_cplx
      97                 :             : 
      98                 :             : !Local variables-------------------------------
      99                 :             :  integer  :: cplx_
     100                 :             : 
     101                 :             : #ifdef DEV_LINALG_TIMING
     102                 :             :  real(dp) :: tsec(2)
     103                 :             :  call timab(TIMAB_XCOPY,1,tsec)
     104                 :             : #endif
     105                 :             : 
     106         [ +  + ]:     3680405 :  cplx_=1 ; if(PRESENT(x_cplx)) cplx_ = x_cplx
     107         [ +  + ]:     2624057 :  if(cplx_ == 2) then
     108                 :      704792 :     call zcopy(size,tsrc,incsrc,tdest,incdest)
     109                 :             :  else
     110                 :     2975613 :     call dcopy(size,tsrc,incsrc,tdest,incdest)
     111                 :             :  end if
     112                 :             : 
     113                 :             : #ifdef DEV_LINALG_TIMING
     114                 :             :  call timab(TIMAB_XCOPY,2,tsec)
     115                 :             : #endif
     116                 :             : 
     117                 :     3680405 : end subroutine abi_dcopy
     118                 :             : !!***
     119                 :             : 
     120                 :             : !!****f* m_abi_linalg/abi_dcopy_1d
     121                 :             : !! NAME
     122                 :             : !! abi_dcopy_1d
     123                 :             : !!
     124                 :             : !! FUNCTION
     125                 :             : !!
     126                 :             : !! INPUTS
     127                 :             : !!
     128                 :             : !! SOURCE
     129                 :             : 
     130                 :       26700 : subroutine abi_dcopy_1d(size,tsrc,incsrc,tdest,incdest,x_cplx)
     131                 :             : 
     132                 :             : !Arguments-------------------------------------
     133                 :             :  integer, intent(in) :: size
     134                 :             :  integer, intent(in) :: incsrc
     135                 :             :  integer, intent(in) :: incdest
     136                 :             :  real(dp), intent(in)  :: tsrc(*)
     137                 :             :  real(dp), intent(inout) :: tdest(*)
     138                 :             : !Only for lobpcgwf
     139                 :             :  integer, intent(in), optional :: x_cplx
     140                 :             : 
     141                 :       26700 :  call abi_dcopy(size,tsrc(1),incsrc,tdest(1),incdest,x_cplx)
     142                 :             : 
     143                 :       26700 : end subroutine abi_dcopy_1d
     144                 :             : !!***
     145                 :             : 
     146                 :             : !!****f* m_abi_linalg/abi_dcopy_2d
     147                 :             : !! NAME
     148                 :             : !! abi_dcopy_2d
     149                 :             : !!
     150                 :             : !! FUNCTION
     151                 :             : !!
     152                 :             : !! INPUTS
     153                 :             : !!
     154                 :             : !! SOURCE
     155                 :             : 
     156                 :     1908128 : subroutine abi_dcopy_2d(size,tsrc,incsrc,tdest,incdest,x_cplx,gpu_option)
     157                 :             : 
     158                 :             : !Arguments-------------------------------------
     159                 :             :  integer, intent(in) :: size
     160                 :             :  integer, intent(in) :: incsrc
     161                 :             :  integer, intent(in) :: incdest
     162                 :             :  real(dp), target, DEV_CONTARRD intent(in) :: tsrc(:,:)
     163                 :             :  real(dp), target, DEV_CONTARRD intent(inout) :: tdest(:,:)
     164                 :             :  !Optionals -----------------------------------
     165                 :             :  integer, intent(in), optional :: gpu_option !only in xg
     166                 :             :  integer, intent(in), optional :: x_cplx  !Only for lobpcgwf
     167                 :             : 
     168                 :             : !Local variables-------------------------------
     169                 :             :  integer :: cplx_,gpu_option_
     170                 :             : 
     171                 :             : ! *********************************************************************
     172                 :             : 
     173         [ +  - ]:     1908128 :  gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
     174         [ +  - ]:     1908128 :  cplx_=1 ; if(PRESENT(x_cplx)) cplx_ = x_cplx
     175                 :             :  ! write(*,*) "dcopy2D size=",size
     176                 :             : 
     177         [ -  + ]:     1908128 :  if(gpu_option_/=ABI_GPU_DISABLED) then
     178         [ #  # ]:           0 :    if(gpu_option_==ABI_GPU_OPENMP) then
     179                 :             : #ifdef HAVE_OPENMP_OFFLOAD
     180                 :             :      !$OMP TARGET DATA USE_DEVICE_ADDR(tsrc,tdest)
     181                 :             :      call abi_gpu_xcopy_cptr(cplx_, size, c_loc(tsrc), incsrc, c_loc(tdest), incdest)
     182                 :             :      !$OMP END TARGET DATA
     183                 :             : #endif
     184                 :             :    else
     185                 :           0 :      call abi_gpu_xcopy_cptr(cplx_, size, c_loc(tsrc), incsrc, c_loc(tdest), incdest)
     186                 :             :    end if
     187                 :             :  else
     188                 :     1908128 :    call abi_dcopy(size,tsrc(1,1),incsrc,tdest(1,1),incdest,x_cplx)
     189                 :             :  end if
     190                 :             : 
     191                 :     1908128 : end subroutine abi_dcopy_2d
     192                 :             : !!***
     193                 :             : 
     194                 :             : !!****f* m_abi_linalg/abi_dcopy_0d_1d
     195                 :             : !! NAME
     196                 :             : !! abi_dcopy_0d_1d
     197                 :             : !!
     198                 :             : !! FUNCTION
     199                 :             : !!
     200                 :             : !! INPUTS
     201                 :             : !!
     202                 :             : !! SOURCE
     203                 :             : 
     204                 :           0 : subroutine abi_dcopy_0d_1d(size,tsrc,incsrc,tdest,incdest,x_cplx)
     205                 :             : 
     206                 :             : !Arguments-------------------------------------
     207                 :             :  integer, intent(in) :: size
     208                 :             :  integer, intent(in) :: incsrc
     209                 :             :  integer, intent(in) :: incdest
     210                 :             :  real(dp),intent(in) :: tsrc
     211                 :             :  real(dp), intent(inout) :: tdest(*)
     212                 :             :  integer,intent(in), optional :: x_cplx !only lobpcgwf
     213                 :             : 
     214                 :           0 :  call abi_dcopy(size,tsrc,incsrc,tdest(1),incdest,x_cplx)
     215                 :             : 
     216                 :           0 : end subroutine abi_dcopy_0d_1d
     217                 :             : !!***
     218                 :             : 
     219                 :             : !!****f* m_abi_linalg/abi_dcopy_1d_0d
     220                 :             : !! NAME
     221                 :             : !! abi_dcopy_1d_0d
     222                 :             : !!
     223                 :             : !! FUNCTION
     224                 :             : !!
     225                 :             : !! INPUTS
     226                 :             : !!
     227                 :             : !! SOURCE
     228                 :             : 
     229                 :      163157 : subroutine abi_dcopy_1d_0d(size,tsrc,incsrc,tdest,incdest,x_cplx)
     230                 :             : 
     231                 :             :  !Arguments-------------------------------------
     232                 :             :  integer, intent(in) :: size
     233                 :             :  integer, intent(in) :: incsrc
     234                 :             :  integer, intent(in) :: incdest
     235                 :             :  real(dp),intent(in) :: tsrc(*)
     236                 :             :  real(dp),intent(inout) :: tdest
     237                 :             :  integer,intent(in), optional :: x_cplx !only lobpcgwf
     238                 :             : 
     239                 :      163157 :  call abi_dcopy(size,tsrc(1),incsrc,tdest,incdest,x_cplx)
     240                 :             : 
     241                 :      163157 : end subroutine abi_dcopy_1d_0d
     242                 :             : !!***
     243                 :             : 
     244                 :             : !!****f* m_abi_linalg/abi_d2zcopy_2d
     245                 :             : !! NAME
     246                 :             : !! abi_d2zcopy_2d
     247                 :             : !!
     248                 :             : !! FUNCTION
     249                 :             : !!
     250                 :             : !! INPUTS
     251                 :             : !!
     252                 :             : !! SOURCE
     253                 :             : 
     254   [ -  +  -  + ]:      129952 : subroutine abi_d2zcopy_2d(size,tsrc,incsrc,tdest,incdest,x_cplx)
     255                 :             : 
     256                 :             :  !Arguments-------------------------------------
     257                 :             :  integer, intent(in) :: size
     258                 :             :  integer, intent(in) :: incsrc
     259                 :             :  integer, intent(in) :: incdest
     260                 :             :  real(dp),     DEV_CONTARRD intent(in) :: tsrc(:,:)
     261                 :             :  complex(dp), DEV_CONTARRD intent(inout) :: tdest(:,:)
     262                 :             :  !only in lobpcgwf
     263                 :             :  integer, intent(in),optional :: x_cplx
     264                 :             : 
     265                 :             : !Local variables-------------------------------
     266                 :             :  integer  :: cplx_
     267                 :             : 
     268                 :             : #ifdef DEV_LINALG_TIMING
     269                 :             :  real(dp) :: tsec(2)
     270                 :             :  call timab(TIMAB_XCOPY,1,tsec)
     271                 :             : #endif
     272                 :             : 
     273         [ +  + ]:      129952 :  cplx_=1 ; if(PRESENT(x_cplx)) cplx_ = x_cplx
     274         [ +  - ]:          64 :  if(cplx_ == 2) then
     275   [ -  +  -  -  :          64 :     call zcopy(size,tsrc,incsrc,tdest,incdest)
          -  -  -  -  -  
          +  -  -  -  -  
          -  -  -  +  -  
          -  -  -  -  +  
             -  -  -  - ]
     276                 :             :  else
     277   [ -  +  -  -  :      129888 :     call dcopy(size,tsrc,incsrc,tdest,incdest)
          -  -  -  -  -  
          +  -  -  -  -  
          -  -  -  +  -  
          -  -  -  -  +  
             -  -  -  - ]
     278                 :             :  end if
     279                 :             : 
     280                 :             : #ifdef DEV_LINALG_TIMING
     281                 :             :  call timab(TIMAB_XCOPY,2,tsec)
     282                 :             : #endif
     283                 :             : 
     284                 :      129952 : end subroutine abi_d2zcopy_2d
     285                 :             : !!***
     286                 :             : 
     287                 :             : 
     288                 :             : !!****f* m_abi_linalg/abi_zcopy_2d
     289                 :             : !! NAME
     290                 :             : !! abi_d2zcopy_2d
     291                 :             : !!
     292                 :             : !! FUNCTION
     293                 :             : !!
     294                 :             : !! INPUTS
     295                 :             : !!
     296                 :             : !! SOURCE
     297                 :             : 
     298                 :     4841898 : subroutine abi_zcopy_2d(size,tsrc,incsrc,tdest,incdest,gpu_option)
     299                 :             : 
     300                 :             :  !Arguments-------------------------------------
     301                 :             :  integer, intent(in) :: size
     302                 :             :  integer, intent(in) :: incsrc
     303                 :             :  integer, intent(in) :: incdest
     304                 :             :  complex(dp), target, DEV_CONTARRD intent(in) :: tsrc(:,:)
     305                 :             :  complex(dp), target, DEV_CONTARRD intent(inout) :: tdest(:,:)
     306                 :             :  !only in lobpcgwf
     307                 :             :  integer, intent(in),optional :: gpu_option
     308                 :             : 
     309                 :             : !Local variables-------------------------------
     310                 :             :  integer  :: gpu_option_
     311                 :             : 
     312                 :             : #ifdef DEV_LINALG_TIMING
     313                 :             :  real(dp) :: tsec(2)
     314                 :             :  call timab(TIMAB_XCOPY,1,tsec)
     315                 :             : #endif
     316                 :             : 
     317         [ +  - ]:     4841898 :  gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
     318         [ -  + ]:     4841898 :  if(gpu_option_/=ABI_GPU_DISABLED) then
     319         [ #  # ]:           0 :    if(gpu_option_==ABI_GPU_OPENMP) then
     320                 :             : #ifdef HAVE_OPENMP_OFFLOAD
     321                 :             :      !$OMP TARGET DATA USE_DEVICE_ADDR(tsrc,tdest)
     322                 :             :      call abi_gpu_xcopy_cptr(2, size, c_loc(tsrc), incsrc, c_loc(tdest), incdest)
     323                 :             :      !$OMP END TARGET DATA
     324                 :             : #endif
     325                 :             :    else
     326                 :           0 :      call abi_gpu_xcopy_cptr(2, size, c_loc(tsrc), incsrc, c_loc(tdest), incdest)
     327                 :             :    end if
     328                 :             :  else
     329                 :     4841898 :    call abi_zcopy(size,tsrc(1,1),incsrc,tdest(1,1),incdest)
     330                 :             :  end if
     331                 :     4841898 : end subroutine abi_zcopy_2d
     332                 :             : !!***
     333                 :             : 
     334                 :             : 
     335                 :             : !!****f* m_abi_linalg/abi_z2dcopy_2d
     336                 :             : !! NAME
     337                 :             : !! abi_z2dcopy_2d
     338                 :             : !!
     339                 :             : !! FUNCTION
     340                 :             : !!
     341                 :             : !! INPUTS
     342                 :             : !!
     343                 :             : !! SOURCE
     344                 :             : 
     345   [ -  +  -  + ]:      129952 : subroutine abi_z2dcopy_2d(size,tsrc,incsrc,tdest,incdest,x_cplx)
     346                 :             : 
     347                 :             : !Arguments-------------------------------------
     348                 :             :  integer, intent(in) :: size
     349                 :             :  integer, intent(in) :: incsrc
     350                 :             :  integer, intent(in) :: incdest
     351                 :             :  complex(dp), DEV_CONTARRD intent(in) :: tsrc(:,:)
     352                 :             :  real(dp),     DEV_CONTARRD intent(inout) :: tdest(:,:)
     353                 :             :  !only in lobpcgwf
     354                 :             :  integer,intent(in), optional :: x_cplx
     355                 :             : 
     356                 :             : !Local variables-------------------------------
     357                 :             :  integer  :: cplx_
     358                 :             : #ifdef DEV_LINALG_TIMING
     359                 :             :  real(dp) :: tsec(2)
     360                 :             :  call timab(TIMAB_XCOPY,1,tsec)
     361                 :             : #endif
     362                 :             : 
     363         [ +  + ]:      129952 :  cplx_=1 ; if(PRESENT(x_cplx)) cplx_ = x_cplx
     364         [ +  - ]:          64 :  if(cplx_ == 2) then
     365   [ -  +  -  -  :          64 :     call zcopy(size,tsrc,incsrc,tdest,incdest)
          -  -  -  -  -  
          +  -  -  -  -  
          -  -  -  +  -  
          -  -  -  -  +  
             -  -  -  - ]
     366                 :             :  else
     367   [ -  +  -  -  :      129888 :     call dcopy(size,tsrc,incsrc,tdest,incdest)
          -  -  -  -  -  
          +  -  -  -  -  
          -  -  -  +  -  
          -  -  -  -  +  
             -  -  -  - ]
     368                 :             :  end if
     369                 :             : 
     370                 :             : #ifdef DEV_LINALG_TIMING
     371                 :             :  call timab(TIMAB_XCOPY,2,tsec)
     372                 :             : #endif
     373                 :             : 
     374                 :      129952 : end subroutine abi_z2dcopy_2d
     375                 :             : !!***
        

Generated by: LCOV version 2.3-1