[Openmp-commits] [PATCH] D47717: [OMPT] Make sure that OMPT is enabled in runtime entry points that access internals of the runtime

Simon Convent via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Jun 4 07:11:56 PDT 2018


sconvent created this revision.
sconvent added reviewers: Hahnfeld, protze.joachim, jlpeyton, hbae, omalyshe.

Make sure that OMPT is enabled in runtime entry points that access internals of the runtime.
Else, return an appropiate value indicating an error or that the data is not available.


https://reviews.llvm.org/D47717

Files:
  runtime/src/ompt-general.cpp
  runtime/src/ompt-specific.cpp


Index: runtime/src/ompt-specific.cpp
===================================================================
--- runtime/src/ompt-specific.cpp
+++ runtime/src/ompt-specific.cpp
@@ -195,7 +195,7 @@
 //----------------------------------------------------------
 
 ompt_data_t *__ompt_get_thread_data_internal() {
-  if (__kmp_get_gtid() >= 0) {
+  if (ompt_enabled.enabled && __kmp_get_gtid() >= 0) {
     kmp_info_t *thread = ompt_get_thread();
     if (thread == NULL)
       return NULL;
@@ -232,7 +232,7 @@
 int __ompt_get_parallel_info_internal(int ancestor_level,
                                       ompt_data_t **parallel_data,
                                       int *team_size) {
-  if (__kmp_get_gtid() >= 0) {
+  if (ompt_enabled.enabled && __kmp_get_gtid() >= 0) {
     ompt_team_info_t *info;
     if (team_size) {
       info = __ompt_get_teaminfo(ancestor_level, team_size);
@@ -331,7 +331,7 @@
                                   omp_frame_t **task_frame,
                                   ompt_data_t **parallel_data,
                                   int *thread_num) {
-  if (__kmp_get_gtid() < 0)
+  if (!ompt_enabled.enabled || __kmp_get_gtid() < 0)
     return 0;
 
   if (ancestor_level < 0)
Index: runtime/src/ompt-general.cpp
===================================================================
--- runtime/src/ompt-general.cpp
+++ runtime/src/ompt-general.cpp
@@ -455,7 +455,7 @@
     if (ompt_event_implementation_status(event_name)) {                        \
       ompt_callback_t mycb =                                                   \
           (ompt_callback_t)ompt_callbacks.ompt_callback(event_name);           \
-      if (mycb) {                                                              \
+      if (ompt_enabled.enabled && ompt_enabled.event_name && mycb) {           \
         *callback = mycb;                                                      \
         return ompt_get_callback_success;                                      \
       }                                                                        \
@@ -573,7 +573,7 @@
 #if !KMP_AFFINITY_SUPPORTED
   return -1;
 #else
-  if (__kmp_get_gtid() < 0)
+  if (!ompt_enabled.enabled || __kmp_get_gtid() < 0)
     return -1;
 
   int gtid;
@@ -594,7 +594,7 @@
 #if !KMP_AFFINITY_SUPPORTED
   return 0;
 #else
-  if (__kmp_get_gtid() < 0)
+  if (!ompt_enabled.enabled || __kmp_get_gtid() < 0)
     return 0;
 
   int i, gtid, place_num, first_place, last_place, start, end;
@@ -630,7 +630,7 @@
 
 OMPT_API_ROUTINE int ompt_get_proc_id(void) {
 #if KMP_OS_LINUX
-  if (__kmp_get_gtid() < 0)
+  if (!ompt_enabled.enabled || __kmp_get_gtid() < 0)
     return -1;
 
   return sched_getcpu();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47717.149756.patch
Type: text/x-patch
Size: 2693 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20180604/84758881/attachment-0001.bin>


More information about the Openmp-commits mailing list