[Openmp-commits] [PATCH] D41171: [OMPT] Handle null pointer in set_callback to improve performance

Simon Convent via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Dec 21 02:14:57 PST 2017


sconvent updated this revision to Diff 127847.
sconvent retitled this revision from "[OMPT] Handle null pointer correctly in set_callback " to "[OMPT] Handle null pointer in set_callback to improve performance".
sconvent edited the summary of this revision.
sconvent added a comment.

Removed unnecessary definition.

The parallel_begin and parallel_end callbacks can be set independently by my understanding of the spec. So the testcase should be valid.


https://reviews.llvm.org/D41171

Files:
  runtime/src/ompt-general.cpp
  runtime/test/ompt/misc/unset_callback.c


Index: runtime/test/ompt/misc/unset_callback.c
===================================================================
--- /dev/null
+++ runtime/test/ompt/misc/unset_callback.c
@@ -0,0 +1,29 @@
+// RUN: %libomp-compile-and-run | FileCheck %s
+// REQUIRES: ompt
+#include "callback.h"
+#include <omp.h>
+
+int main()
+{
+  #pragma omp parallel num_threads(1)
+  {
+
+  }
+  ompt_set_callback(ompt_callback_parallel_begin, NULL);
+  #pragma omp parallel num_threads(1)
+  {
+
+  }
+
+  // Check if libomp supports the callbacks for this test.
+  // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_idle'
+
+  // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
+
+  // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_parallel_begin:
+  // CHECK: {{^}}[[THREAD_ID]]: ompt_event_parallel_end:
+  // CHECK-NOT: {{^}}[[THREAD_ID]]: ompt_event_parallel_begin:
+  // CHECK: {{^}}[[THREAD_ID]]: ompt_event_parallel_end:
+
+  return 0;
+}
Index: runtime/src/ompt-general.cpp
===================================================================
--- runtime/src/ompt-general.cpp
+++ runtime/src/ompt-general.cpp
@@ -411,9 +411,12 @@
   case event_name:                                                             \
     if (ompt_event_implementation_status(event_name)) {                        \
       ompt_callbacks.ompt_callback(event_name) = (callback_type)callback;      \
-      ompt_enabled.event_name = 1;                                             \
+      ompt_enabled.event_name = (callback != 0);                               \
     }                                                                          \
-    return ompt_event_implementation_status(event_name);
+    if (callback)                                                              \
+      return ompt_event_implementation_status(event_name);                     \
+    else                                                                       \
+      return ompt_set_always;
 
     FOREACH_OMPT_EVENT(ompt_event_macro)
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41171.127847.patch
Type: text/x-patch
Size: 1986 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20171221/daa68159/attachment.bin>


More information about the Openmp-commits mailing list