[Openmp-commits] [PATCH] D41171: [OMPT] Handle null pointer correctly in set_callback

Simon Convent via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Dec 14 03:08:35 PST 2017


sconvent updated this revision to Diff 126921.
sconvent added a comment.

Implemented suggestion


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,30 @@
+// RUN: %libomp-compile-and-run | FileCheck %s
+// REQUIRES: ompt
+#include "callback.h"
+#include <omp.h>
+
+int main()
+{
+  int x = 0;
+  #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.126921.patch
Type: text/x-patch
Size: 2000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20171214/94c7c664/attachment.bin>


More information about the Openmp-commits mailing list