[Openmp-commits] [openmp] r252173 - Improve OMPT initialization code

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Thu Nov 5 08:54:55 PST 2015


Author: jlpeyton
Date: Thu Nov  5 10:54:55 2015
New Revision: 252173

URL: http://llvm.org/viewvc/llvm-project?rev=252173&view=rev
Log:
Improve OMPT initialization code

Use of #ifdef OMPT_DEBUG was causing messages to be generated under normal
operation when the OpenMP library was compiled with KMP_DEBUG enabled.
Elsewhere, KMP_DEBUG evaluates assertions, but never produces messages during
normal operation. To avoid this inconsistency, set OMPT_DEBUG using a cmake
variable LIBOMP_OMPT_DEBUG.

While I was editing the associated ompt-specific.h and ompt-general.c files,
make the spacing and comments consistent.

Patch by John Mellor-Crummey

Differential Revision: http://reviews.llvm.org/D14355

Modified:
    openmp/trunk/runtime/CMakeLists.txt
    openmp/trunk/runtime/src/kmp_config.h.cmake
    openmp/trunk/runtime/src/ompt-general.c
    openmp/trunk/runtime/src/ompt-specific.h

Modified: openmp/trunk/runtime/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/CMakeLists.txt?rev=252173&r1=252172&r2=252173&view=diff
==============================================================================
--- openmp/trunk/runtime/CMakeLists.txt (original)
+++ openmp/trunk/runtime/CMakeLists.txt Thu Nov  5 10:54:55 2015
@@ -273,6 +273,8 @@ if(LIBOMP_STATS)
 endif()
 
 # OMPT-support
+set(LIBOMP_OMPT_DEBUG FALSE CACHE BOOL
+  "Trace OMPT initialization?")
 set(LIBOMP_OMPT_SUPPORT FALSE CACHE BOOL
   "OMPT-support?")
 set(LIBOMP_OMPT_BLAME TRUE CACHE BOOL

Modified: openmp/trunk/runtime/src/kmp_config.h.cmake
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_config.h.cmake?rev=252173&r1=252172&r2=252173&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_config.h.cmake (original)
+++ openmp/trunk/runtime/src/kmp_config.h.cmake Thu Nov  5 10:54:55 2015
@@ -35,6 +35,8 @@
 #define KMP_STATS_ENABLED LIBOMP_STATS
 #cmakedefine01 LIBOMP_USE_DEBUGGER
 #define USE_DEBUGGER LIBOMP_USE_DEBUGGER
+#cmakedefine01 LIBOMP_OMPT_DEBUG
+#define OMPT_DEBUG LIBOMP_OMPT_DEBUG
 #cmakedefine01 LIBOMP_OMPT_SUPPORT
 #define OMPT_SUPPORT LIBOMP_OMPT_SUPPORT
 #cmakedefine01 LIBOMP_OMPT_BLAME

Modified: openmp/trunk/runtime/src/ompt-general.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/ompt-general.c?rev=252173&r1=252172&r2=252173&view=diff
==============================================================================
--- openmp/trunk/runtime/src/ompt-general.c (original)
+++ openmp/trunk/runtime/src/ompt-general.c Thu Nov  5 10:54:55 2015
@@ -134,31 +134,31 @@ ompt_initialize_t ompt_tool_windows()
 #if OMPT_DEBUG
     printf("ompt_tool_windows(): looking for ompt_tool\n");
 #endif
-    if( !EnumProcessModules( process, modules, NUM_MODULES * sizeof(HMODULE),
-                             &needed ) ) {
+    if (!EnumProcessModules( process, modules, NUM_MODULES * sizeof(HMODULE),
+                              &needed)) {
         // Regardless of the error reason use the stub initialization function
         free(modules);
         return NULL;
     }
     // Check if NUM_MODULES is enough to list all modules
     new_size = needed / sizeof(HMODULE);
-    if( new_size > NUM_MODULES ) {
+    if (new_size > NUM_MODULES) {
 #if OMPT_DEBUG
     printf("ompt_tool_windows(): resize buffer to %d bytes\n", needed);
 #endif
         modules = (HMODULE*)realloc( modules, needed );
         // If resizing failed use the stub function.
-        if( !EnumProcessModules( process, modules, needed, &needed ) ) {
+        if (!EnumProcessModules(process, modules, needed, &needed)) {
             free(modules);
             return NULL;
         }
     }
-    for( i = 0; i < new_size; ++i ) {
+    for (i = 0; i < new_size; ++i) {
         (FARPROC &)ompt_tool_p = GetProcAddress(modules[i], "ompt_tool");
-        if( ompt_tool_p ) {
+        if (ompt_tool_p) {
 #if OMPT_DEBUG
             TCHAR modName[MAX_PATH];
-            if( GetModuleFileName(modules[i], modName, MAX_PATH))
+            if (GetModuleFileName(modules[i], modName, MAX_PATH))
                 printf("ompt_tool_windows(): ompt_tool found in module %s\n",
                        modName);
 #endif
@@ -168,7 +168,7 @@ ompt_initialize_t ompt_tool_windows()
 #if OMPT_DEBUG
         else {
             TCHAR modName[MAX_PATH];
-            if( GetModuleFileName(modules[i], modName, MAX_PATH) )
+            if (GetModuleFileName(modules[i], modName, MAX_PATH))
                 printf("ompt_tool_windows(): ompt_tool not found in module %s\n",
                        modName);
         }
@@ -228,7 +228,7 @@ void ompt_pre_init()
         break;
     }
 #if OMPT_DEBUG
-    printf("ompt_pre_init():ompt_enabled = %d\n", ompt_enabled);
+    printf("ompt_pre_init(): ompt_enabled = %d\n", ompt_enabled);
 #endif
 }
 

Modified: openmp/trunk/runtime/src/ompt-specific.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/ompt-specific.h?rev=252173&r1=252172&r2=252173&view=diff
==============================================================================
--- openmp/trunk/runtime/src/ompt-specific.h (original)
+++ openmp/trunk/runtime/src/ompt-specific.h Thu Nov  5 10:54:55 2015
@@ -3,8 +3,18 @@
 
 #include "kmp.h"
 
+/*****************************************************************************
+ * types
+ ****************************************************************************/
+
 typedef kmp_info_t ompt_thread_t;
 
+
+
+/*****************************************************************************
+ * forward declarations
+ ****************************************************************************/
+
 void __ompt_team_assign_id(kmp_team_t *team, ompt_parallel_id_t ompt_pid);
 void __ompt_thread_assign_wait_id(void *variable);
 
@@ -34,15 +44,17 @@ ompt_task_id_t __ompt_get_task_id_intern
 ompt_frame_t *__ompt_get_task_frame_internal(int depth);
 
 
+
 /*****************************************************************************
  * macros
  ****************************************************************************/
-#define OMPT_DEBUG KMP_DEBUG
+
 #define OMPT_HAVE_WEAK_ATTRIBUTE KMP_HAVE_WEAK_ATTRIBUTE
 #define OMPT_HAVE_PSAPI KMP_HAVE_PSAPI
 #define OMPT_STR_MATCH(haystack, needle) __kmp_str_match(haystack, 0, needle)
 
 
+
 //******************************************************************************
 // inline functions
 //******************************************************************************




More information about the Openmp-commits mailing list