Skip to content

Commit be063d4

Browse files
dhruvachakronlieb
authored andcommitted
[OpenMP] [OMPT] Fix build failure with target OMPT disabled.
If any of the macros from OmptCommonDefs.h is used, the source must either guard it with OMPT_SUPPORT defined or include the common defs header file unconditionally. Otherwise, the macros may not resolve correctly, leading to build failures. Change-Id: I878b4cc60d0586654340392ca257032f4738e6e2
1 parent 88462e1 commit be063d4

File tree

10 files changed

+19
-18
lines changed

10 files changed

+19
-18
lines changed

offload/include/OmptTracingBuffer.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#ifndef OPENMP_LIBOMPTARGET_OMPTTRACINGBUFFER_H
1414
#define OPENMP_LIBOMPTARGET_OMPTTRACINGBUFFER_H
1515

16+
#ifdef OMPT_SUPPORT
17+
1618
#include <atomic>
1719
#include <cassert>
1820
#include <condition_variable>
@@ -38,15 +40,6 @@
3840
// thread-wait-tracker is 32 bits in length.
3941
#define OMPT_NUM_HELPER_THREADS 1
4042

41-
#ifdef OMPT_SUPPORT
42-
#define OMPT_TRACING_IF_ENABLED(stmts) \
43-
do { \
44-
stmts \
45-
} while (0)
46-
#else
47-
#define OMPT_TRACING_IF_ENABLED(stmts)
48-
#endif
49-
5043
/*
5144
* Buffer manager for trace records generated by OpenMP master and
5245
* worker threads. During device init, a tool may register a
@@ -397,4 +390,6 @@ class OmptTracingBufferMgr {
397390
int flushAllBuffers(int DeviceId);
398391
};
399392

393+
#endif // OMPT_SUPPORT
394+
400395
#endif // OPENMP_LIBOMPTARGET_OMPTTRACINGBUFFER_H

offload/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <unistd.h>
2222
#include <unordered_map>
2323

24+
#include "OmptCommonDefs.h"
25+
2426
#include "Shared/Debug.h"
2527
#include "Shared/Environment.h"
2628
#include "Shared/Utils.h"
@@ -3121,7 +3123,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
31213123

31223124
// For large transfers use synchronous behavior.
31233125
// If OMPT is enabled or synchronous behavior is explicitly requested:
3124-
if (ompt::TracingActive || OMPX_ForceSyncRegions ||
3126+
if (OMPT_IF_BUILT(ompt::TracingActive ||) OMPX_ForceSyncRegions ||
31253127
Size >= OMPX_MaxAsyncCopyBytes) {
31263128
if (AsyncInfoWrapper.hasQueue())
31273129
if (auto Err = synchronize(AsyncInfoWrapper))
@@ -3194,7 +3196,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
31943196

31953197
// For large transfers use synchronous behavior.
31963198
// If OMPT is enabled or synchronous behavior is explicitly requested:
3197-
if (ompt::TracingActive || OMPX_ForceSyncRegions ||
3199+
if (OMPT_IF_BUILT(ompt::TracingActive ||) OMPX_ForceSyncRegions ||
31983200
Size >= OMPX_MaxAsyncCopyBytes) {
31993201
if (AsyncInfoWrapper.hasQueue())
32003202
if (auto Err = synchronize(AsyncInfoWrapper))
@@ -3249,7 +3251,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
32493251

32503252
// For large transfers use synchronous behavior.
32513253
// If OMPT is enabled or synchronous behavior is explicitly requested:
3252-
if (ompt::TracingActive || OMPX_ForceSyncRegions ||
3254+
if (OMPT_IF_BUILT(ompt::TracingActive ||) OMPX_ForceSyncRegions ||
32533255
Size >= OMPX_MaxAsyncCopyBytes) {
32543256
if (AsyncInfoWrapper.hasQueue())
32553257
if (auto Err = synchronize(AsyncInfoWrapper))

offload/plugins-nextgen/common/src/PluginInterface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
//===----------------------------------------------------------------------===//
1010

1111
#include "PluginInterface.h"
12+
#include "OmptCommonDefs.h"
1213

1314
#include "Shared/APITypes.h"
1415
#include "Shared/Debug.h"

offload/src/LegacyAPI.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "OmptCommonDefs.h"
1314
#include "OpenMP/OMPT/Interface.h"
1415
#include "omptarget.h"
1516
#include "private.h"

offload/src/OmptTracingBuffer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#ifdef OMPT_SUPPORT
14+
1315
#include "Shared/Debug.h"
1416
#include "OmptTracing.h"
1517
#include "OmptTracingBuffer.h"
@@ -742,3 +744,4 @@ OmptTracingBufferMgr::OmptTracingBufferMgr() {
742744
// no need to hold locks for init() since object is getting constructed here
743745
init();
744746
}
747+
#endif

offload/src/OpenMP/API.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "OmptCommonDefs.h"
1314
#include "PluginManager.h"
1415
#include "device.h"
1516
#include "omptarget.h"

offload/src/OpenMP/OMPT/Callback.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@
1212

1313
#ifndef OMPT_SUPPORT
1414

15-
#include "Shared/Debug.h"
16-
#include "omp-tools.h"
17-
#include "private.h"
18-
19-
#include "llvm/Support/DynamicLibrary.h"
2015
extern "C" {
2116
/// Dummy definition when OMPT is disabled
2217
void ompt_libomptarget_connect() {}

offload/src/PluginManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "PluginManager.h"
14+
#include "OmptCommonDefs.h"
1415
#include "OmptTracing.h"
1516
#include "OpenMP/OMPT/Callback.h"
1617
#include "Shared/Debug.h"
@@ -260,7 +261,7 @@ void PluginManager::unregisterLib(__tgt_bin_desc *Desc) {
260261

261262
// Flush in-process OMPT trace records and shut down helper threads
262263
// before unloading the library.
263-
OMPT_TRACING_IF_ENABLED(llvm::omp::target::ompt::TraceRecordManager
264+
OMPT_IF_TRACING_ENABLED(llvm::omp::target::ompt::TraceRecordManager
264265
.flushAndShutdownHelperThreads(););
265266

266267
PM->RTLsMtx.lock();

offload/src/device.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "device.h"
1414
#include "OffloadEntry.h"
15+
#include "OmptCommonDefs.h"
1516
#include "OmptTracing.h"
1617
#include "OpenMP/Mapping.h"
1718
#include "OpenMP/OMPT/Callback.h"

offload/src/interface.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "OpenMP/OMPT/Interface.h"
15+
#include "OmptCommonDefs.h"
1516
#include "OpenMP/OMPT/Callback.h"
1617
#include "PluginManager.h"
1718
#include "private.h"

0 commit comments

Comments
 (0)