[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
This commit is contained in:
Joseph Huber 2022-08-29 09:43:45 -05:00
parent 033a97a8f3
commit 04ae35e592
4 changed files with 6 additions and 22 deletions

View File

@ -71,15 +71,8 @@ if (APPLE OR WIN32 OR NOT OPENMP_HAVE_STD_CPP17_FLAG)
set(ENABLE_LIBOMPTARGET OFF)
endif()
set(ENABLE_LIBOMPTARGET_PROFILING OFF)
if (ENABLE_LIBOMPTARGET AND NOT LLVM_RUNTIMES_BUILD)
set(ENABLE_LIBOMPTARGET_PROFILING ON)
endif()
option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading."
${ENABLE_LIBOMPTARGET})
option(OPENMP_ENABLE_LIBOMPTARGET_PROFILING "Enable time profiling for libomptarget."
${ENABLE_LIBOMPTARGET_PROFILING})
option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF)
# Build host runtime library, after LIBOMPTARGET variables are set since they are needed

View File

@ -707,16 +707,15 @@ displayed. This feature is only availible if ``libomptarget`` was built with
LIBOMPTARGET_PROFILE
""""""""""""""""""""
``LIBOMPTARGET_PROFILE`` allows ``libomptarget`` to generate time profile output
similar to Clang's ``-ftime-trace`` option. This generates a JSON file based on
`Chrome Tracing`_ that can be viewed with ``chrome://tracing`` or the
`Speedscope App`_. Building this feature depends on the `LLVM Support Library`_
for time trace output. Using this library is enabled by default when building
using the CMake option ``OPENMP_ENABLE_LIBOMPTARGET_PROFILING``. The output will
be saved to the filename specified by the environment variable. For multi-threaded
applications, profiling in ``libomp`` is also needed. Setting the CMake option
``OPENMP_ENABLE_LIBOMP_PROFILING=ON`` to enable the feature. Note that this will
turn ``libomp`` into a C++ library.
`Speedscope App`_. The output will be saved to the filename specified by the
environment variable. For multi-threaded applications, profiling in ``libomp``
is also needed. Setting the CMake option ``OPENMP_ENABLE_LIBOMP_PROFILING=ON``
to enable the feature. This feature depends on the `LLVM Support Library`_
for time trace output. Note that this will turn ``libomp`` into a C++ library.
.. _`Chrome Tracing`: https://www.chromium.org/developers/how-tos/trace-event-profiling-tool

View File

@ -187,7 +187,6 @@ printKernelArguments(const ident_t *Loc, const int64_t DeviceId,
}
}
#ifdef OMPTARGET_PROFILE_ENABLED
#include "llvm/Support/TimeProfiler.h"
#define TIMESCOPE() llvm::TimeTraceScope TimeScope(__FUNCTION__)
#define TIMESCOPE_WITH_IDENT(IDENT) \
@ -200,6 +199,5 @@ printKernelArguments(const ident_t *Loc, const int64_t DeviceId,
#define TIMESCOPE()
#define TIMESCOPE_WITH_IDENT(IDENT)
#define TIMESCOPE_WITH_NAME_AND_IDENT(NAME, IDENT)
#endif
#endif

View File

@ -38,9 +38,7 @@ static const char *RTLNames[] = {
PluginManager *PM;
#if OMPTARGET_PROFILE_ENABLED
static char *ProfileTraceFile = nullptr;
#endif
__attribute__((constructor(101))) void init() {
DP("Init target library!\n");
@ -59,12 +57,10 @@ __attribute__((constructor(101))) void init() {
PM = new PluginManager(UseEventsForAtomicTransfers);
#ifdef OMPTARGET_PROFILE_ENABLED
ProfileTraceFile = getenv("LIBOMPTARGET_PROFILE");
// TODO: add a configuration option for time granularity
if (ProfileTraceFile)
timeTraceProfilerInitialize(500 /* us */, "libomptarget");
#endif
}
__attribute__((destructor(101))) void deinit() {
@ -88,7 +84,6 @@ __attribute__((destructor(101))) void deinit() {
delete PM;
#ifdef OMPTARGET_PROFILE_ENABLED
if (ProfileTraceFile) {
// TODO: add env var for file output
if (auto E = timeTraceProfilerWrite(ProfileTraceFile, "-"))
@ -96,7 +91,6 @@ __attribute__((destructor(101))) void deinit() {
timeTraceProfilerCleanup();
}
#endif
}
void RTLsTy::loadRTLs() {