[Openmp-commits] [openmp] 04ae35e - [libomptarget] Always enable time tracing in libomptarget

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Mon Aug 29 12:49:14 PDT 2022


Author: Joseph Huber
Date: 2022-08-29T14:49:03-05:00
New Revision: 04ae35e592c1e7e99bb3894420b6ff2117ace78a

URL: https://github.com/llvm/llvm-project/commit/04ae35e592c1e7e99bb3894420b6ff2117ace78a
DIFF: https://github.com/llvm/llvm-project/commit/04ae35e592c1e7e99bb3894420b6ff2117ace78a.diff

LOG: [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

Added: 
    

Modified: 
    openmp/CMakeLists.txt
    openmp/docs/design/Runtimes.rst
    openmp/libomptarget/src/private.h
    openmp/libomptarget/src/rtl.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index dd860485c69d9..a038dc09be2c5 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 532b76f72c41d..2bb6e8b9ae8e8 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 2fe7c6337a213..5adadf98dc899 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 d0b5eb5b4d75c..7fdc47d2560b9 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() {


        


More information about the Openmp-commits mailing list