From 52d0ef3c00fc0542630fa98a4dfdf7137fb8635f Mon Sep 17 00:00:00 2001 From: AndreyChurbanov Date: Thu, 5 May 2022 11:27:48 -0500 Subject: [PATCH] [OpenMP] libomp: Add itt notifications to sync dependent tasks. Intel Inspector uses itt notifications to analyze code execution, and it reports race conditions in dependent tasks. This patch fixes the issue notifying Inspector on tasks dependency synchronizations. Differential Revision: https://reviews.llvm.org/D123042 --- openmp/runtime/src/kmp_taskdeps.cpp | 3 +++ openmp/runtime/src/kmp_taskdeps.h | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/openmp/runtime/src/kmp_taskdeps.cpp b/openmp/runtime/src/kmp_taskdeps.cpp index 501830eaa758..6c1d93a89183 100644 --- a/openmp/runtime/src/kmp_taskdeps.cpp +++ b/openmp/runtime/src/kmp_taskdeps.cpp @@ -45,6 +45,9 @@ static void __kmp_init_node(kmp_depnode_t *node) { #ifdef KMP_SUPPORT_GRAPH_OUTPUT node->dn.id = KMP_ATOMIC_INC(&kmp_node_id_seed); #endif +#if USE_ITT_BUILD && USE_ITT_NOTIFY + __itt_sync_create(node, "OMP task dep node", NULL, 0); +#endif } static inline kmp_depnode_t *__kmp_node_ref(kmp_depnode_t *node) { diff --git a/openmp/runtime/src/kmp_taskdeps.h b/openmp/runtime/src/kmp_taskdeps.h index 99f182bbd050..ac6174afd3f5 100644 --- a/openmp/runtime/src/kmp_taskdeps.h +++ b/openmp/runtime/src/kmp_taskdeps.h @@ -25,6 +25,9 @@ static inline void __kmp_node_deref(kmp_info_t *thread, kmp_depnode_t *node) { kmp_int32 n = KMP_ATOMIC_DEC(&node->dn.nrefs) - 1; KMP_DEBUG_ASSERT(n >= 0); if (n == 0) { +#if USE_ITT_BUILD && USE_ITT_NOTIFY + __itt_sync_destroy(node); +#endif KMP_ASSERT(node->dn.nrefs == 0); #if USE_FAST_MEMORY __kmp_fast_free(thread, node); @@ -125,11 +128,17 @@ static inline void __kmp_release_deps(kmp_int32 gtid, kmp_taskdata_t *task) { kmp_taskdata_t *next_taskdata; for (kmp_depnode_list_t *p = node->dn.successors; p; p = next) { kmp_depnode_t *successor = p->node; +#if USE_ITT_BUILD && USE_ITT_NOTIFY + __itt_sync_releasing(successor); +#endif kmp_int32 npredecessors = KMP_ATOMIC_DEC(&successor->dn.npredecessors) - 1; // successor task can be NULL for wait_depends or because deps are still // being processed if (npredecessors == 0) { +#if USE_ITT_BUILD && USE_ITT_NOTIFY + __itt_sync_acquired(successor); +#endif KMP_MB(); if (successor->dn.task) { KA_TRACE(20, ("__kmp_release_deps: T#%d successor %p of %p scheduled "