Skip to content

Commit 2dbc532

Browse files
committed
[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
1 parent 5554451 commit 2dbc532

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

openmp/libomptarget/include/OmptCallback.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "omp-tools.h"
2020

21+
#pragma push_macro("DEBUG_PREFIX")
22+
#undef DEBUG_PREFIX
2123
#define DEBUG_PREFIX "OMPT"
2224

2325
#define FOREACH_OMPT_TARGET_CALLBACK(macro) \
@@ -82,4 +84,6 @@ void connectLibrary();
8284

8385
#endif // OMPT_SUPPORT
8486

87+
#pragma pop_macro("DEBUG_PREFIX")
88+
8589
#endif // _OMPTCALLBACK_H

openmp/libomptarget/include/OmptConnector.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
#include "Debug.h"
2828
#include "omptarget.h"
2929

30+
#pragma push_macro("DEBUG_PREFIX")
31+
#undef DEBUG_PREFIX
3032
#define DEBUG_PREFIX "OMPT"
31-
#define LIBOMPTARGET_STRINGIFY(s) #s
3233

3334
/// Type for the function to be invoked for connecting two libraries.
3435
typedef void (*OmptConnectRtnTy)(ompt_start_tool_result_t *result);
@@ -103,4 +104,6 @@ class OmptLibraryConnectorTy {
103104

104105
#endif // OMPT_SUPPORT
105106

107+
#pragma pop_macro("DEBUG_PREFIX")
108+
106109
#endif // _OMPTCONNECTOR_H

openmp/libomptarget/src/OmptCallback.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#include "OmptCallback.h"
2323
#include "OmptConnector.h"
2424

25+
#undef DEBUG_PREFIX
26+
#define DEBUG_PREFIX "OMPT"
27+
2528
using namespace llvm::omp::target::ompt;
2629

2730
// Define OMPT callback functions (bound to actual callbacks later on)
@@ -64,10 +67,10 @@ ompt_function_lookup_t llvm::omp::target::ompt::lookupCallbackByName = nullptr;
6467
int llvm::omp::target::ompt::initializeLibrary(ompt_function_lookup_t lookup,
6568
int initial_device_num,
6669
ompt_data_t *tool_data) {
67-
DP("OMPT: Executing initializeLibrary (libomp)\n");
70+
DP("Executing initializeLibrary (libomp)\n");
6871
#define bindOmptFunctionName(OmptFunction, DestinationFunction) \
6972
DestinationFunction = (OmptFunction##_t)lookup(#OmptFunction); \
70-
DP("OMPT: initializeLibrary (libomp) bound %s=%p\n", #DestinationFunction, \
73+
DP("initializeLibrary (libomp) bound %s=%p\n", #DestinationFunction, \
7174
((void *)(uint64_t)DestinationFunction));
7275

7376
bindOmptFunctionName(ompt_get_callback, lookupCallbackByCode);
@@ -87,15 +90,15 @@ int llvm::omp::target::ompt::initializeLibrary(ompt_function_lookup_t lookup,
8790
}
8891

8992
void llvm::omp::target::ompt::finalizeLibrary(ompt_data_t *data) {
90-
DP("OMPT: Executing finalizeLibrary (libomp)\n");
93+
DP("Executing finalizeLibrary (libomp)\n");
9194
// Before disabling OMPT, call the (plugin) finalizations that were registered
9295
// with this library
9396
LibraryFinalizer->finalize();
9497
delete LibraryFinalizer;
9598
}
9699

97100
void llvm::omp::target::ompt::connectLibrary() {
98-
DP("OMPT: Entering connectLibrary (libomp)\n");
101+
DP("Entering connectLibrary (libomp)\n");
99102
// Connect with libomp
100103
static OmptLibraryConnectorTy LibompConnector("libomp");
101104
static ompt_start_tool_result_t OmptResult;
@@ -118,13 +121,13 @@ void llvm::omp::target::ompt::connectLibrary() {
118121
FOREACH_OMPT_EMI_EVENT(bindOmptCallback)
119122
#undef bindOmptCallback
120123

121-
DP("OMPT: Exiting connectLibrary (libomp)\n");
124+
DP("Exiting connectLibrary (libomp)\n");
122125
}
123126

124127
extern "C" {
125128
/// Used for connecting libomptarget with a plugin
126129
void ompt_libomptarget_connect(ompt_start_tool_result_t *result) {
127-
DP("OMPT: Enter ompt_libomptarget_connect\n");
130+
DP("Enter ompt_libomptarget_connect\n");
128131
if (result && LibraryFinalizer) {
129132
// Cache each fini function, so that they can be invoked on exit
130133
LibraryFinalizer->registerRtl(result->finalize);
@@ -134,7 +137,7 @@ void ompt_libomptarget_connect(ompt_start_tool_result_t *result) {
134137
result->initialize(lookupCallbackByName,
135138
/* initial_device_num */ 0, /* tool_data */ nullptr);
136139
}
137-
DP("OMPT: Leave ompt_libomptarget_connect\n");
140+
DP("Leave ompt_libomptarget_connect\n");
138141
}
139142
}
140143
#else

0 commit comments

Comments
 (0)