Skip to content

Commit 04ae35e

Browse files
committed
[libomptarget] Always enable time tracing in libomptarget
Previously time tracing features were hidden behind an optional CMake option. This was because `libomptarget` was not based on the LLVM libraries at that time. Now that `libomptarget` is an LLVM library we should be able to freely use the `LLVMSupport` library whenever we want and do not need to guard it in this way. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D132852
1 parent 033a97a commit 04ae35e

File tree

4 files changed

+6
-22
lines changed

4 files changed

+6
-22
lines changed

openmp/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,8 @@ if (APPLE OR WIN32 OR NOT OPENMP_HAVE_STD_CPP17_FLAG)
7171
set(ENABLE_LIBOMPTARGET OFF)
7272
endif()
7373

74-
set(ENABLE_LIBOMPTARGET_PROFILING OFF)
75-
if (ENABLE_LIBOMPTARGET AND NOT LLVM_RUNTIMES_BUILD)
76-
set(ENABLE_LIBOMPTARGET_PROFILING ON)
77-
endif()
78-
7974
option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading."
8075
${ENABLE_LIBOMPTARGET})
81-
option(OPENMP_ENABLE_LIBOMPTARGET_PROFILING "Enable time profiling for libomptarget."
82-
${ENABLE_LIBOMPTARGET_PROFILING})
8376
option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF)
8477

8578
# Build host runtime library, after LIBOMPTARGET variables are set since they are needed

openmp/docs/design/Runtimes.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -707,16 +707,15 @@ displayed. This feature is only availible if ``libomptarget`` was built with
707707

708708
LIBOMPTARGET_PROFILE
709709
""""""""""""""""""""
710+
710711
``LIBOMPTARGET_PROFILE`` allows ``libomptarget`` to generate time profile output
711712
similar to Clang's ``-ftime-trace`` option. This generates a JSON file based on
712713
`Chrome Tracing`_ that can be viewed with ``chrome://tracing`` or the
713-
`Speedscope App`_. Building this feature depends on the `LLVM Support Library`_
714-
for time trace output. Using this library is enabled by default when building
715-
using the CMake option ``OPENMP_ENABLE_LIBOMPTARGET_PROFILING``. The output will
716-
be saved to the filename specified by the environment variable. For multi-threaded
717-
applications, profiling in ``libomp`` is also needed. Setting the CMake option
718-
``OPENMP_ENABLE_LIBOMP_PROFILING=ON`` to enable the feature. Note that this will
719-
turn ``libomp`` into a C++ library.
714+
`Speedscope App`_. The output will be saved to the filename specified by the
715+
environment variable. For multi-threaded applications, profiling in ``libomp``
716+
is also needed. Setting the CMake option ``OPENMP_ENABLE_LIBOMP_PROFILING=ON``
717+
to enable the feature. This feature depends on the `LLVM Support Library`_
718+
for time trace output. Note that this will turn ``libomp`` into a C++ library.
720719

721720
.. _`Chrome Tracing`: https://www.chromium.org/developers/how-tos/trace-event-profiling-tool
722721

openmp/libomptarget/src/private.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ printKernelArguments(const ident_t *Loc, const int64_t DeviceId,
187187
}
188188
}
189189

190-
#ifdef OMPTARGET_PROFILE_ENABLED
191190
#include "llvm/Support/TimeProfiler.h"
192191
#define TIMESCOPE() llvm::TimeTraceScope TimeScope(__FUNCTION__)
193192
#define TIMESCOPE_WITH_IDENT(IDENT) \
@@ -200,6 +199,5 @@ printKernelArguments(const ident_t *Loc, const int64_t DeviceId,
200199
#define TIMESCOPE()
201200
#define TIMESCOPE_WITH_IDENT(IDENT)
202201
#define TIMESCOPE_WITH_NAME_AND_IDENT(NAME, IDENT)
203-
#endif
204202

205203
#endif

openmp/libomptarget/src/rtl.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ static const char *RTLNames[] = {
3838

3939
PluginManager *PM;
4040

41-
#if OMPTARGET_PROFILE_ENABLED
4241
static char *ProfileTraceFile = nullptr;
43-
#endif
4442

4543
__attribute__((constructor(101))) void init() {
4644
DP("Init target library!\n");
@@ -59,12 +57,10 @@ __attribute__((constructor(101))) void init() {
5957

6058
PM = new PluginManager(UseEventsForAtomicTransfers);
6159

62-
#ifdef OMPTARGET_PROFILE_ENABLED
6360
ProfileTraceFile = getenv("LIBOMPTARGET_PROFILE");
6461
// TODO: add a configuration option for time granularity
6562
if (ProfileTraceFile)
6663
timeTraceProfilerInitialize(500 /* us */, "libomptarget");
67-
#endif
6864
}
6965

7066
__attribute__((destructor(101))) void deinit() {
@@ -88,15 +84,13 @@ __attribute__((destructor(101))) void deinit() {
8884

8985
delete PM;
9086

91-
#ifdef OMPTARGET_PROFILE_ENABLED
9287
if (ProfileTraceFile) {
9388
// TODO: add env var for file output
9489
if (auto E = timeTraceProfilerWrite(ProfileTraceFile, "-"))
9590
fprintf(stderr, "Error writing out the time trace\n");
9691

9792
timeTraceProfilerCleanup();
9893
}
99-
#endif
10094
}
10195

10296
void RTLsTy::loadRTLs() {

0 commit comments

Comments
 (0)