[Openmp-commits] [openmp] r264266 - [OMPT] Fix parallel_id and task_id in loop_end with schedule static

Jonas Hahnfeld via Openmp-commits openmp-commits at lists.llvm.org
Thu Mar 24 05:52:20 PDT 2016


Author: hahnfeld
Date: Thu Mar 24 07:52:20 2016
New Revision: 264266

URL: http://llvm.org/viewvc/llvm-project?rev=264266&view=rev
Log:
[OMPT] Fix parallel_id and task_id in loop_end with schedule static

For serialized parallel regions, wrong ids were reported. Now the same code is
used as in kmp_dispatch.cpp which emits the correct ids.

Differential Revision: http://reviews.llvm.org/D18348

Added:
    openmp/trunk/runtime/test/ompt/worksharing/
    openmp/trunk/runtime/test/ompt/worksharing/for/
    openmp/trunk/runtime/test/ompt/worksharing/for/auto.c
    openmp/trunk/runtime/test/ompt/worksharing/for/auto_serialized.c
    openmp/trunk/runtime/test/ompt/worksharing/for/base.h
    openmp/trunk/runtime/test/ompt/worksharing/for/base_serialized.h
    openmp/trunk/runtime/test/ompt/worksharing/for/dynamic.c
    openmp/trunk/runtime/test/ompt/worksharing/for/dynamic_serialized.c
    openmp/trunk/runtime/test/ompt/worksharing/for/guided.c
    openmp/trunk/runtime/test/ompt/worksharing/for/guided_serialized.c
    openmp/trunk/runtime/test/ompt/worksharing/for/runtime.c
    openmp/trunk/runtime/test/ompt/worksharing/for/runtime_serialized.c
    openmp/trunk/runtime/test/ompt/worksharing/for/static.c
    openmp/trunk/runtime/test/ompt/worksharing/for/static_serialized.c
Modified:
    openmp/trunk/runtime/src/kmp_csupport.c
    openmp/trunk/runtime/test/lit.cfg
    openmp/trunk/runtime/test/ompt/callback.h

Modified: openmp/trunk/runtime/src/kmp_csupport.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_csupport.c?rev=264266&r1=264265&r2=264266&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_csupport.c (original)
+++ openmp/trunk/runtime/src/kmp_csupport.c Thu Mar 24 07:52:20 2016
@@ -1559,13 +1559,10 @@ __kmpc_for_static_fini( ident_t *loc, km
 #if OMPT_SUPPORT && OMPT_TRACE
     if (ompt_enabled &&
         ompt_callbacks.ompt_callback(ompt_event_loop_end)) {
-        kmp_info_t *this_thr = __kmp_threads[ global_tid ];
-        kmp_team_t *team     = this_thr -> th.th_team;
-        int tid = __kmp_tid_from_gtid( global_tid );
-
+        ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
+        ompt_task_info_t *task_info = __ompt_get_taskinfo(0);
         ompt_callbacks.ompt_callback(ompt_event_loop_end)(
-            team->t.ompt_team_info.parallel_id,
-            team->t.t_implicit_task_taskdata[tid].ompt_task_info.task_id);
+            team_info->parallel_id, task_info->task_id);
     }
 #endif
 

Modified: openmp/trunk/runtime/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/lit.cfg?rev=264266&r1=264265&r2=264266&view=diff
==============================================================================
--- openmp/trunk/runtime/test/lit.cfg (original)
+++ openmp/trunk/runtime/test/lit.cfg Thu Mar 24 07:52:20 2016
@@ -2,6 +2,7 @@
 # Configuration file for the 'lit' test runner.
 
 import os
+import re
 import subprocess
 import lit.formats
 
@@ -47,6 +48,11 @@ config.test_cflags = config.test_openmp_
     " -L " + config.library_dir + \
     " " + config.test_extra_cflags
 
+# Allow XFAIL to work
+config.target_triple = [ ]
+if re.search('gcc', config.test_compiler) is not None:
+    config.available_features.add('gcc')
+
 # Setup environment to find dynamic library at runtime
 append_dynamic_library_path(config.library_dir)
 if config.using_hwloc:

Modified: openmp/trunk/runtime/test/ompt/callback.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/callback.h?rev=264266&r1=264265&r2=264266&view=diff
==============================================================================
--- openmp/trunk/runtime/test/ompt/callback.h (original)
+++ openmp/trunk/runtime/test/ompt/callback.h Thu Mar 24 07:52:20 2016
@@ -44,6 +44,23 @@ on_ompt_event_implicit_task_end(
 }
 
 static void
