[Openmp-commits] [openmp] 5dd1fc7 - [OpenMP][NFC] Improve profiling for the offload runtime
Johannes Doerfert via Openmp-commits
openmp-commits at lists.llvm.org
Mon Dec 11 17:31:03 PST 2023
Author: Johannes Doerfert
Date: 2023-12-11T17:30:35-08:00
New Revision: 5dd1fc700857eb46882c7e27cd8835ef4fee1f22
URL: https://github.com/llvm/llvm-project/commit/5dd1fc700857eb46882c7e27cd8835ef4fee1f22
DIFF: https://github.com/llvm/llvm-project/commit/5dd1fc700857eb46882c7e27cd8835ef4fee1f22.diff
LOG: [OpenMP][NFC] Improve profiling for the offload runtime
Added:
Modified:
openmp/libomptarget/include/Shared/Profile.h
openmp/libomptarget/src/OffloadRTL.cpp
openmp/libomptarget/src/PluginManager.cpp
Removed:
################################################################################
diff --git a/openmp/libomptarget/include/Shared/Profile.h b/openmp/libomptarget/include/Shared/Profile.h
index 316b0c3086d048..19ca0cf2275186 100644
--- a/openmp/libomptarget/include/Shared/Profile.h
+++ b/openmp/libomptarget/include/Shared/Profile.h
@@ -75,7 +75,7 @@ class Profiler {
};
/// Time spend in the current scope, assigned to the function name.
-#define TIMESCOPE() llvm::TimeTraceScope TimeScope(__FUNCTION__)
+#define TIMESCOPE() llvm::TimeTraceScope TimeScope(__PRETTY_FUNCTION__)
/// Time spend in the current scope, assigned to the function name and source
/// info.
diff --git a/openmp/libomptarget/src/OffloadRTL.cpp b/openmp/libomptarget/src/OffloadRTL.cpp
index 061b053c68cc88..86ef0d5bc91cf0 100644
--- a/openmp/libomptarget/src/OffloadRTL.cpp
+++ b/openmp/libomptarget/src/OffloadRTL.cpp
@@ -21,6 +21,9 @@ extern void llvm::omp::target::ompt::connectLibrary();
#endif
__attribute__((constructor(101))) void init() {
+ Profiler::get();
+ TIMESCOPE();
+
DP("Init offload library!\n");
PM = new PluginManager();
@@ -32,7 +35,6 @@ __attribute__((constructor(101))) void init() {
PM->init();
- Profiler::get();
PM->registerDelayedLibraries();
}
diff --git a/openmp/libomptarget/src/PluginManager.cpp b/openmp/libomptarget/src/PluginManager.cpp
index 16e04dde923d9e..17787284441c55 100644
--- a/openmp/libomptarget/src/PluginManager.cpp
+++ b/openmp/libomptarget/src/PluginManager.cpp
@@ -12,6 +12,7 @@
#include "PluginManager.h"
#include "Shared/Debug.h"
+#include "Shared/Profile.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
@@ -28,6 +29,7 @@ static const char *RTLNames[] = {ENABLED_OFFLOAD_PLUGINS};
Expected<std::unique_ptr<PluginAdaptorTy>>
PluginAdaptorTy::create(const std::string &Name) {
DP("Attempting to load library '%s'...\n", Name.c_str());
+ TIMESCOPE_WITH_NAME_AND_IDENT(Name, (const ident_t *)nullptr);
std::string ErrMsg;
auto LibraryHandler = std::make_unique<DynamicLibrary>(
@@ -101,6 +103,7 @@ void PluginAdaptorTy::addOffloadEntries(DeviceImageTy &DI) {
}
void PluginManager::init() {
+ TIMESCOPE();
DP("Loading RTLs...\n");
// Attempt to open all the plugins and, if they exist, check if the interface
@@ -123,6 +126,7 @@ void PluginManager::init() {
void PluginAdaptorTy::initDevices(PluginManager &PM) {
if (isUsed())
return;
+ TIMESCOPE();
// If this RTL is not already in use, initialize it.
assert(getNumberOfPluginDevices() > 0 &&
More information about the Openmp-commits
mailing list