[OMPT] Fix tool initialization returning 0
authorJoachim Protze <protze@itc.rwth-aachen.de>
Tue, 6 Feb 2018 08:41:27 +0000 (08:41 +0000)
committerJoachim Protze <protze@itc.rwth-aachen.de>
Tue, 6 Feb 2018 08:41:27 +0000 (08:41 +0000)
If tool initialization returns 0, OMPT should not be active. The current
implementation provided some callback invocations in this case.

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

llvm-svn: 324320

openmp/runtime/src/ompt-general.cpp

index 5bc72aa..46d5be5 100644 (file)
@@ -332,6 +332,12 @@ void ompt_post_init() {
     ompt_enabled.enabled = !!ompt_start_tool_result->initialize(
         ompt_fn_lookup, &(ompt_start_tool_result->tool_data));
 
+    if (!ompt_enabled.enabled) {
+      // tool not enabled, zero out the bitmap, and done
+      memset(&ompt_enabled, 0, sizeof(ompt_enabled));
+      return;
+    }
+
     ompt_thread_t *root_thread = ompt_get_thread();
 
     ompt_set_thread_state(root_thread, omp_state_overhead);