[Openmp-commits] [openmp] 2dbc532 - [OMPT] Fix use of 'DEBUG_PREFIX' in the OMPT headers

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Fri Jul 14 13:58:33 PDT 2023


Author: Joseph Huber
Date: 2023-07-14T15:58:24-05:00
New Revision: 2dbc53267274177f754fcb7470a9ebd4ee9bcbda

URL: https://github.com/llvm/llvm-project/commit/2dbc53267274177f754fcb7470a9ebd4ee9bcbda
DIFF: https://github.com/llvm/llvm-project/commit/2dbc53267274177f754fcb7470a9ebd4ee9bcbda.diff

LOG: [OMPT] Fix use of 'DEBUG_PREFIX' in the OMPT headers

This is the only place that defines  this prefix in a header file and
was thus overriding and redefining other users of it. If we must use it
in a header file, at least repsect its old values.

Reviewed By: tianshilei1992

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

Added: 
    

Modified: 
    openmp/libomptarget/include/OmptCallback.h
    openmp/libomptarget/include/OmptConnector.h
    openmp/libomptarget/src/OmptCallback.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/include/OmptCallback.h b/openmp/libomptarget/include/OmptCallback.h
index 1393df9d91f363..dcee2a65b62b8a 100644
--- a/openmp/libomptarget/include/OmptCallback.h
+++ b/openmp/libomptarget/include/OmptCallback.h
@@ -18,6 +18,8 @@
 
 #include "omp-tools.h"
 
+#pragma push_macro("DEBUG_PREFIX")
+#undef DEBUG_PREFIX
 #define DEBUG_PREFIX "OMPT"
 
 #define FOREACH_OMPT_TARGET_CALLBACK(macro)                                    \
@@ -82,4 +84,6 @@ void connectLibrary();
 
 #endif // OMPT_SUPPORT
 
+#pragma pop_macro("DEBUG_PREFIX")
+
 #endif // _OMPTCALLBACK_H

diff  --git a/openmp/libomptarget/include/OmptConnector.h b/openmp/libomptarget/include/OmptConnector.h
index c0191a207c5a4e..75473b8dda486f 100644
--- a/openmp/libomptarget/include/OmptConnector.h
+++ b/openmp/libomptarget/include/OmptConnector.h
@@ -27,8 +27,9 @@
 #include "Debug.h"
 #include "omptarget.h"
 
+#pragma push_macro("DEBUG_PREFIX")
+#undef DEBUG_PREFIX
 #define DEBUG_PREFIX "OMPT"
-#define LIBOMPTARGET_STRINGIFY(s) #s
 
 /// Type for the function to be invoked for connecting two libraries.
 typedef void (*OmptConnectRtnTy)(ompt_start_tool_result_t *result);
@@ -103,4 +104,6 @@ class OmptLibraryConnectorTy {
 
 #endif // OMPT_SUPPORT
 
+#pragma pop_macro("DEBUG_PREFIX")
+
 #endif // _OMPTCONNECTOR_H

diff  --git a/openmp/libomptarget/src/OmptCallback.cpp b/openmp/libomptarget/src/OmptCallback.cpp
index cde310236e0e49..36fb273c2e6952 100644
--- a/openmp/libomptarget/src/OmptCallback.cpp
+++ b/openmp/libomptarget/src/OmptCallback.cpp
@@ -22,6 +22,9 @@
 #include "OmptCallback.h"
 #include "OmptConnector.h"
 
+#undef DEBUG_PREFIX
+#define DEBUG_PREFIX "OMPT"
+
 using namespace llvm::omp::target::ompt;
 
 // Define OMPT callback functions (bound to actual callbacks later on)
@@ -64,10 +67,10 @@ ompt_function_lookup_t llvm::omp::target::ompt::lookupCallbackByName = nullptr;
 int llvm::omp::target::ompt::initializeLibrary(ompt_function_lookup_t lookup,
                                                int initial_device_num,
                                                ompt_data_t *tool_data) {
-  DP("OMPT: Executing initializeLibrary (libomp)\n");
+  DP("Executing initializeLibrary (libomp)\n");
 #define bindOmptFunctionName(OmptFunction, DestinationFunction)                \
   DestinationFunction = (OmptFunction##_t)lookup(#OmptFunction);               \
-  DP("OMPT: initializeLibrary (libomp) bound %s=%p\n", #DestinationFunction,   \
+  DP("initializeLibrary (libomp) bound %s=%p\n", #DestinationFunction,         \
      ((void *)(uint64_t)DestinationFunction));
 
   bindOmptFunctionName(ompt_get_callback, lookupCallbackByCode);
@@ -87,7 +90,7 @@ int llvm::omp::target::ompt::initializeLibrary(ompt_function_lookup_t lookup,
 }
 
 void llvm::omp::target::ompt::finalizeLibrary(ompt_data_t *data) {
-  DP("OMPT: Executing finalizeLibrary (libomp)\n");
+  DP("Executing finalizeLibrary (libomp)\n");
   // Before disabling OMPT, call the (plugin) finalizations that were registered
   // with this library
   LibraryFinalizer->finalize();
@@ -95,7 +98,7 @@ void llvm::omp::target::ompt::finalizeLibrary(ompt_data_t *data) {
 }
 
 void llvm::omp::target::ompt::connectLibrary() {
-  DP("OMPT: Entering connectLibrary (libomp)\n");
+  DP("Entering connectLibrary (libomp)\n");
   // Connect with libomp
   static OmptLibraryConnectorTy LibompConnector("libomp");
   static ompt_start_tool_result_t OmptResult;
@@ -118,13 +121,13 @@ void llvm::omp::target::ompt::connectLibrary() {
   FOREACH_OMPT_EMI_EVENT(bindOmptCallback)
 #undef bindOmptCallback
 
-  DP("OMPT: Exiting connectLibrary (libomp)\n");
+  DP("Exiting connectLibrary (libomp)\n");
 }
 
 extern "C" {
 /// Used for connecting libomptarget with a plugin
 void ompt_libomptarget_connect(ompt_start_tool_result_t *result) {
-  DP("OMPT: Enter ompt_libomptarget_connect\n");
+  DP("Enter ompt_libomptarget_connect\n");
   if (result && LibraryFinalizer) {
     // Cache each fini function, so that they can be invoked on exit
     LibraryFinalizer->registerRtl(result->finalize);
@@ -134,7 +137,7 @@ void ompt_libomptarget_connect(ompt_start_tool_result_t *result) {
     result->initialize(lookupCallbackByName,
                        /* initial_device_num */ 0, /* tool_data */ nullptr);
   }
-  DP("OMPT: Leave ompt_libomptarget_connect\n");
+  DP("Leave ompt_libomptarget_connect\n");
 }
 }
 #else


        


More information about the Openmp-commits mailing list