From 04ae35e592c1e7e99bb3894420b6ff2117ace78a Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Mon, 29 Aug 2022 09:43:45 -0500 Subject: [PATCH] [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 --- openmp/CMakeLists.txt | 7 ------- openmp/docs/design/Runtimes.rst | 13 ++++++------- openmp/libomptarget/src/private.h | 2 -- openmp/libomptarget/src/rtl.cpp | 6 ------ 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt index dd86048..a038dc0 100644 --- a/openmp/CMakeLists.txt +++ b/openmp/CMakeLists.txt @@ -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 diff --git a/openmp/docs/design/Runtimes.rst b/openmp/docs/design/Runtimes.rst index 532b76f..2bb6e8b 100644 --- a/openmp/docs/design/Runtimes.rst +++ b/openmp/docs/design/Runtimes.rst @@ -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 diff --git a/openmp/libomptarget/src/private.h b/openmp/libomptarget/src/private.h index 2fe7c63..5adadf9 100644 --- a/openmp/libomptarget/src/private.h +++ b/openmp/libomptarget/src/private.h @@ -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 diff --git a/openmp/libomptarget/src/rtl.cpp b/openmp/libomptarget/src/rtl.cpp index d0b5eb5..7fdc47d 100644 --- a/openmp/libomptarget/src/rtl.cpp +++ b/openmp/libomptarget/src/rtl.cpp @@ -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() { -- 2.7.4