[Openmp-commits] [PATCH] D57469: Set exit_frame in master task before calling a user's outlined function for a parallel loop construct

John Mellor-Crummey via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Jan 30 13:02:14 PST 2019


jmellorcrummey created this revision.
jmellorcrummey added reviewers: OpenMP, protze.joachim.

For combined parallel loop constructs, the master task launches an outlined function directly from the runtime. In such cases, the OMPT frame object for the master task needs to have its exit_frame field set before the task is launched. This patch corrects an omission in the OMPT support


Repository:
  rOMP OpenMP

https://reviews.llvm.org/D57469

Files:
  runtime/src/kmp_gsupport.cpp


Index: runtime/src/kmp_gsupport.cpp
===================================================================
--- runtime/src/kmp_gsupport.cpp
+++ runtime/src/kmp_gsupport.cpp
@@ -1089,6 +1089,13 @@
     OMPT_STORE_RETURN_ADDRESS(gtid);                                           \
   }
 
+#define OMPT_LOOP_BEFORE_TASK()                                                \
+  if (ompt_enabled.enabled) {                                                  \
+     ompt_frame_t *inner_frame;                                                \
+    __ompt_get_task_info_internal(0, NULL, NULL, &inner_frame, NULL, NULL);    \
+    inner_frame->exit_frame.ptr = OMPT_GET_FRAME_ADDRESS(0);                   \
+  }
+
 #define OMPT_LOOP_POST()                                                       \
   if (ompt_enabled.enabled) {                                                  \
     parent_frame->enter_frame = ompt_data_none;                                \
@@ -1098,6 +1105,8 @@
 
 #define OMPT_LOOP_PRE()
 
+#define OMPT_LOOP_BEFORE_TASK()
+
 #define OMPT_LOOP_POST()
 
 #endif
@@ -1467,7 +1476,7 @@
   KA_TRACE(20, ("GOMP_parallel_sections exit: T#%d\n", gtid));
 }
 
-#define PARALLEL_LOOP(func, schedule, ompt_pre, ompt_post)                     \
+#define PARALLEL_LOOP(func, schedule, ompt_pre, ompt_before_task, ompt_post)   \
   void func(void (*task)(void *), void *data, unsigned num_threads, long lb,   \
             long ub, long str, long chunk_sz, unsigned flags) {                \
     int gtid = __kmp_entry_gtid();                                             \
@@ -1498,6 +1507,7 @@
     KMP_DISPATCH_INIT(&loc, gtid, (schedule), lb,                              \
                       (str > 0) ? (ub - 1) : (ub + 1), str, chunk_sz,          \
                       (schedule) != kmp_sch_static);                           \
+    ompt_before_task();                                                        \
     task(data);                                                                \
     KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_END)();                         \
     ompt_post();                                                               \
@@ -1506,13 +1516,17 @@
   }
 
 PARALLEL_LOOP(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_STATIC),
-              kmp_sch_static, OMPT_LOOP_PRE, OMPT_LOOP_POST)
+              kmp_sch_static, OMPT_LOOP_PRE, OMPT_LOOP_BEFORE_TASK, 
+              OMPT_LOOP_POST)
 PARALLEL_LOOP(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_DYNAMIC),
-              kmp_sch_dynamic_chunked, OMPT_LOOP_PRE, OMPT_LOOP_POST)
+              kmp_sch_dynamic_chunked, OMPT_LOOP_PRE, OMPT_LOOP_BEFORE_TASK, 
+              OMPT_LOOP_POST)
 PARALLEL_LOOP(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_GUIDED),
-              kmp_sch_guided_chunked, OMPT_LOOP_PRE, OMPT_LOOP_POST)
+              kmp_sch_guided_chunked, OMPT_LOOP_PRE, OMPT_LOOP_BEFORE_TASK, 
+              OMPT_LOOP_POST)
 PARALLEL_LOOP(KMP_EXPAND_NAME(KMP_API_NAME_GOMP_PARALLEL_LOOP_RUNTIME),
-              kmp_sch_runtime, OMPT_LOOP_PRE, OMPT_LOOP_POST)
+              kmp_sch_runtime, OMPT_LOOP_PRE, OMPT_LOOP_BEFORE_TASK, 
+              OMPT_LOOP_POST)
 
 void KMP_EXPAND_NAME(KMP_API_NAME_GOMP_TASKGROUP_START)(void) {
   int gtid = __kmp_entry_gtid();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57469.184356.patch
Type: text/x-patch
Size: 3274 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20190130/8119cfd7/attachment.bin>


More information about the Openmp-commits mailing list