LCOV - code coverage report
Current view: top level - shared/common/src/28_numeric_noabirule - abi_xaxpy.f90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 48.8 % 43 21
Test Date: 2026-09-20 15:27:41 Functions: 50.0 % 8 4

            Line data    Source code
       1              : !{\src2tex{textfont=tt}}
       2              : !!****f* m_abi_linalg/abi_xaxpy
       3              : !! NAME
       4              : !!  abi_xaxpy
       5              : !!
       6              : !! FUNCTION
       7              : !!  abi_xaxpy is the generic function for BLAS-1 AXPY (y = alpha * x + y)
       8              : !!  with optional GPU dispatch.
       9              : !!
      10              : !! COPYRIGHT
      11              : !!  Copyright (C) 2001-2026 ABINIT group
      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              : !----------------------------------------------------------------------
      21              : 
      22              : !!****f* m_abi_linalg/abi_daxpy
      23              : !! NAME
      24              : !! abi_daxpy
      25              : !!
      26              : !! FUNCTION
      27              : !!  Real AXPY: y = alpha * x + y, with real(dp) alpha and real(dp) arrays.
      28              : !!  On GPU, calls abi_gpu_xaxpy_cptr with cplx=1.
      29              : !!
      30              : !! INPUTS
      31              : !!
      32              : !! SOURCE
      33              : 
      34            0 : subroutine abi_daxpy(n, alpha, x, incx, y, incy, gpu_option)
      35              : 
      36              : !Arguments ------------------------------------
      37              :  integer, intent(in) :: n
      38              :  real(dp), intent(in) :: alpha
      39              :  real(dp), target, intent(in) :: x(*)
      40              :  integer, intent(in) :: incx
      41              :  real(dp), target, intent(inout) :: y(*)
      42              :  integer, intent(in) :: incy
      43              :  !Optionals -----------------------------------
      44              :  integer, intent(in), optional :: gpu_option
      45              : 
      46              : !Local variables-------------------------------
      47              :  integer :: gpu_option_
      48              : 
      49              : ! *********************************************************************
      50              : 
      51            0 :  gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
      52              : 
      53            0 :  call abi_d2zaxpy(n, dcmplx(alpha, 0.0_dp), x, incx, y, incy, x_cplx=1, gpu_option=gpu_option_)
      54              : 
      55            0 : end subroutine abi_daxpy
      56              : !!***
      57              : 
      58              : !----------------------------------------------------------------------
      59              : 
      60              : !!****f* m_abi_linalg/abi_daxpy_2d
      61              : !! NAME
      62              : !! abi_daxpy_2d
      63              : !!
      64              : !! FUNCTION
      65              : !!  Real AXPY: y = alpha * x + y, with real(dp) alpha and real(dp) arrays.
      66              : !!  On GPU, calls abi_gpu_xaxpy_cptr with cplx=1.
      67              : !!
      68              : !! INPUTS
      69              : !!
      70              : !! SOURCE
      71              : 
      72            0 : subroutine abi_daxpy_2d(n, alpha, x, incx, y, incy, gpu_option)
      73              : 
      74              : !Arguments ------------------------------------
      75              :  integer, intent(in) :: n
      76              :  real(dp), intent(in) :: alpha
      77              :  real(dp), target, intent(in) :: x(:,:)
      78              :  integer, intent(in) :: incx
      79              :  real(dp), target, intent(inout) :: y(:,:)
      80              :  integer, intent(in) :: incy
      81              :  !Optionals -----------------------------------
      82              :  integer, intent(in), optional :: gpu_option
      83              : 
      84              : !Local variables-------------------------------
      85              :  integer :: gpu_option_
      86              : 
      87              : ! *********************************************************************
      88              : 
      89            0 :  gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
      90              : 
      91            0 :  call abi_d2zaxpy(n, dcmplx(alpha, 0.0_dp), x, incx, y, incy, x_cplx=1, gpu_option=gpu_option_)
      92              : 
      93            0 : end subroutine abi_daxpy_2d
      94              : !!***
      95              : 
      96              : !----------------------------------------------------------------------
      97              : 
      98              : !!****f* m_abi_linalg/abi_d2zaxpy_2d
      99              : !! NAME
     100              : !! abi_d2zaxpy_2d
     101              : !!
     102              : !! FUNCTION
     103              : !!  Real AXPY: y = alpha * x + y, with real(dp) alpha and real(dp) arrays.
     104              : !!  On GPU, calls abi_gpu_xaxpy_cptr with cplx=1.
     105              : !!
     106              : !! INPUTS
     107              : !!
     108              : !! SOURCE
     109              : 
     110       412274 : subroutine abi_d2zaxpy_2d(n, alpha, x, incx, y, incy, x_cplx, gpu_option)
     111              : 
     112              : !Arguments ------------------------------------
     113              :  integer, intent(in) :: n
     114              :  complex(dp), intent(in) :: alpha
     115              :  real(dp), target, intent(in) :: x(:,:)
     116              :  integer, intent(in) :: incx
     117              :  real(dp), target, intent(inout) :: y(:,:)
     118              :  integer, intent(in) :: incy
     119              :  !Optionals -----------------------------------
     120              :  integer, intent(in), optional :: x_cplx, gpu_option
     121              : 
     122              : !Local variables-------------------------------
     123              :  integer :: cplx_,gpu_option_
     124              : 
     125              : ! *********************************************************************
     126              : 
     127       412274 :  gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
     128       412274 :  cplx_=1 ; if(PRESENT(x_cplx)) cplx_ = x_cplx
     129              : 
     130       412274 :  call abi_d2zaxpy(n, alpha, x, incx, y, incy, x_cplx=cplx_, gpu_option=gpu_option_)
     131              : 
     132       412274 : end subroutine abi_d2zaxpy_2d
     133              : !!***
     134              : 
     135              : 
     136              : !----------------------------------------------------------------------
     137              : 
     138              : !!****f* m_abi_linalg/abi_d2zaxpy_5d
     139              : !! NAME
     140              : !! abi_d2zaxpy_5d
     141              : !!
     142              : !! FUNCTION
     143              : !!  Real AXPY: y = alpha * x + y, with real(dp) alpha and real(dp) arrays.
     144              : !!  On GPU, calls abi_gpu_xaxpy_cptr with cplx=1.
     145              : !!
     146              : !! INPUTS
     147              : !!
     148              : !! SOURCE
     149              : 
     150            0 : subroutine abi_d2zaxpy_5d(n, alpha, x, incx, y, incy, x_cplx, gpu_option)
     151              : 
     152              : !Arguments ------------------------------------
     153              :  integer, intent(in) :: n
     154              :  complex(dp), intent(in) :: alpha
     155              :  real(dp), target, intent(in) :: x(:,:,:,:,:)
     156              :  integer, intent(in) :: incx
     157              :  real(dp), target, intent(inout) :: y(:,:,:,:,:)
     158              :  integer, intent(in) :: incy
     159              :  !Optionals -----------------------------------
     160              :  integer, intent(in), optional :: x_cplx, gpu_option
     161              : 
     162              : !Local variables-------------------------------
     163              :  integer :: cplx_,gpu_option_
     164              : 
     165              : ! *********************************************************************
     166              : 
     167            0 :  gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
     168            0 :  cplx_=1 ; if(PRESENT(x_cplx)) cplx_ = x_cplx
     169              : 
     170            0 :  call abi_d2zaxpy(n, alpha, x, incx, y, incy, x_cplx=cplx_, gpu_option=gpu_option_)
     171              : 
     172            0 : end subroutine abi_d2zaxpy_5d
     173              : !!***
     174              : 
     175              : 
     176              : !----------------------------------------------------------------------
     177              : 
     178              : !!****f* m_abi_linalg/abi_d2zaxpy
     179              : !! NAME
     180              : !! abi_d2zaxpy
     181              : !!
     182              : !! FUNCTION
     183              : !!  Real AXPY: y = alpha * x + y, with real(dp) alpha and real(dp) arrays.
     184              : !!  On GPU, calls abi_gpu_xaxpy_cptr with cplx=1.
     185              : !!
     186              : !! INPUTS
     187              : !!
     188              : !! SOURCE
     189              : 
     190       412274 : subroutine abi_d2zaxpy(n, alpha, x, incx, y, incy, x_cplx, gpu_option)
     191              : 
     192              : !Arguments ------------------------------------
     193              :  integer, intent(in) :: n
     194              :  complex(dp), intent(in) :: alpha
     195              :  real(dp), target, intent(in) :: x(*)
     196              :  integer, intent(in) :: incx
     197              :  real(dp), target, intent(inout) :: y(*)
     198              :  integer, intent(in) :: incy
     199              :  !Optionals -----------------------------------
     200              :  integer, intent(in), optional :: x_cplx, gpu_option
     201              : 
     202              : !Local variables-------------------------------
     203              :  integer :: cplx_,gpu_option_
     204              : 
     205              : ! *********************************************************************
     206              : 
     207       412274 :  gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
     208       412274 :  cplx_=1 ; if(PRESENT(x_cplx)) cplx_ = x_cplx
     209              : 
     210              : #if defined(DEBUG_VERBOSE) && defined(HAVE_OPENMP_OFFLOAD)
     211              :  if ( gpu_option_ == ABI_GPU_OPENMP ) then
     212              :    ABI_CHECK(xomp_target_is_present(c_loc(x)), "Array isn't mapped on GPU")
     213              :    ABI_CHECK(xomp_target_is_present(c_loc(y)), "Array isn't mapped on GPU")
     214              :  end if
     215              : #endif
     216              : 
     217       412274 :  if(gpu_option_/=ABI_GPU_DISABLED) then
     218            0 :    if(gpu_option_==ABI_GPU_OPENMP) then
     219              : #ifdef HAVE_OPENMP_OFFLOAD
     220              :      !$OMP TARGET DATA USE_DEVICE_ADDR(x,y)
     221              :      call abi_gpu_xaxpy_cptr(cplx_, n, alpha, c_loc(x), incx, c_loc(y), incy)
     222              :      !$OMP END TARGET DATA
     223              : #endif
     224              :    else
     225            0 :      call abi_gpu_xaxpy_cptr(cplx_, n, alpha, c_loc(x), incx, c_loc(y), incy)
     226              :    end if
     227              :  else
     228       412274 :    if(cplx_==1) then
     229       412274 :      call daxpy(n, alpha, x, incx, y, incy)
     230              :    else
     231            0 :      call zaxpy(n, alpha, x, incx, y, incy)
     232              :    end if
     233              :  end if
     234              : 
     235       412274 : end subroutine abi_d2zaxpy
     236              : !!***
     237              : 
     238              : !----------------------------------------------------------------------
     239              : 
     240              : !!****f* m_abi_linalg/abi_zaxpy
     241              : !! NAME
     242              : !! abi_zaxpy
     243              : !!
     244              : !! FUNCTION
     245              : !!  Complex AXPY: y = alpha * x + y, with complex(dp) alpha and complex(dp) arrays.
     246              : !!  On GPU, calls abi_gpu_xaxpy_cptr with cplx=2.
     247              : !!
     248              : !! INPUTS
     249              : !!
     250              : !! SOURCE
     251              : 
     252       673983 : subroutine abi_zaxpy(n, alpha, x, incx, y, incy, gpu_option)
     253              : 
     254              : !Arguments ------------------------------------
     255              :  integer, intent(in) :: n
     256              :  complex(dp), intent(in) :: alpha
     257              :  complex(dp), target, intent(in) :: x(*)
     258              :  integer, intent(in) :: incx
     259              :  complex(dp), target, intent(inout) :: y(*)
     260              :  integer, intent(in) :: incy
     261              :  !Optionals -----------------------------------
     262              :  integer, intent(in), optional :: gpu_option
     263              : 
     264              : !Local variables-------------------------------
     265              :  integer :: gpu_option_
     266              : 
     267              : ! *********************************************************************
     268              : 
     269       673983 :  gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
     270              : 
     271              : #if defined(DEBUG_VERBOSE) && defined(HAVE_OPENMP_OFFLOAD)
     272              :  if ( gpu_option_ == ABI_GPU_OPENMP ) then
     273              :    ABI_CHECK(xomp_target_is_present(c_loc(x)), "Array isn't mapped on GPU")
     274              :    ABI_CHECK(xomp_target_is_present(c_loc(y)), "Array isn't mapped on GPU")
     275              :  end if
     276              : #endif
     277              : 
     278       673983 :  if(gpu_option_/=ABI_GPU_DISABLED) then
     279            0 :    if(gpu_option_==ABI_GPU_OPENMP) then
     280              : #ifdef HAVE_OPENMP_OFFLOAD
     281              :      !$OMP TARGET DATA USE_DEVICE_ADDR(x,y)
     282              :      call abi_gpu_xaxpy_cptr(2, n, alpha, c_loc(x), incx, c_loc(y), incy)
     283              :      !$OMP END TARGET DATA
     284              : #endif
     285              :    else
     286            0 :      call abi_gpu_xaxpy_cptr(2, n, alpha, c_loc(x), incx, c_loc(y), incy)
     287              :    end if
     288              :  else
     289       673983 :    call zaxpy(n, alpha, x, incx, y, incy)
     290              :  end if
     291              : 
     292       673983 : end subroutine abi_zaxpy
     293              : !!***
     294              : 
     295              : !----------------------------------------------------------------------
     296              : 
     297              : !!****f* m_abi_linalg/abi_zaxpy_2d
     298              : !! NAME
     299              : !! abi_zaxpy_2d
     300              : !!
     301              : !! FUNCTION
     302              : !!  Complex AXPY: y = alpha * x + y, with complex(dp) alpha and complex(dp) arrays.
     303              : !!  On GPU, calls abi_gpu_xaxpy_cptr with cplx=2.
     304              : !!
     305              : !! INPUTS
     306              : !!
     307              : !! SOURCE
     308              : 
     309       673983 : subroutine abi_zaxpy_2d(n, alpha, x, incx, y, incy, gpu_option)
     310              : 
     311              : !Arguments ------------------------------------
     312              :  integer, intent(in) :: n
     313              :  complex(dp), intent(in) :: alpha
     314              :  complex(dp), target, intent(in) :: x(:,:)
     315              :  integer, intent(in) :: incx
     316              :  complex(dp), target, intent(inout) :: y(:,:)
     317              :  integer, intent(in) :: incy
     318              :  !Optionals -----------------------------------
     319              :  integer, intent(in), optional :: gpu_option
     320              : 
     321              : !Local variables-------------------------------
     322              :  integer :: gpu_option_
     323              : 
     324              : ! *********************************************************************
     325              : 
     326       673983 :  gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
     327              : 
     328       673983 :  call abi_zaxpy(n, alpha, x, incx, y, incy, gpu_option=gpu_option_)
     329              : 
     330       673983 : end subroutine abi_zaxpy_2d
     331              : !!***
     332              : 
     333              : !----------------------------------------------------------------------
     334              : 
     335              : !!****f* m_abi_linalg/abi_zaxpy_3d
     336              : !! NAME
     337              : !! abi_zaxpy_3d
     338              : !!
     339              : !! FUNCTION
     340              : !!  Complex AXPY: y = alpha * x + y, with complex(dp) alpha and complex(dp) arrays.
     341              : !!  On GPU, calls abi_gpu_xaxpy_cptr with cplx=2.
     342              : !!
     343              : !! INPUTS
     344              : !!
     345              : !! SOURCE
     346              : 
     347            0 : subroutine abi_zaxpy_3d(n, alpha, x, incx, y, incy, gpu_option)
     348              : 
     349              : !Arguments ------------------------------------
     350              :  integer, intent(in) :: n
     351              :  complex(dp), intent(in) :: alpha
     352              :  complex(dp), target, intent(in) :: x(:,:,:)
     353              :  integer, intent(in) :: incx
     354              :  complex(dp), target, intent(inout) :: y(:,:,:)
     355              :  integer, intent(in) :: incy
     356              :  !Optionals -----------------------------------
     357              :  integer, intent(in), optional :: gpu_option
     358              : 
     359              : !Local variables-------------------------------
     360              :  integer :: gpu_option_
     361              : 
     362              : ! *********************************************************************
     363              : 
     364            0 :  gpu_option_=ABI_GPU_DISABLED ; if(PRESENT(gpu_option)) gpu_option_ = gpu_option
     365              : 
     366            0 :  call abi_zaxpy(n, alpha, x, incx, y, incy, gpu_option=gpu_option_)
     367              : 
     368            0 : end subroutine abi_zaxpy_3d
     369              : !!***
        

Generated by: LCOV version 2.3-1