[llvm-branch-commits] [openmp] 6f0f022 - [OpenMP] Update allocator trait key/value definitions
Author: Hansang Bae Date: 2021-01-12T20:09:45-06:00 New Revision: 6f0f0220380f83e8f3bf9832ffa795e9965fda2d URL: https://github.com/llvm/llvm-project/commit/6f0f0220380f83e8f3bf9832ffa795e9965fda2d DIFF: https://github.com/llvm/llvm-project/commit/6f0f0220380f83e8f3bf9832ffa795e9965fda2d.diff LOG: [OpenMP] Update allocator trait key/value definitions Use new definitions introduced in 5.1 specification. Differential Revision: https://reviews.llvm.org/D94277 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 openmp/runtime/src/kmp.h openmp/runtime/src/kmp_alloc.cpp Removed: diff --git a/openmp/runtime/src/include/omp.h.var b/openmp/runtime/src/include/omp.h.var index 8821377e29d8..4d055f905bcb 100644 --- a/openmp/runtime/src/include/omp.h.var +++ b/openmp/runtime/src/include/omp.h.var @@ -307,7 +307,7 @@ typedef uintptr_t omp_uintptr_t; typedef enum { -omp_atk_threadmodel = 1, +omp_atk_sync_hint = 1, omp_atk_alignment = 2, omp_atk_access = 3, omp_atk_pool_size = 4, @@ -320,10 +320,10 @@ typedef enum { omp_atv_false = 0, omp_atv_true = 1, -omp_atv_default = 2, omp_atv_contended = 3, omp_atv_uncontended = 4, -omp_atv_sequential = 5, +omp_atv_serialized = 5, +omp_atv_sequential = omp_atv_serialized, // (deprecated) omp_atv_private = 6, omp_atv_all = 7, omp_atv_thread = 8, @@ -338,6 +338,7 @@ omp_atv_blocked = 17, omp_atv_interleaved = 18 } omp_alloctrait_value_t; +#define omp_atv_default ((omp_uintptr_t)-1) typedef struct { omp_alloctrait_key_t key; diff --git a/openmp/runtime/src/include/omp_lib.f90.var b/openmp/runtime/src/include/omp_lib.f90.var index 24f8a2af4c5e..2fc8d7c3daa4 100644 --- a/openmp/runtime/src/include/omp_lib.f90.var +++ b/openmp/runtime/src/include/omp_lib.f90.var @@ -98,7 +98,7 @@ integer (kind=omp_control_tool_result_kind), parameter :: omp_control_tool_success = 0 integer (kind=omp_control_tool_result_kind), parameter :: omp_control_tool_ignored = 1 -integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_threadmodel = 1 +integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_sync_hint = 1 integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_alignment = 2 integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_access = 3 integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_pool_size = 4 @@ -107,12 +107,13 @@ integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_pinned = 7 integer (kind=omp_alloctrait_key_kind), parameter :: omp_atk_partition = 8 +integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_default = -1 integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_false = 0 integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_true = 1 -integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_default = 2 integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_contended = 3 integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_uncontended = 4 -integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_sequential = 5 +integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_serialized = 5 +integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_sequential = omp_atv_serialized integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_private = 6 integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_all = 7 integer (kind=omp_alloctrait_val_kind), parameter :: omp_atv_thread = 8 diff --git a/openmp/runtime/src/include/omp_lib.h.var b/openmp/runtime/src/include/omp_lib.h.var index 05140b04f273..3fb2d25b15f1 100644 --- a/openmp/runtime/src/include/omp_lib.h.var +++ b/openmp/runtime/src/include/omp_lib.h.var @@ -131,8 +131,8 @@ integer(omp_control_tool_result_kind)omp_control_tool_ignored parameter(omp_control_tool_ignored=1) - integer(kind=omp_alloctrait_key_kind)omp_atk_threadmodel - parameter(omp_atk_threadmodel=1) + integer(kind=omp_alloctrait_key_kind)omp_atk_sync_hint + parameter(omp_atk_sync_hint=1) integer(kind=omp_alloctrait_key_kind)omp_atk_alignment parameter(omp_atk_alignment=2) integer(kind=omp_alloctrait_key_kind)omp_atk_access @@ -148,18 +148,20 @@ integer(kind=omp_alloctrait_key_kind)omp_atk_partition parameter(omp_atk_partition=8) + integer(kind=omp_alloctrait_val_kind)omp_atv_default + parameter(omp_atv_default=-1) ! Reserved for future use integer(kind=omp_alloctrait_val_kind)omp
[llvm-branch-commits] [openmp] bba3a82 - [OpenMP] Use persistent memory for omp_large_cap_mem
Author: Hansang Bae Date: 2021-01-12T20:35:27-06:00 New Revision: bba3a82b56c0874757f2c1423bbdff08e2a88967 URL: https://github.com/llvm/llvm-project/commit/bba3a82b56c0874757f2c1423bbdff08e2a88967 DIFF: https://github.com/llvm/llvm-project/commit/bba3a82b56c0874757f2c1423bbdff08e2a88967.diff LOG: [OpenMP] Use persistent memory for omp_large_cap_mem This change enables volatile use of persistent memory for omp_large_cap_mem* on supported systems. It depends on libmemkind's support for persistent memory, and requirements/details can be found at the following url. https://pmem.io/2020/01/20/memkind-dax-kmem.html Differential Revision: https://reviews.llvm.org/D94353 Added: Modified: openmp/runtime/src/kmp_alloc.cpp Removed: diff --git a/openmp/runtime/src/kmp_alloc.cpp b/openmp/runtime/src/kmp_alloc.cpp index b56e71881208..31981d5c1d55 100644 --- a/openmp/runtime/src/kmp_alloc.cpp +++ b/openmp/runtime/src/kmp_alloc.cpp @@ -1239,6 +1239,9 @@ static void **mk_hbw_preferred; static void **mk_hugetlb; static void **mk_hbw_hugetlb; static void **mk_hbw_preferred_hugetlb; +static void **mk_dax_kmem; +static void **mk_dax_kmem_all; +static void **mk_dax_kmem_preferred; #if KMP_OS_UNIX && KMP_DYNAMIC_LIB static inline void chk_kind(void ***pkind) { @@ -1279,25 +1282,21 @@ void __kmp_init_memkind() { mk_hbw_preferred_hugetlb = (void **)dlsym(h_memkind, "MEMKIND_HBW_PREFERRED_HUGETLB"); chk_kind(&mk_hbw_preferred_hugetlb); + mk_dax_kmem = (void **)dlsym(h_memkind, "MEMKIND_DAX_KMEM"); + chk_kind(&mk_dax_kmem); + mk_dax_kmem_all = (void **)dlsym(h_memkind, "MEMKIND_DAX_KMEM_ALL"); + chk_kind(&mk_dax_kmem_all); + mk_dax_kmem_preferred = + (void **)dlsym(h_memkind, "MEMKIND_DAX_KMEM_PREFERRED"); + chk_kind(&mk_dax_kmem_preferred); KE_TRACE(25, ("__kmp_init_memkind: memkind library initialized\n")); return; // success } dlclose(h_memkind); // failure -h_memkind = NULL; } - kmp_mk_check = NULL; - kmp_mk_alloc = NULL; - kmp_mk_free = NULL; - mk_default = NULL; - mk_interleave = NULL; - mk_hbw = NULL; - mk_hbw_interleave = NULL; - mk_hbw_preferred = NULL; - mk_hugetlb = NULL; - mk_hbw_hugetlb = NULL; - mk_hbw_preferred_hugetlb = NULL; -#else +#else // !(KMP_OS_UNIX && KMP_DYNAMIC_LIB) kmp_mk_lib_name = ""; +#endif // !(KMP_OS_UNIX && KMP_DYNAMIC_LIB) h_memkind = NULL; kmp_mk_check = NULL; kmp_mk_alloc = NULL; @@ -1310,7 +1309,9 @@ void __kmp_init_memkind() { mk_hugetlb = NULL; mk_hbw_hugetlb = NULL; mk_hbw_preferred_hugetlb = NULL; -#endif + mk_dax_kmem = NULL; + mk_dax_kmem_all = NULL; + mk_dax_kmem_preferred = NULL; } void __kmp_fini_memkind() { @@ -1332,6 +1333,9 @@ void __kmp_fini_memkind() { mk_hugetlb = NULL; mk_hbw_hugetlb = NULL; mk_hbw_preferred_hugetlb = NULL; + mk_dax_kmem = NULL; + mk_dax_kmem_all = NULL; + mk_dax_kmem_preferred = NULL; #endif } @@ -1401,6 +1405,17 @@ omp_allocator_handle_t __kmpc_init_allocator(int gtid, omp_memspace_handle_t ms, __kmp_free(al); return omp_null_allocator; } +} else if (ms == omp_large_cap_mem_space) { + if (mk_dax_kmem_all) { +// All pmem nodes are visited +al->memkind = mk_dax_kmem_all; + } else if (mk_dax_kmem) { +// Only closest pmem node is visited +al->memkind = mk_dax_kmem; + } else { +__kmp_free(al); +return omp_null_allocator; + } } else { if (al->memkind == (void *)omp_atv_interleaved && mk_interleave) { al->memkind = mk_interleave; @@ -1473,6 +1488,8 @@ void *__kmpc_alloc(int gtid, size_t size, omp_allocator_handle_t allocator) { // pre-defined allocator if (allocator == omp_high_bw_mem_alloc && mk_hbw_preferred) { ptr = kmp_mk_alloc(*mk_hbw_preferred, desc.size_a); + } else if (allocator == omp_large_cap_mem_alloc && mk_dax_kmem_all) { +ptr = kmp_mk_alloc(*mk_dax_kmem_all, desc.size_a); } else { ptr = kmp_mk_alloc(*mk_default, desc.size_a); } @@ -1529,6 +1546,8 @@ void *__kmpc_alloc(int gtid, size_t size, omp_allocator_handle_t allocator) { // pre-defined allocator if (allocator == omp_high_bw_mem_alloc) { // ptr = NULL; +} else if (allocator == omp_large_cap_mem_alloc) { + // warnings? } else { ptr = __kmp_thread_malloc(__kmp_thread_from_gtid(gtid), desc.size_a); } @@ -1684,6 +1703,8 @@ void __kmpc_free(int gtid, void *ptr, const omp_allocator_handle_t allocator) { // pre-defined allocator if (oal == omp_high_bw_mem_alloc && mk_hbw_preferred) { kmp_mk_free(*mk_hbw_preferred, desc.ptr_alloc); + } else if (oal == omp_large_cap_mem_alloc && mk_dax_kmem_all) { +kmp_mk_free(*mk_dax_kmem_all, desc.ptr_alloc); } else { kmp_mk_free(*mk_defa
[llvm-branch-commits] [openmp] 2d911f7 - [OpenMP] Fix atomic entries for captured logical operation
Author: Hansang Bae Date: 2021-01-19T09:59:28-06:00 New Revision: 2d911f7c72f9174a34f74abe2909f992b03caaf1 URL: https://github.com/llvm/llvm-project/commit/2d911f7c72f9174a34f74abe2909f992b03caaf1 DIFF: https://github.com/llvm/llvm-project/commit/2d911f7c72f9174a34f74abe2909f992b03caaf1.diff LOG: [OpenMP] Fix atomic entries for captured logical operation Added missing code for the captured atomic operation. Differential Revision: https://reviews.llvm.org/D94848 Added: Modified: openmp/runtime/src/kmp_atomic.cpp Removed: diff --git a/openmp/runtime/src/kmp_atomic.cpp b/openmp/runtime/src/kmp_atomic.cpp index 4d60b550ae62..a9d5257ab2aa 100644 --- a/openmp/runtime/src/kmp_atomic.cpp +++ b/openmp/runtime/src/kmp_atomic.cpp @@ -2536,8 +2536,11 @@ ATOMIC_CRITICAL_CPT_MIX(float10, long double, div_cpt, /, fp, _Quad, 10r, \ if (flag) { \ new_value OP rhs; \ - } else \ +(*lhs) = new_value; \ + } else { \ new_value = (*lhs); \ +(*lhs) OP rhs; \ + } \ \ __kmp_release_atomic_lock(&ATOMIC_LOCK##LCK_ID, gtid); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [openmp] 480cbed - [OpenMP] Remove unnecessary pointer checks in a few locations
Author: Hansang Bae Date: 2021-01-22T19:18:50-06:00 New Revision: 480cbed31e74b0db3d31d78789b639af250ce9fe URL: https://github.com/llvm/llvm-project/commit/480cbed31e74b0db3d31d78789b639af250ce9fe DIFF: https://github.com/llvm/llvm-project/commit/480cbed31e74b0db3d31d78789b639af250ce9fe.diff LOG: [OpenMP] Remove unnecessary pointer checks in a few locations Also, return NULL from unsuccessful OMPT function lookup. Differential Revision: https://reviews.llvm.org/D95277 Added: Modified: openmp/runtime/src/kmp_taskdeps.cpp openmp/runtime/src/ompt-general.cpp Removed: diff --git a/openmp/runtime/src/kmp_taskdeps.cpp b/openmp/runtime/src/kmp_taskdeps.cpp index f580431d0182..5713cb9cb4d8 100644 --- a/openmp/runtime/src/kmp_taskdeps.cpp +++ b/openmp/runtime/src/kmp_taskdeps.cpp @@ -529,10 +529,9 @@ kmp_int32 __kmpc_omp_task_with_deps(ident_t *loc_ref, kmp_int32 gtid, current_task->ompt_task_info.frame.enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0); if (ompt_enabled.ompt_callback_task_create) { - ompt_data_t task_data = ompt_data_none; ompt_callbacks.ompt_callback(ompt_callback_task_create)( - current_task ? &(current_task->ompt_task_info.task_data) : &task_data, - current_task ? &(current_task->ompt_task_info.frame) : NULL, + &(current_task->ompt_task_info.task_data), + &(current_task->ompt_task_info.frame), &(new_taskdata->ompt_task_info.task_data), ompt_task_explicit | TASK_TYPE_DETAILS_FORMAT(new_taskdata), 1, OMPT_LOAD_OR_GET_RETURN_ADDRESS(gtid)); @@ -646,13 +645,12 @@ kmp_int32 __kmpc_omp_task_with_deps(ident_t *loc_ref, kmp_int32 gtid, void __ompt_taskwait_dep_finish(kmp_taskdata_t *current_task, ompt_data_t *taskwait_task_data) { if (ompt_enabled.ompt_callback_task_schedule) { -ompt_data_t task_data = ompt_data_none; ompt_callbacks.ompt_callback(ompt_callback_task_schedule)( -current_task ? &(current_task->ompt_task_info.task_data) : &task_data, -ompt_task_switch, taskwait_task_data); +&(current_task->ompt_task_info.task_data), ompt_task_switch, +taskwait_task_data); ompt_callbacks.ompt_callback(ompt_callback_task_schedule)( taskwait_task_data, ompt_task_complete, -current_task ? &(current_task->ompt_task_info.task_data) : &task_data); +&(current_task->ompt_task_info.task_data)); } current_task->ompt_task_info.frame.enter_frame.ptr = NULL; *taskwait_task_data = ompt_data_none; @@ -698,11 +696,9 @@ void __kmpc_omp_wait_deps(ident_t *loc_ref, kmp_int32 gtid, kmp_int32 ndeps, current_task->ompt_task_info.frame.enter_frame.ptr = OMPT_GET_FRAME_ADDRESS(0); if (ompt_enabled.ompt_callback_task_create) { - ompt_data_t task_data = ompt_data_none; ompt_callbacks.ompt_callback(ompt_callback_task_create)( - current_task ? &(current_task->ompt_task_info.task_data) : &task_data, - current_task ? &(current_task->ompt_task_info.frame) : NULL, - taskwait_task_data, + &(current_task->ompt_task_info.task_data), + &(current_task->ompt_task_info.frame), taskwait_task_data, ompt_task_explicit | ompt_task_undeferred | ompt_task_mergeable, 1, OMPT_LOAD_OR_GET_RETURN_ADDRESS(gtid)); } diff --git a/openmp/runtime/src/ompt-general.cpp b/openmp/runtime/src/ompt-general.cpp index 36bd6b55f33a..c52a3f28c2e7 100644 --- a/openmp/runtime/src/ompt-general.cpp +++ b/openmp/runtime/src/ompt-general.cpp @@ -840,5 +840,5 @@ static ompt_interface_fn_t ompt_fn_lookup(const char *s) { FOREACH_OMPT_INQUIRY_FN(ompt_interface_fn) - return (ompt_interface_fn_t)0; + return NULL; } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [openmp] 82a29a6 - [OpenMP] Add definition/interface for target memory routines
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,
[llvm-branch-commits] [openmp] fb1c528 - [OpenMP] Use c_int/c_size_t in Fortran target memory routine interface
Author: Hansang Bae Date: 2021-01-06T16:28:30-06:00 New Revision: fb1c52852690cb6ad6f7f2a7b5c35bf4d0c56e44 URL: https://github.com/llvm/llvm-project/commit/fb1c52852690cb6ad6f7f2a7b5c35bf4d0c56e44 DIFF: https://github.com/llvm/llvm-project/commit/fb1c52852690cb6ad6f7f2a7b5c35bf4d0c56e44.diff LOG: [OpenMP] Use c_int/c_size_t in Fortran target memory routine interface The Fortran interface is now in line with 5.1 specification. Differential Revision: https://reviews.llvm.org/D94042 Added: Modified: 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_lib.f90.var b/openmp/runtime/src/include/omp_lib.f90.var index 1bde868a505b..24f8a2af4c5e 100644 --- a/openmp/runtime/src/include/omp_lib.f90.var +++ b/openmp/runtime/src/include/omp_lib.f90.var @@ -512,59 +512,54 @@ 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 +integer(c_size_t), value :: size +integer(c_int), 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 +integer(c_int), 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 +integer(c_int) omp_target_is_present type(c_ptr), value :: ptr -integer (kind=omp_integer_kind), value :: device_num +integer(c_int), 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 +integer(c_int) 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 +integer(c_size_t), value :: length, dst_offset, src_offset +integer(c_int), 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 +integer(c_int) 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(*) +integer(c_size_t), value :: element_size +integer(c_int), value :: num_dims, dst_device_num, src_device_num +integer(c_size_t), 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 +integer(c_int) 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(*) +integer(c_size_t), value :: length, dst_offset, src_offset +integer(c_int), value :: dst_device_num, src_device_num, & +depobj_count +integer(omp_depend_kind), optional :: depobj_list(*) end function omp_target_memcpy_asyn
[llvm-branch-commits] [openmp] 171ca93 - [OpenMP] Initialize runtime in the forked child process
Author: Hansang Bae Date: 2020-12-15T07:29:28-06:00 New Revision: 171ca93c543098d5e0bef459847de14cf17b5faf URL: https://github.com/llvm/llvm-project/commit/171ca93c543098d5e0bef459847de14cf17b5faf DIFF: https://github.com/llvm/llvm-project/commit/171ca93c543098d5e0bef459847de14cf17b5faf.diff LOG: [OpenMP] Initialize runtime in the forked child process This patch enables serial initialization in the forked child process to fix unstable runtime behavior when used with Python-based AI tools. Differential Revision: https://reviews.llvm.org/D93230 Added: Modified: openmp/runtime/src/z_Linux_util.cpp Removed: diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp index 15237d631958..d039a454f00d 100644 --- a/openmp/runtime/src/z_Linux_util.cpp +++ b/openmp/runtime/src/z_Linux_util.cpp @@ -1272,8 +1272,8 @@ static void __kmp_atfork_prepare(void) { } static void __kmp_atfork_parent(void) { - __kmp_release_bootstrap_lock(&__kmp_initz_lock); __kmp_release_bootstrap_lock(&__kmp_forkjoin_lock); + __kmp_release_bootstrap_lock(&__kmp_initz_lock); } /* Reset the library so execution in the child starts "all over again" with @@ -1281,6 +1281,7 @@ static void __kmp_atfork_parent(void) { allocated by parent, just abandon it to be safe. */ static void __kmp_atfork_child(void) { __kmp_release_bootstrap_lock(&__kmp_forkjoin_lock); + __kmp_release_bootstrap_lock(&__kmp_initz_lock); /* TODO make sure this is done right for nested/sibling */ // ATT: Memory leaks are here? TODO: Check it and fix. /* KMP_ASSERT( 0 ); */ @@ -1302,7 +1303,6 @@ static void __kmp_atfork_child(void) { } #endif // KMP_AFFINITY_SUPPORTED - __kmp_init_runtime = FALSE; #if KMP_USE_MONITOR __kmp_init_monitor = 0; #endif @@ -1355,6 +1355,8 @@ static void __kmp_atfork_child(void) { __kmp_itt_reset(); // reset ITT's global state #endif /* USE_ITT_BUILD */ + __kmp_serial_initialize(); + /* This is necessary to make sure no stale data is left around */ /* AC: customers complain that we use unsafe routines in the atfork handler. Mathworks: dlsym() is unsafe. We call dlsym and dlopen ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [openmp] e1fd202 - [OpenMP] Add definitions for 5.1 interop to omp.h
Author: Hansang Bae Date: 2020-12-17T13:03:59-06:00 New Revision: e1fd202489e184e32a23fe01af8a61e48af186a8 URL: https://github.com/llvm/llvm-project/commit/e1fd202489e184e32a23fe01af8a61e48af186a8 DIFF: https://github.com/llvm/llvm-project/commit/e1fd202489e184e32a23fe01af8a61e48af186a8.diff LOG: [OpenMP] Add definitions for 5.1 interop to omp.h Added: Modified: openmp/runtime/src/include/omp.h.var Removed: diff --git a/openmp/runtime/src/include/omp.h.var b/openmp/runtime/src/include/omp.h.var index 510bfc225f89..b687ff16eaeb 100644 --- a/openmp/runtime/src/include/omp.h.var +++ b/openmp/runtime/src/include/omp.h.var @@ -152,6 +152,67 @@ extern int __KAI_KMPC_CONVENTION omp_get_device_num (void); typedef void * omp_depend_t; +/* OpenMP 5.1 interop */ +typedef intptr_t omp_intptr_t; + +/* 0..omp_get_num_interop_properties()-1 are reserved for implementation-defined properties */ +typedef enum omp_interop_property { +omp_ipr_fr_id = -1, +omp_ipr_fr_name = -2, +omp_ipr_vendor = -3, +omp_ipr_vendor_name = -4, +omp_ipr_device_num = -5, +omp_ipr_platform = -6, +omp_ipr_device = -7, +omp_ipr_device_context = -8, +omp_ipr_targetsync = -9, +omp_ipr_first = -9 +} omp_interop_property_t; + +#define omp_interop_none 0 + +typedef enum omp_interop_rc { +omp_irc_no_value = 1, +omp_irc_success = 0, +omp_irc_empty = -1, +omp_irc_out_of_range = -2, +omp_irc_type_int = -3, +omp_irc_type_ptr = -4, +omp_irc_type_str = -5, +omp_irc_other = -6 +} omp_interop_rc_t; + +typedef void * omp_interop_t; + +/*! + * The `omp_get_num_interop_properties` routine retrieves the number of implementation-defined properties available for an `omp_interop_t` object. + */ +extern int __KAI_KMPC_CONVENTION omp_get_num_interop_properties(const omp_interop_t); +/*! + * The `omp_get_interop_int` routine retrieves an integer property from an `omp_interop_t` object. + */ +extern omp_intptr_t __KAI_KMPC_CONVENTION omp_get_interop_int(const omp_interop_t, omp_interop_property_t, int *); +/*! + * The `omp_get_interop_ptr` routine retrieves a pointer property from an `omp_interop_t` object. + */ +extern void * __KAI_KMPC_CONVENTION omp_get_interop_ptr(const omp_interop_t, omp_interop_property_t, int *); +/*! + * The `omp_get_interop_str` routine retrieves a string property from an `omp_interop_t` object. + */ +extern const char * __KAI_KMPC_CONVENTION omp_get_interop_str(const omp_interop_t, omp_interop_property_t, int *); +/*! + * The `omp_get_interop_name` routine retrieves a property name from an `omp_interop_t` object. + */ +extern const char * __KAI_KMPC_CONVENTION omp_get_interop_name(const omp_interop_t, omp_interop_property_t); +/*! + * The `omp_get_interop_type_desc` routine retrieves a description of the type of a property associated with an `omp_interop_t` object. + */ +extern const char * __KAI_KMPC_CONVENTION omp_get_interop_type_desc(const omp_interop_t, omp_interop_property_t); +/*! + * The `omp_get_interop_rc_desc` routine retrieves a description of the return code associated with an `omp_interop_t` object. + */ +extern const char * __KAI_KMPC_CONVENTION omp_get_interop_rc_desc(const omp_interop_rc_t, omp_interop_rc_t); + /* kmp API functions */ extern int__KAI_KMPC_CONVENTION kmp_get_stacksize (void); extern void __KAI_KMPC_CONVENTION kmp_set_stacksize (int); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [openmp] c4a2222 - [OpenMP] Add __kmpc_omp_target_task_alloc to dllexport
Author: Hansang Bae Date: 2020-12-04T08:11:14-06:00 New Revision: c4a4d97120df55f5d1d753e7f839fdb1da2f URL: https://github.com/llvm/llvm-project/commit/c4a4d97120df55f5d1d753e7f839fdb1da2f DIFF: https://github.com/llvm/llvm-project/commit/c4a4d97120df55f5d1d753e7f839fdb1da2f.diff LOG: [OpenMP] Add __kmpc_omp_target_task_alloc to dllexport This patch enables use of the entry on Windows. Differential Revision: https://reviews.llvm.org/D92618 Added: Modified: openmp/runtime/src/dllexports Removed: diff --git a/openmp/runtime/src/dllexports b/openmp/runtime/src/dllexports index da5a0c6e04d2..6e41376a16b9 100644 --- a/openmp/runtime/src/dllexports +++ b/openmp/runtime/src/dllexports @@ -387,6 +387,7 @@ kmpc_set_disp_num_buffers 267 __kmpc_task_allow_completion_event 276 __kmpc_taskred_init 277 __kmpc_taskred_modifier_init278 +__kmpc_omp_target_task_alloc279 %endif # User API entry points that have both lower- and upper- case versions for Fortran. ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [openmp] c3b5009 - [OpenMP] Use RTM lock for OMP lock with synchronization hint
Author: Hansang Bae Date: 2020-12-09T19:14:53-06:00 New Revision: c3b5009aa7f42ab8376b39d96e762e2d2e98ab5e URL: https://github.com/llvm/llvm-project/commit/c3b5009aa7f42ab8376b39d96e762e2d2e98ab5e DIFF: https://github.com/llvm/llvm-project/commit/c3b5009aa7f42ab8376b39d96e762e2d2e98ab5e.diff LOG: [OpenMP] Use RTM lock for OMP lock with synchronization hint This patch introduces a new RTM lock type based on spin lock which is used for OMP lock with speculative hint on supported architecture. Differential Revision: https://reviews.llvm.org/D92615 Added: Modified: openmp/runtime/src/kmp_csupport.cpp openmp/runtime/src/kmp_lock.cpp openmp/runtime/src/kmp_lock.h openmp/runtime/src/kmp_runtime.cpp openmp/runtime/src/kmp_settings.cpp Removed: diff --git a/openmp/runtime/src/kmp_csupport.cpp b/openmp/runtime/src/kmp_csupport.cpp index 1a8db51a667b..fbe7c3d646d6 100644 --- a/openmp/runtime/src/kmp_csupport.cpp +++ b/openmp/runtime/src/kmp_csupport.cpp @@ -1249,7 +1249,7 @@ static __forceinline kmp_dyna_lockseq_t __kmp_map_hint_to_lock(uintptr_t hint) { if (hint & kmp_lock_hint_hle) return KMP_TSX_LOCK(hle); if (hint & kmp_lock_hint_rtm) -return KMP_CPUINFO_RTM ? KMP_TSX_LOCK(rtm) : __kmp_user_lock_seq; +return KMP_CPUINFO_RTM ? KMP_TSX_LOCK(rtm_queuing) : __kmp_user_lock_seq; if (hint & kmp_lock_hint_adaptive) return KMP_CPUINFO_RTM ? KMP_TSX_LOCK(adaptive) : __kmp_user_lock_seq; @@ -1268,9 +1268,9 @@ static __forceinline kmp_dyna_lockseq_t __kmp_map_hint_to_lock(uintptr_t hint) { if ((hint & omp_lock_hint_uncontended) && !(hint & omp_lock_hint_speculative)) return lockseq_tas; - // HLE lock for speculation + // Use RTM lock for speculation if (hint & omp_lock_hint_speculative) -return KMP_TSX_LOCK(hle); +return KMP_CPUINFO_RTM ? KMP_TSX_LOCK(rtm_spin) : __kmp_user_lock_seq; return __kmp_user_lock_seq; } @@ -1291,6 +1291,7 @@ __ompt_get_mutex_impl_type(void *user_lock, kmp_indirect_lock_t *ilock = 0) { return kmp_mutex_impl_spin; #if KMP_USE_TSX case locktag_hle: +case locktag_rtm_spin: return kmp_mutex_impl_speculative; #endif default: @@ -1302,7 +1303,7 @@ __ompt_get_mutex_impl_type(void *user_lock, kmp_indirect_lock_t *ilock = 0) { switch (ilock->type) { #if KMP_USE_TSX case locktag_adaptive: - case locktag_rtm: + case locktag_rtm_queuing: return kmp_mutex_impl_speculative; #endif case locktag_nested_tas: @@ -1336,7 +1337,8 @@ static kmp_mutex_impl_t __ompt_get_mutex_impl_type() { return kmp_mutex_impl_queuing; #if KMP_USE_TSX case lk_hle: - case lk_rtm: + case lk_rtm_queuing: + case lk_rtm_spin: case lk_adaptive: return kmp_mutex_impl_speculative; #endif @@ -2144,7 +2146,8 @@ __kmp_init_nest_lock_with_hint(ident_t *loc, void **lock, kmp_dyna_lockseq_t seq) { #if KMP_USE_TSX // Don't have nested lock implementation for speculative locks - if (seq == lockseq_hle || seq == lockseq_rtm || seq == lockseq_adaptive) + if (seq == lockseq_hle || seq == lockseq_rtm_queuing || + seq == lockseq_rtm_spin || seq == lockseq_adaptive) seq = __kmp_user_lock_seq; #endif switch (seq) { diff --git a/openmp/runtime/src/kmp_lock.cpp b/openmp/runtime/src/kmp_lock.cpp index 6fa6bf060673..38b43a36fcb8 100644 --- a/openmp/runtime/src/kmp_lock.cpp +++ b/openmp/runtime/src/kmp_lock.cpp @@ -2764,20 +2764,22 @@ static int __kmp_test_hle_lock_with_checks(kmp_dyna_lock_t *lck, return __kmp_test_hle_lock(lck, gtid); // TODO: add checks } -static void __kmp_init_rtm_lock(kmp_queuing_lock_t *lck) { +static void __kmp_init_rtm_queuing_lock(kmp_queuing_lock_t *lck) { __kmp_init_queuing_lock(lck); } -static void __kmp_destroy_rtm_lock(kmp_queuing_lock_t *lck) { +static void __kmp_destroy_rtm_queuing_lock(kmp_queuing_lock_t *lck) { __kmp_destroy_queuing_lock(lck); } -static void __kmp_destroy_rtm_lock_with_checks(kmp_queuing_lock_t *lck) { +static void +__kmp_destroy_rtm_queuing_lock_with_checks(kmp_queuing_lock_t *lck) { __kmp_destroy_queuing_lock_with_checks(lck); } KMP_ATTRIBUTE_TARGET_RTM -static void __kmp_acquire_rtm_lock(kmp_queuing_lock_t *lck, kmp_int32 gtid) { +static void __kmp_acquire_rtm_queuing_lock(kmp_queuing_lock_t *lck, + kmp_int32 gtid) { unsigned retries = 3, status; do { status = _xbegin(); @@ -2799,13 +2801,14 @@ static void __kmp_acquire_rtm_lock(kmp_queuing_lock_t *lck, kmp_int32 gtid) { __kmp_acquire_queuing_lock(lck, gtid); } -static void __kmp_acquire_rtm_lock_with_checks(kmp_queuing_lock_t *lck, - kmp_int32 gtid) { - __kmp_acquire_rtm_lock(lck, gtid); +static void __kmp_acquire_rtm_queuing_lock_with_checks(kmp_queuing_lock_t *lck, +