TABLE OF CONTENTS


ABINIT/m_ompgpu_utils [ Modules ]

[ Top ] [ Modules ]

NAME

  m_ompgpu_utils

FUNCTION

  Collection of routines useful for leveraging OpenMP GPU offload capabilities.

COPYRIGHT

  Copyright (C) 2000-2024 ABINIT group (MT)
  This file is distributed under the terms of the
  GNU General Public License, see ~abinit/COPYING
  or http://www.gnu.org/copyleft/gpl.txt .

PARENTS

CHILDREN

SOURCE

20 #if defined HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23 
24 #include "abi_common.h"
25 
26 module m_ompgpu_utils
27 
28  use defs_basis
29  use m_errors
30  use m_abicore
31  use m_xmpi
32 
33  implicit none
34 
35  private
36 
37 
38 #ifdef HAVE_OPENMP_OFFLOAD
39  ! pointer to GPU buffers
40  integer, pointer, save :: cur_kg_k(:,:) => null()
41  integer, pointer, save :: cur_kg_kp(:,:) => null()
42  integer, pointer, save :: cur_kg_k_gather(:,:) => null()
43 #endif
44 
45  public :: ompgpu_load_hamilt_buffers
46  public :: ompgpu_free_hamilt_buffers
47 
48 contains
49 
50  subroutine ompgpu_load_hamilt_buffers(kg_k,kg_kp,kg_k_gather)
51    integer,intent(in),target :: kg_k(:,:), kg_kp(:,:)
52    integer,intent(in),target,optional :: kg_k_gather(:,:)
53 
54 #ifdef HAVE_OPENMP_OFFLOAD
55    if(associated(cur_kg_k)) call ompgpu_free_hamilt_buffers()
56 
57    cur_kg_k            => kg_k
58    cur_kg_kp           => kg_kp
59    if(present(kg_k_gather))  cur_kg_k_gather     => kg_k_gather
60    !$OMP TARGET ENTER DATA MAP(to:cur_kg_k,cur_kg_kp,cur_kg_k_gather)
61 #else
62    ABI_UNUSED((/kg_k,kg_kp,kg_k_gather/))
63    ABI_BUG("ABINIT wasn't compiled with OpenMP GPU offloading, aborting.")
64 #endif
65  end subroutine ompgpu_load_hamilt_buffers
66 
67  subroutine ompgpu_free_hamilt_buffers()
68 #ifdef HAVE_OPENMP_OFFLOAD
69 
70    !$OMP TARGET EXIT DATA MAP(release:cur_kg_k,cur_kg_kp,cur_kg_k_gather)
71    cur_kg_k            => null()
72    cur_kg_kp           => null()
73    cur_kg_k_gather     => null()
74 #else
75    ABI_BUG("ABINIT wasn't compiled with OpenMP GPU offloading, aborting.")
76 #endif
77  end subroutine ompgpu_free_hamilt_buffers
78 
79 end module m_ompgpu_utils