From 4fe83593ebc4d3759e2119d6f6b20cfa6bde1910 Mon Sep 17 00:00:00 2001 From: Joachim Protze Date: Thu, 21 Dec 2017 13:55:34 +0000 Subject: [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 llvm-svn: 321264 --- openmp/runtime/src/ompt-general.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'openmp/runtime/src') diff --git a/openmp/runtime/src/ompt-general.cpp b/openmp/runtime/src/ompt-general.cpp index c1e8b0f22eb..9f21214f808 100644 --- a/openmp/runtime/src/ompt-general.cpp +++ b/openmp/runtime/src/ompt-general.cpp @@ -411,9 +411,12 @@ OMPT_API_ROUTINE int ompt_set_callback(ompt_callbacks_t which, 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) -- cgit v1.2.3