Index: runtime/src/ompt-general.cpp =================================================================== --- runtime/src/ompt-general.cpp +++ runtime/src/ompt-general.cpp @@ -411,9 +411,15 @@ case event_name: \ if (ompt_event_implementation_status(event_name)) { \ ompt_callbacks.ompt_callback(event_name) = (callback_type)callback; \ - ompt_enabled.event_name = 1; \ + if (callback) \ + ompt_enabled.event_name = 1; \ + else \ + ompt_enabled.event_name = 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) 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 + +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; +}