[llvm-branch-commits] [openmp] 82a29a6 - [OpenMP] Add definition/interface for target memory routines
Hansang Bae via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jan 4 06:21:51 PST 2021
Author: Hansang Bae
Date: 2021-01-04T08:12:57-06:00
New Revision: 82a29a62aba52d68d37309cd3025370ba98e37e4
URL: https://github.com/llvm/llvm-project/commit/82a29a62aba52d68d37309cd3025370ba98e37e4
DIFF: https://github.com/llvm/llvm-project/commit/82a29a62aba52d68d37309cd3025370ba98e37e4.diff
LOG: [OpenMP] Add definition/interface for target memory routines
The change includes new routines introduced in 5.1 and Fortran
interface.
Differential Revision: https://reviews.llvm.org/D93505
Added:
Modified:
openmp/runtime/src/include/omp.h.var
openmp/runtime/src/include/omp_lib.f90.var
openmp/runtime/src/include/omp_lib.h.var
Removed:
################################################################################
diff --git a/openmp/runtime/src/include/omp.h.var b/openmp/runtime/src/include/omp.h.var
index b687ff16eaeb..8821377e29d8 100644
--- a/openmp/runtime/src/include/omp.h.var
+++ b/openmp/runtime/src/include/omp.h.var
@@ -213,6 +213,24 @@
*/
extern const char * __KAI_KMPC_CONVENTION omp_get_interop_rc_desc(const omp_interop_rc_t, omp_interop_rc_t);
+ /* OpenMP 5.1 device memory routines */
+
+ /*!
+ * The `omp_target_memcpy_async` routine asynchronously performs a copy between any combination of host and device pointers.
+ */
+ extern int __KAI_KMPC_CONVENTION omp_target_memcpy_async(void *, const void *, size_t, size_t, size_t, int,
+ int, int, omp_depend_t *);
+ /*!
+ * The `omp_target_memcpy_rect_async` routine asynchronously performs a copy between any combination of host and device pointers.
+ */
+ extern int __KAI_KMPC_CONVENTION omp_target_memcpy_rect_async(void *, const void *, size_t, int, const size_t *,
+ const size_t *, const size_t *, const size_t *, const size_t *, int, int,
+ int, omp_depend_t *);
+ /*!
+ * The `omp_get_mapped_ptr` routine returns the device pointer that is associated with a host pointer for a given device.
+ */
+ extern void * __KAI_KMPC_CONVENTION omp_get_mapped_ptr(const void *, int);
+
/* kmp API functions */
extern int __KAI_KMPC_CONVENTION kmp_get_stacksize (void);
extern void __KAI_KMPC_CONVENTION kmp_set_stacksize (int);
diff --git a/openmp/runtime/src/include/omp_lib.f90.var b/openmp/runtime/src/include/omp_lib.f90.var
index fbbb7b9df94d..1bde868a505b 100644
--- a/openmp/runtime/src/include/omp_lib.f90.var
+++ b/openmp/runtime/src/include/omp_lib.f90.var
@@ -509,6 +509,103 @@
end subroutine omp_display_env
+ function omp_target_alloc(size, device_num) bind(c)
+ use omp_lib_kinds
+ type(c_ptr) omp_target_alloc
+ integer (kind=kmp_size_t_kind), value :: size
+ integer (kind=omp_integer_kind), value :: device_num
+ end function omp_target_alloc
+
+ subroutine omp_target_free(device_ptr, device_num) bind(c)
+ use omp_lib_kinds
+ type(c_ptr), value :: device_ptr
+ integer (kind=omp_integer_kind), value :: device_num
+ end subroutine omp_target_free
+
+ function omp_target_is_present(ptr, device_num) bind(c)
+ use omp_lib_kinds
+ integer (kind=omp_integer_kind) omp_target_is_present
+ type(c_ptr), value :: ptr
+ integer (kind=omp_integer_kind), value :: device_num
+ end function omp_target_is_present
+
+ function omp_target_memcpy(dst, src, length, dst_offset, src_offset, &
+ dst_device_num, src_device_num) bind(c)
+ use omp_lib_kinds
+ integer (kind=omp_integer_kind) omp_target_memcpy
+ type(c_ptr), value :: dst, src
+ integer (kind=kmp_size_t_kind), value :: length, dst_offset, &
+ src_offset
+ integer (kind=omp_integer_kind), value :: dst_device_num, &
+ src_device_num
+ end function omp_target_memcpy
+
+ function omp_target_memcpy_rect(dst, src, element_size, num_dims, &
+ volume, dst_offsets, src_offsets, dst_dimensions, &
+ src_dimensions, dst_device_num, src_device_num) bind(c)
+ use omp_lib_kinds
+ integer (kind=omp_integer_kind) omp_target_memcpy_rect
+ type(c_ptr), value :: dst, src
+ integer (kind=kmp_size_t_kind), value :: element_size
+ integer (kind=omp_integer_kind), value :: num_dims, &
+ dst_device_num, src_device_num
+ integer (kind=kmp_size_t_kind), intent(in) :: volume(*), &
+ dst_offsets(*), src_offsets(*), dst_dimensions(*), &
+ src_dimensions(*)
+ end function omp_target_memcpy_rect
+
+ function omp_target_memcpy_async(dst, src, length, dst_offset, &
+ src_offset, dst_device_num, src_device_num, depobj_count, &
+ depobj_list) bind(c)
+ use omp_lib_kinds
+ integer (kind=omp_integer_kind) omp_target_memcpy_async
+ type(c_ptr), value :: dst, src
+ integer (kind=kmp_size_t_kind), value :: length, dst_offset, &
+ src_offset
+ integer (kind=omp_integer_kind), value :: dst_device_num, &
+ src_device_num, depobj_count
+ integer (kind=omp_depend_kind), optional :: depobj_list(*)
+ end function omp_target_memcpy_async
+
+ function omp_target_memcpy_rect_async(dst, src, element_size, &
+ num_dims, volume, dst_offsets, src_offsets, dst_dimensions, &
+ src_dimensions, dst_device_num, src_device_num, depobj_count, &
+ depobj_list) bind(c)
+ use omp_lib_kinds
+ integer (kind=omp_integer_kind) omp_target_memcpy_rect_async
+ type(c_ptr), value :: dst, src
+ integer (kind=kmp_size_t_kind), value :: element_size
+ integer (kind=omp_integer_kind), value :: num_dims, &
+ dst_device_num, src_device_num, depobj_count
+ integer (kind=kmp_size_t_kind), intent(in) :: volume(*), &
+ dst_offsets(*), src_offsets(*), dst_dimensions(*), &
+ src_dimensions(*)
+ integer (kind=omp_depend_kind), optional :: depobj_list(*)
+ end function omp_target_memcpy_rect_async
+
+ function omp_target_associate_ptr(host_ptr, device_ptr, size, &
+ device_offset, device_num) bind(c)
+ use omp_lib_kinds
+ integer (kind=omp_integer_kind) omp_target_associate_ptr
+ type(c_ptr), value :: host_ptr, device_ptr
+ integer (kind=kmp_size_t_kind), value :: size, device_offset
+ integer (kind=omp_integer_kind), value :: device_num
+ end function omp_target_associate_ptr
+
+ function omp_get_mapped_ptr(ptr, device_num) bind(c)
+ use omp_lib_kinds
+ type(c_ptr) omp_get_mapped_ptr
+ type(c_ptr), value :: ptr
+ integer (kind=omp_integer_kind), value :: device_num
+ end function omp_get_mapped_ptr
+
+ function omp_target_disassociate_ptr(ptr, device_num) bind(c)
+ use omp_lib_kinds
+ integer (kind=omp_integer_kind) omp_target_disassociate_ptr
+ type(c_ptr), value :: ptr
+ integer (kind=omp_integer_kind), value :: device_num
+ end function omp_target_disassociate_ptr
+
! ***
! *** kmp_* entry points
! ***
diff --git a/openmp/runtime/src/include/omp_lib.h.var b/openmp/runtime/src/include/omp_lib.h.var
index f1b6b03f7725..b649a8071e6f 100644
--- a/openmp/runtime/src/include/omp_lib.h.var
+++ b/openmp/runtime/src/include/omp_lib.h.var
@@ -585,6 +585,113 @@
logical (kind=omp_logical_kind), value :: verbose
end subroutine omp_display_env
+ function omp_target_alloc(size, device_num) bind(c)
+ use, intrinsic :: iso_c_binding, only : c_ptr
+ import
+ type(c_ptr) omp_target_alloc
+ integer (kind=kmp_size_t_kind), value :: size
+ integer (kind=omp_integer_kind), value :: device_num
+ end function omp_target_alloc
+
+ subroutine omp_target_free(device_ptr, device_num) bind(c)
+ use, intrinsic :: iso_c_binding, only : c_ptr
+ import
+ type(c_ptr), value :: device_ptr
+ integer (kind=omp_integer_kind), value :: device_num
+ end subroutine omp_target_free
+
+ function omp_target_is_present(ptr, device_num) bind(c)
+ use, intrinsic :: iso_c_binding, only : c_ptr
+ import
+ integer (kind=omp_integer_kind) omp_target_is_present
+ type(c_ptr), value :: ptr
+ integer (kind=omp_integer_kind), value :: device_num
+ end function omp_target_is_present
+
+ function omp_target_memcpy(dst, src, length, dst_offset, &
+ & src_offset, dst_device_num, src_device_num) bind(c)
+ use, intrinsic :: iso_c_binding, only : c_ptr
+ import
+ integer (kind=omp_integer_kind) omp_target_memcpy
+ type(c_ptr), value :: dst, src
+ integer (kind=kmp_size_t_kind), value :: length, dst_offset, &
+ & src_offset
+ integer (kind=omp_integer_kind), value :: dst_device_num, &
+ & src_device_num
+ end function omp_target_memcpy
+
+ function omp_target_memcpy_rect(dst, src, element_size, &
+ & num_dims, volume, dst_offsets, src_offsets, dst_dimensions, &
+ & src_dimensions, dst_device_num, src_device_num) bind(c)
+ use, intrinsic :: iso_c_binding, only : c_ptr
+ import
+ integer (kind=omp_integer_kind) omp_target_memcpy_rect
+ type(c_ptr), value :: dst, src
+ integer (kind=kmp_size_t_kind), value :: element_size
+ integer (kind=omp_integer_kind), value :: num_dims, &
+ & dst_device_num, src_device_num
+ integer (kind=kmp_size_t_kind), intent(in) :: volume(*), &
+ & dst_offsets(*), src_offsets(*), dst_dimensions(*), &
+ & src_dimensions(*)
+ end function omp_target_memcpy_rect
+
+ function omp_target_memcpy_async(dst, src, length, dst_offset, &
+ & src_offset, dst_device_num, src_device_num, depobj_count, &
+ & depobj_list) bind(c)
+ use, intrinsic :: iso_c_binding, only : c_ptr
+ import
+ integer (kind=omp_integer_kind) omp_target_memcpy_async
+ type(c_ptr), value :: dst, src
+ integer (kind=kmp_size_t_kind), value :: length, dst_offset, &
+ & src_offset
+ integer (kind=omp_integer_kind), value :: dst_device_num, &
+ & src_device_num, depobj_count
+ integer (kind=omp_depend_kind), optional :: depobj_list(*)
+ end function omp_target_memcpy_async
+
+ function omp_target_memcpy_rect_async(dst, src, element_size, &
+ & num_dims, volume, dst_offsets, src_offsets, dst_dimensions, &
+ & src_dimensions, dst_device_num, src_device_num, &
+ & depobj_count, depobj_list) bind(c)
+ use, intrinsic :: iso_c_binding, only : c_ptr
+ import
+ integer (kind=omp_integer_kind) omp_target_memcpy_rect_async
+ type(c_ptr), value :: dst, src
+ integer (kind=kmp_size_t_kind), value :: element_size
+ integer (kind=omp_integer_kind), value :: num_dims, &
+ & dst_device_num, src_device_num, depobj_count
+ integer (kind=kmp_size_t_kind), intent(in) :: volume(*), &
+ & dst_offsets(*), src_offsets(*), dst_dimensions(*), &
+ & src_dimensions(*)
+ integer (kind=omp_depend_kind), optional :: depobj_list(*)
+ end function omp_target_memcpy_rect_async
+
+ function omp_target_associate_ptr(host_ptr, device_ptr, size, &
+ & device_offset, device_num) bind(c)
+ use, intrinsic :: iso_c_binding, only : c_ptr
+ import
+ integer (kind=omp_integer_kind) omp_target_associate_ptr
+ type(c_ptr), value :: host_ptr, device_ptr
+ integer (kind=kmp_size_t_kind), value :: size, device_offset
+ integer (kind=omp_integer_kind), value :: device_num
+ end function omp_target_associate_ptr
+
+ function omp_get_mapped_ptr(ptr, device_num) bind(c)
+ use, intrinsic :: iso_c_binding, only : c_ptr
+ import
+ type(c_ptr) omp_get_mapped_ptr
+ type(c_ptr), value :: ptr
+ integer (kind=omp_integer_kind), value :: device_num
+ end function omp_get_mapped_ptr
+
+ function omp_target_disassociate_ptr(ptr, device_num) bind(c)
+ use, intrinsic :: iso_c_binding, only : c_ptr
+ import
+ integer (kind=omp_integer_kind) omp_target_disassociate_ptr
+ type(c_ptr), value :: ptr
+ integer (kind=omp_integer_kind), value :: device_num
+ end function omp_target_disassociate_ptr
+
! ***
! *** kmp_* entry points
! ***
More information about the llvm-branch-commits
mailing list