LCOV - code coverage report
Current view: top level - src/46_ghc_omp - m_ompgpu_utils.F90 (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 6 0
Test Date: 2026-09-19 17:42:43 Functions: 0.0 % 2 0

            Line data    Source code
       1              : !!****m* ABINIT/m_ompgpu_utils
       2              : !! NAME
       3              : !!  m_ompgpu_utils
       4              : !!
       5              : !! FUNCTION
       6              : !!  Collection of routines useful for leveraging OpenMP GPU offload capabilities.
       7              : !!
       8              : !! COPYRIGHT
       9              : !!  Copyright (C) 2000-2026 ABINIT group (MT)
      10              : !!  This file is distributed under the terms of the
      11              : !!  GNU General Public License, see ~abinit/COPYING
      12              : !!  or http://www.gnu.org/copyleft/gpl.txt .
      13              : !!
      14              : !! SOURCE
      15              : 
      16              : #if defined HAVE_CONFIG_H
      17              : #include "config.h"
      18              : #endif
      19              : 
      20              : #include "abi_common.h"
      21              : 
      22              : module m_ompgpu_utils
      23              : 
      24              :  use defs_basis
      25              :  use m_errors
      26              :  use m_abicore
      27              :  use m_xmpi
      28              : 
      29              :  implicit none
      30              : 
      31              :  private
      32              : 
      33              : 
      34              : #ifdef HAVE_OPENMP_OFFLOAD
      35              :  ! pointer to GPU buffers
      36              :  integer, pointer, save :: cur_kg_k(:,:) => null()
      37              :  integer, pointer, save :: cur_kg_kp(:,:) => null()
      38              :  real(dp), pointer, save :: cur_ffnl_k(:,:,:,:) => null()
      39              :  real(dp), pointer, save :: cur_ph3d_k(:,:,:) => null()
      40              :  integer, pointer, save :: cur_kg_k_gather(:,:) => null()
      41              : #endif
      42              : 
      43              :  public :: ompgpu_load_hamilt_buffers
      44              :  public :: ompgpu_free_hamilt_buffers
      45              : 
      46              : contains
      47              : 
      48            0 :  subroutine ompgpu_load_hamilt_buffers(kg_k,kg_kp,ffnl_k,ph3d_k,kg_k_gather)
      49              :    integer,intent(in),target :: kg_k(:,:), kg_kp(:,:)
      50              :    real(dp),intent(in),target :: ffnl_k(:,:,:,:),ph3d_k(:,:,:)
      51              :    integer,intent(in),target,optional :: kg_k_gather(:,:)
      52              : 
      53              : #ifdef HAVE_OPENMP_OFFLOAD
      54              :    if(associated(cur_kg_k)) call ompgpu_free_hamilt_buffers()
      55              : 
      56              :    cur_kg_k            => kg_k
      57              :    cur_kg_kp           => kg_kp
      58              :    cur_ffnl_k          => ffnl_k
      59              :    cur_ph3d_k          => ph3d_k
      60              :    if(present(kg_k_gather))  cur_kg_k_gather     => kg_k_gather
      61              :    !$OMP TARGET ENTER DATA MAP(to:cur_kg_k,cur_kg_kp,cur_ffnl_k,cur_ph3d_k,cur_kg_k_gather)
      62              : #else
      63              :    ABI_UNUSED((/kg_k,kg_kp,kg_k_gather/))
      64              :    ABI_UNUSED((/ffnl_k,ph3d_k/))
      65            0 :    ABI_BUG("ABINIT wasn't compiled with OpenMP GPU offloading, aborting.")
      66              : #endif
      67            0 :  end subroutine ompgpu_load_hamilt_buffers
      68              : 
      69            0 :  subroutine ompgpu_free_hamilt_buffers()
      70              : #ifdef HAVE_OPENMP_OFFLOAD
      71              : 
      72              :    !$OMP TARGET EXIT DATA MAP(release:cur_kg_k,cur_kg_kp,cur_ffnl_k,cur_ph3d_k,cur_kg_k_gather)
      73              :    cur_kg_k            => null()
      74              :    cur_kg_kp           => null()
      75              :    cur_kg_k_gather     => null()
      76              : #else
      77            0 :    ABI_BUG("ABINIT wasn't compiled with OpenMP GPU offloading, aborting.")
      78              : #endif
      79            0 :  end subroutine ompgpu_free_hamilt_buffers
      80              : 
      81              : end module m_ompgpu_utils
      82              : !!***
      83              : 
        

Generated by: LCOV version 2.3-1