From 2dbc53267274177f754fcb7470a9ebd4ee9bcbda Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Fri, 14 Jul 2023 12:36:00 -0500 Subject: [PATCH] [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 --- openmp/libomptarget/include/OmptCallback.h | 4 ++++ openmp/libomptarget/include/OmptConnector.h | 5 ++++- openmp/libomptarget/src/OmptCallback.cpp | 17 ++++++++++------- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/openmp/libomptarget/include/OmptCallback.h b/openmp/libomptarget/include/OmptCallback.h index 1393df9d91f3..dcee2a65b62b 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 c0191a207c5a..75473b8dda48 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 @@ private: #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 cde310236e0e..36fb273c2e69 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