m_omptgt_common Module

Constants and device-memory helpers shared by the OpenMP target backend.

Device arrays are held as contiguous Fortran pointers whose target is a raw omp_target_alloc allocation. The host never dereferences them: they are only passed as actual arguments to the explicit-shape or assumed-size dummies of the offloaded kernels, which name those dummies in an OMP_DEVICE_ADDR clause to say "this array already lives on the device", so the runtime neither maps nor copies it. Referencing such a pointer directly inside a target region instead makes the runtime map it implicitly, copying the whole array into a fresh device buffer and back on every launch.

OMP_DEVICE_ADDR is a preprocessor macro set per compiler in src/CMakeLists.txt, because no one spelling is accepted everywhere: OpenMP 5.1 says has_device_addr, and its compilers (GNU, Flang, Cray, ifx) allow is_device_ptr only on type(c_ptr); NVHPC rejects has_device_addr but takes the OpenMP 4.5 form, is_device_ptr on a dummy array. The preprocessors expand macros in !$omp lines.


Uses

  • module~~m_omptgt_common~~UsesGraph module~m_omptgt_common m_omptgt_common iso_c_binding iso_c_binding module~m_omptgt_common->iso_c_binding module~m_common m_common module~m_omptgt_common->module~m_common module~m_logger m_logger module~m_omptgt_common->module~m_logger omp_lib omp_lib module~m_omptgt_common->omp_lib module~m_common->module~m_logger m_mpi m_mpi module~m_common->m_mpi iso_fortran_env iso_fortran_env module~m_logger->iso_fortran_env module~m_logger->m_mpi

Used by

  • module~~m_omptgt_common~~UsedByGraph module~m_omptgt_common m_omptgt_common module~m_backend_setup m_backend_setup module~m_backend_setup->module~m_omptgt_common module~m_omptgt_backend m_omptgt_backend module~m_backend_setup->module~m_omptgt_backend module~m_omptgt_backend->module~m_omptgt_common module~m_omptgt_exec_dist m_omptgt_exec_dist module~m_omptgt_backend->module~m_omptgt_exec_dist module~m_omptgt_kernels_fieldops m_omptgt_kernels_fieldops module~m_omptgt_backend->module~m_omptgt_kernels_fieldops module~m_omptgt_sendrecv m_omptgt_sendrecv module~m_omptgt_backend->module~m_omptgt_sendrecv module~m_omptgt_tdsops m_omptgt_tdsops module~m_omptgt_backend->module~m_omptgt_tdsops module~m_omptgt_exec_thom m_omptgt_exec_thom module~m_omptgt_backend->module~m_omptgt_exec_thom module~m_omptgt_exec_dist->module~m_omptgt_common module~m_omptgt_kernels_dist m_omptgt_kernels_dist module~m_omptgt_exec_dist->module~m_omptgt_kernels_dist module~m_omptgt_exec_dist->module~m_omptgt_sendrecv module~m_omptgt_exec_dist->module~m_omptgt_tdsops module~m_omptgt_kernels_dist->module~m_omptgt_common module~m_omptgt_kernels_fieldops->module~m_omptgt_common module~m_omptgt_kernels_thom m_omptgt_kernels_thom module~m_omptgt_kernels_thom->module~m_omptgt_common module~m_omptgt_sendrecv->module~m_omptgt_common module~m_omptgt_tdsops->module~m_omptgt_common module~m_memcheck_build m_memcheck_build module~m_memcheck_build->module~m_backend_setup module~m_omptgt_exec_thom->module~m_omptgt_kernels_thom module~m_omptgt_exec_thom->module~m_omptgt_tdsops program~x3d2_poisson_solver x3d2_poisson_solver program~x3d2_poisson_solver->module~m_backend_setup program~xcompact xcompact program~xcompact->module~m_backend_setup program~x3d2_memcheck x3d2_memcheck program~x3d2_memcheck->module~m_memcheck_build

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: SZ = 64

Number of points a pencil group stacks together in the leading dimension, set to the width the target hardware issues a wavefront at so that one group fills one wavefront. The last branch covers a build that selects no vendor.

integer, public, parameter :: SZ = 32
integer, public, parameter :: SZ = 16
integer, public, parameter :: SZ = 16

Interfaces

public interface dev_alloc

Allocates a device array of the given extents.

  • private subroutine dev_alloc_1d(a, n)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(out), pointer, contiguous :: a(:)
    integer, intent(in) :: n
  • private subroutine dev_alloc_2d(a, n1, n2)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(out), pointer, contiguous :: a(:,:)
    integer, intent(in) :: n1
    integer, intent(in) :: n2
  • private subroutine dev_alloc_3d(a, n1, n2, n3)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(out), pointer, contiguous :: a(:,:,:)
    integer, intent(in) :: n1
    integer, intent(in) :: n2
    integer, intent(in) :: n3

public interface dev_free

Frees a device array allocated with dev_alloc.

  • private subroutine dev_free_1d(a)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(inout), pointer, contiguous :: a(:)
  • private subroutine dev_free_2d(a)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(inout), pointer, contiguous :: a(:,:)
  • private subroutine dev_free_3d(a)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(inout), pointer, contiguous :: a(:,:,:)

public interface dev_upload

Copies a host array into a device array of the same size.

  • private subroutine dev_upload_1d(a_dev, a_host)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in), pointer, contiguous :: a_dev(:)
    real(kind=dp), intent(in) :: a_host(:)
  • private subroutine dev_upload_2d(a_dev, a_host)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in), pointer, contiguous :: a_dev(:,:)
    real(kind=dp), intent(in) :: a_host(:,:)
  • private subroutine dev_upload_3d(a_dev, a_host)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in), pointer, contiguous :: a_dev(:,:,:)
    real(kind=dp), intent(in) :: a_host(:,:,:)

public interface dev_clone

Allocates a device array of a host array's shape and copies it in.

  • private subroutine dev_clone_1d(a_dev, a_host)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(out), pointer, contiguous :: a_dev(:)
    real(kind=dp), intent(in) :: a_host(:)
  • private subroutine dev_clone_2d(a_dev, a_host)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(out), pointer, contiguous :: a_dev(:,:)
    real(kind=dp), intent(in) :: a_host(:,:)

public interface dev_download

Copies a device array into a host array of the same size.

  • private subroutine dev_download_1d(a_host, a_dev)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(inout) :: a_host(:)
    real(kind=dp), intent(in), pointer, contiguous :: a_dev(:)
  • private subroutine dev_download_3d(a_host, a_dev)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(inout) :: a_host(:,:,:)
    real(kind=dp), intent(in), pointer, contiguous :: a_dev(:,:,:)

Subroutines

public subroutine memcpy_h2d(dst, src, n)

Copies n reals from host address src to device address dst.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: dst
type(c_ptr), intent(in) :: src
integer, intent(in) :: n

public subroutine memcpy_d2h(dst, src, n)

Copies n reals from device address src to host address dst.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: dst
type(c_ptr), intent(in) :: src
integer, intent(in) :: n

public subroutine device_sync()

Waits until the device work queued so far has completed.

Read more…

Arguments

None

public subroutine memcpy_d2d(dst, src, n)

Copies n reals between two device addresses.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: dst
type(c_ptr), intent(in) :: src
integer, intent(in) :: n