[Openmp-commits] [openmp] r321264 - [OMPT] Handle null pointer in set_callback to improve performance

Joachim Protze via Openmp-commits openmp-commits at lists.llvm.org
Thu Dec 21 05:55:34 PST 2017


Author: jprotze
Date: Thu Dec 21 05:55:34 2017
New Revision: 321264

URL: http://llvm.org/viewvc/llvm-project?rev=321264&view=rev
Log:
[OMPT] Handle null pointer in set_callback to improve performance

We use the bitmap ompt_enabled thoughout the runtime, to avoid loading the
vector of callback functions when testing if specific code should be executed.
Before invoking an event callback function, the pointer is tested for NULL.

This revision resets the corresponding bit in ompt_enabled to 0 if
NULL is passed in set_callback.

Differential Revision: https://reviews.llvm.org/D41171

Modified:
    openmp/trunk/runtime/src/ompt-general.cpp

Modified: openmp/trunk/runtime/src/ompt-general.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/ompt-general.cpp?rev=321264&r1=321263&r2=321264&view=diff
==============================================================================
--- openmp/trunk/runtime/src/ompt-general.cpp (original)
+++ openmp/trunk/runtime/src/ompt-general.cpp Thu Dec 21 05:55:34 2017
@@ -411,9 +411,12 @@ OMPT_API_ROUTINE int ompt_set_callback(o
   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)
 




More information about the Openmp-commits mailing list