[Openmp-commits] [PATCH] D39890: [OMPT] Fix assertion for OpenMP code generated with outdated compilers

Joachim Protze via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Nov 10 01:50:27 PST 2017


protze.joachim created this revision.

For up-to-date compilers, this assertion is reasonable, but it breaks compatibility with the typical compiler installed on most systems.
This patch changes the default value to what we had when there was no compiler support. A warning about the outdated compiler is printed during runtime, when this point is reached.

Alternative solution:
Set a configure flag that explicitly asks for backwards compatibility and leave the assert there.


https://reviews.llvm.org/D39890

Files:
  runtime/src/kmp_csupport.cpp
  runtime/src/kmp_sched.cpp


Index: runtime/src/kmp_sched.cpp
===================================================================
--- runtime/src/kmp_sched.cpp
+++ runtime/src/kmp_sched.cpp
@@ -23,6 +23,7 @@
 #include "kmp_itt.h"
 #include "kmp_stats.h"
 #include "kmp_str.h"
+#include "kmp_io.h"
 
 #if OMPT_SUPPORT
 #include "ompt-specific.h"
@@ -67,8 +68,9 @@
   ompt_team_info_t *team_info = NULL;
   ompt_task_info_t *task_info = NULL;
   ompt_work_type_t ompt_work_type;
+  static __thread int singleWarning=0;
 
-  if (ompt_enabled.enabled) {
+  if (ompt_enabled.ompt_callback_work) {
     // Only fully initialize variables needed by OMPT if OMPT is enabled.
     team_info = __ompt_get_teaminfo(0, NULL);
     task_info = __ompt_get_task_info_object(0);
@@ -81,8 +83,13 @@
       } else if ((loc->flags & KMP_IDENT_WORK_DISTRIBUTE) != 0) {
         ompt_work_type = ompt_work_distribute;
       } else {
-        KMP_ASSERT2(0,
-                    "__kmpc_for_static_init: can't determine workshare type");
+        ompt_work_type = ompt_work_loop;
+        if(!singleWarning){
+          __kmp_printf("OMPT Warning: The used compiler is outdated! The provided kind of worksharing event in OMPT is not reliable.\n");
+          singleWarning=1;
+        }
+//        KMP_ASSERT2(0,
+//                    "__kmpc_for_static_init: can't determine workshare type");
       }
       KMP_DEBUG_ASSERT(ompt_work_type);
     }
Index: runtime/src/kmp_csupport.cpp
===================================================================
--- runtime/src/kmp_csupport.cpp
+++ runtime/src/kmp_csupport.cpp
@@ -18,6 +18,7 @@
 #include "kmp_itt.h"
 #include "kmp_lock.h"
 #include "kmp_stats.h"
+#include "kmp_io.h"
 
 #if OMPT_SUPPORT
 #include "ompt-specific.h"
@@ -1761,17 +1762,23 @@
     ompt_work_type_t ompt_work_type;
     ompt_team_info_t *team_info = __ompt_get_teaminfo(0, NULL);
     ompt_task_info_t *task_info = __ompt_get_task_info_object(0);
-    // Determine workshare type
+    static __thread int singleWarning=0;
+      // Determine workshare type
     if (loc != NULL) {
       if ((loc->flags & KMP_IDENT_WORK_LOOP) != 0) {
         ompt_work_type = ompt_work_loop;
       } else if ((loc->flags & KMP_IDENT_WORK_SECTIONS) != 0) {
         ompt_work_type = ompt_work_sections;
       } else if ((loc->flags & KMP_IDENT_WORK_DISTRIBUTE) != 0) {
         ompt_work_type = ompt_work_distribute;
       } else {
-        KMP_ASSERT2(0,
-                    "__kmpc_for_static_fini: can't determine workshare type");
+        ompt_work_type = ompt_work_loop;
+        if(!singleWarning){
+          __kmp_printf("OMPT Warning: The used compiler is outdated! The provided kind of worksharing event in OMPT is not reliable.\n");
+          singleWarning=1;
+        }
+//        KMP_ASSERT2(0,
+//                    "__kmpc_for_static_fini: can't determine workshare type");
       }
       KMP_DEBUG_ASSERT(ompt_work_type);
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39890.122403.patch
Type: text/x-patch
Size: 2912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20171110/3eaadc0b/attachment.bin>


More information about the Openmp-commits mailing list