+on_ompt_event_loop_begin(
+  ompt_parallel_id_t parallel_id,
+  ompt_task_id_t parent_task_id,
+  void *workshare_function)
+{
+  printf("%" PRIu64 ": ompt_event_loop_begin: parallel_id=%" PRIu64 ", parent_task_id=%" PRIu64 ", workshare_function=%p\n", ompt_get_thread_id(), parallel_id, parent_task_id, workshare_function);
+}
+
+static void
+on_ompt_event_loop_end(
+  ompt_parallel_id_t parallel_id,
+  ompt_task_id_t task_id)
+{
+  printf("%" PRIu64 ": ompt_event_loop_end: parallel_id=%" PRIu64 ", task_id=%" PRIu64 "\n", ompt_get_thread_id(), parallel_id, task_id);
+}
+
+static void
 on_ompt_event_parallel_begin(
   ompt_task_id_t parent_task_id,
   ompt_frame_t *parent_task_frame,
@@ -79,6 +96,8 @@ void ompt_initialize(
   ompt_set_callback(ompt_event_barrier_end, (ompt_callback_t) &on_ompt_event_barrier_end);
   ompt_set_callback(ompt_event_implicit_task_begin, (ompt_callback_t) &on_ompt_event_implicit_task_begin);
   ompt_set_callback(ompt_event_implicit_task_end, (ompt_callback_t) &on_ompt_event_implicit_task_end);
+  ompt_set_callback(ompt_event_loop_begin, (ompt_callback_t) &on_ompt_event_loop_begin);
+  ompt_set_callback(ompt_event_loop_end, (ompt_callback_t) &on_ompt_event_loop_end);
   ompt_set_callback(ompt_event_parallel_begin, (ompt_callback_t) &on_ompt_event_parallel_begin);
   ompt_set_callback(ompt_event_parallel_end, (ompt_callback_t) &on_ompt_event_parallel_end);
 }

Added: openmp/trunk/runtime/test/ompt/worksharing/for/auto.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/worksharing/for/auto.c?rev=264266&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/worksharing/for/auto.c (added)
+++ openmp/trunk/runtime/test/ompt/worksharing/for/auto.c Thu Mar 24 07:52:20 2016
@@ -0,0 +1,7 @@
+// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base.h
+// REQUIRES: ompt
+// GCC doesn't call runtime for auto = static schedule
+// XFAIL: gcc
+
+#define SCHEDULE auto
+#include "base.h"

Added: openmp/trunk/runtime/test/ompt/worksharing/for/auto_serialized.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/worksharing/for/auto_serialized.c?rev=264266&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/worksharing/for/auto_serialized.c (added)
+++ openmp/trunk/runtime/test/ompt/worksharing/for/auto_serialized.c Thu Mar 24 07:52:20 2016
@@ -0,0 +1,7 @@
+// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_serialized.h
+// REQUIRES: ompt
+// GCC doesn't call runtime for auto = static schedule
+// XFAIL: gcc
+
+#define SCHEDULE auto
+#include "base_serialized.h"

Added: openmp/trunk/runtime/test/ompt/worksharing/for/base.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/worksharing/for/base.h?rev=264266&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/worksharing/for/base.h (added)
+++ openmp/trunk/runtime/test/ompt/worksharing/for/base.h Thu Mar 24 07:52:20 2016
@@ -0,0 +1,35 @@
+#include "callback.h"
+#include <omp.h>
+
+int main()
+{
+  unsigned int i;
+
+  #pragma omp parallel for num_threads(4) schedule(SCHEDULE)
+  for (i = 0; i < 4; i++) {
+  }
+
+  // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin: parent_task_id={{[0-9]+}}, parent_task_frame=0x{{[0-f]+}}, parallel_id=[[PARALLEL_ID:[0-9]+]], requested_team_size=4, parallel_function=0x{{[0-f]+}}, invoker={{.*}}
+
+  // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
+  // CHECK: {{^}}[[MASTER_ID]]: ompt_event_loop_begin: parallel_id=[[PARALLEL_ID]], parent_task_id=[[IMPLICIT_TASK_ID]], workshare_function=0x{{[0-f]+}}
+  // CHECK: {{^}}[[MASTER_ID]]: ompt_event_loop_end: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
+  // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
+
+  // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
+  // CHECK: {{^}}[[THREAD_ID]]: ompt_event_loop_begin: parallel_id=[[PARALLEL_ID]], parent_task_id=[[IMPLICIT_TASK_ID]], workshare_function=0x{{[0-f]+}}
+  // CHECK: {{^}}[[THREAD_ID]]: ompt_event_loop_end: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
+  // CHECK: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
+
+  // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
+  // CHECK: {{^}}[[THREAD_ID]]: ompt_event_loop_begin: parallel_id=[[PARALLEL_ID]], parent_task_id=[[IMPLICIT_TASK_ID]], workshare_function=0x{{[0-f]+}}
+  // CHECK: {{^}}[[THREAD_ID]]: ompt_event_loop_end: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
+  // CHECK: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
+
+  // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
+  // CHECK: {{^}}[[THREAD_ID]]: ompt_event_loop_begin: parallel_id=[[PARALLEL_ID]], parent_task_id=[[IMPLICIT_TASK_ID]], workshare_function=0x{{[0-f]+}}
+  // CHECK: {{^}}[[THREAD_ID]]: ompt_event_loop_end: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
+  // CHECK: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
+
+  return 0;
+}

Added: openmp/trunk/runtime/test/ompt/worksharing/for/base_serialized.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/worksharing/for/base_serialized.h?rev=264266&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/worksharing/for/base_serialized.h (added)
+++ openmp/trunk/runtime/test/ompt/worksharing/for/base_serialized.h Thu Mar 24 07:52:20 2016
@@ -0,0 +1,20 @@
+#include "callback.h"
+#include <omp.h>
+
+int main()
+{
+  unsigned int i;
+
+  #pragma omp parallel for num_threads(1) schedule(SCHEDULE)
+  for (i = 0; i < 1; i++) {
+  }
+
+  // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin: parent_task_id=[[PARENT_TASK_ID:[0-9]+]], parent_task_frame=0x{{[0-f]+}}, parallel_id=[[PARALLEL_ID:[0-9]+]], requested_team_size=1, parallel_function=0x{{[0-f]+}}, invoker={{.+}}
+
+  // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
+  // CHECK: {{^}}[[MASTER_ID]]: ompt_event_loop_begin: parallel_id=[[PARALLEL_ID]], parent_task_id=[[IMPLICIT_TASK_ID]], workshare_function=0x{{[0-f]+}}
+  // CHECK: {{^}}[[MASTER_ID]]: ompt_event_loop_end: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
+  // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
+
+  return 0;
+}

Added: openmp/trunk/runtime/test/ompt/worksharing/for/dynamic.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/worksharing/for/dynamic.c?rev=264266&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/worksharing/for/dynamic.c (added)
+++ openmp/trunk/runtime/test/ompt/worksharing/for/dynamic.c Thu Mar 24 07:52:20 2016
@@ -0,0 +1,5 @@
+// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base.h
+// REQUIRES: ompt
+
+#define SCHEDULE dynamic
+#include "base.h"

Added: openmp/trunk/runtime/test/ompt/worksharing/for/dynamic_serialized.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/worksharing/for/dynamic_serialized.c?rev=264266&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/worksharing/for/dynamic_serialized.c (added)
+++ openmp/trunk/runtime/test/ompt/worksharing/for/dynamic_serialized.c Thu Mar 24 07:52:20 2016
@@ -0,0 +1,5 @@
+// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_serialized.h
+// REQUIRES: ompt
+
+#define SCHEDULE dynamic
+#include "base_serialized.h"

Added: openmp/trunk/runtime/test/ompt/worksharing/for/guided.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/worksharing/for/guided.c?rev=264266&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/worksharing/for/guided.c (added)
+++ openmp/trunk/runtime/test/ompt/worksharing/for/guided.c Thu Mar 24 07:52:20 2016
@@ -0,0 +1,5 @@
+// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base.h
+// REQUIRES: ompt
+
+#define SCHEDULE guided
+#include "base.h"

Added: openmp/trunk/runtime/test/ompt/worksharing/for/guided_serialized.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/worksharing/for/guided_serialized.c?rev=264266&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/worksharing/for/guided_serialized.c (added)
+++ openmp/trunk/runtime/test/ompt/worksharing/for/guided_serialized.c Thu Mar 24 07:52:20 2016
@@ -0,0 +1,5 @@
+// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_serialized.h
+// REQUIRES: ompt
+
+#define SCHEDULE guided
+#include "base_serialized.h"

Added: openmp/trunk/runtime/test/ompt/worksharing/for/runtime.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/worksharing/for/runtime.c?rev=264266&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/worksharing/for/runtime.c (added)
+++ openmp/trunk/runtime/test/ompt/worksharing/for/runtime.c Thu Mar 24 07:52:20 2016
@@ -0,0 +1,5 @@
+// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base.h
+// REQUIRES: ompt
+
+#define SCHEDULE runtime
+#include "base.h"

Added: openmp/trunk/runtime/test/ompt/worksharing/for/runtime_serialized.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/worksharing/for/runtime_serialized.c?rev=264266&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/worksharing/for/runtime_serialized.c (added)
+++ openmp/trunk/runtime/test/ompt/worksharing/for/runtime_serialized.c Thu Mar 24 07:52:20 2016
@@ -0,0 +1,5 @@
+// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_serialized.h
+// REQUIRES: ompt
+
+#define SCHEDULE runtime
+#include "base_serialized.h"

Added: openmp/trunk/runtime/test/ompt/worksharing/for/static.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/worksharing/for/static.c?rev=264266&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/worksharing/for/static.c (added)
+++ openmp/trunk/runtime/test/ompt/worksharing/for/static.c Thu Mar 24 07:52:20 2016
@@ -0,0 +1,7 @@
+// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base.h
+// REQUIRES: ompt
+// GCC doesn't call runtime for static schedule
+// XFAIL: gcc
+
+#define SCHEDULE static
+#include "base.h"

Added: openmp/trunk/runtime/test/ompt/worksharing/for/static_serialized.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/worksharing/for/static_serialized.c?rev=264266&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/worksharing/for/static_serialized.c (added)
+++ openmp/trunk/runtime/test/ompt/worksharing/for/static_serialized.c Thu Mar 24 07:52:20 2016
@@ -0,0 +1,7 @@
+// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %S/base_serialized.h
+// REQUIRES: ompt
+// GCC doesn't call runtime for static schedule
+// XFAIL: gcc
+
+#define SCHEDULE static
+#include "base_serialized.h"




More information about the Openmp-commits mailing list