Skip to content

Commit 5dd1fc7

Browse files
committed
[OpenMP][NFC] Improve profiling for the offload runtime
1 parent 2ada7bb commit 5dd1fc7

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

openmp/libomptarget/include/Shared/Profile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Profiler {
7575
};
7676

7777
/// Time spend in the current scope, assigned to the function name.
78-
#define TIMESCOPE() llvm::TimeTraceScope TimeScope(__FUNCTION__)
78+
#define TIMESCOPE() llvm::TimeTraceScope TimeScope(__PRETTY_FUNCTION__)
7979

8080
/// Time spend in the current scope, assigned to the function name and source
8181
/// info.

openmp/libomptarget/src/OffloadRTL.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ extern void llvm::omp::target::ompt::connectLibrary();
2121
#endif
2222

2323
__attribute__((constructor(101))) void init() {
24+
Profiler::get();
25+
TIMESCOPE();
26+
2427
DP("Init offload library!\n");
2528

2629
PM = new PluginManager();
@@ -32,7 +35,6 @@ __attribute__((constructor(101))) void init() {
3235

3336
PM->init();
3437

35-
Profiler::get();
3638
PM->registerDelayedLibraries();
3739
}
3840

openmp/libomptarget/src/PluginManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "PluginManager.h"
1414
#include "Shared/Debug.h"
15+
#include "Shared/Profile.h"
1516

1617
#include "llvm/Support/Error.h"
1718
#include "llvm/Support/ErrorHandling.h"
@@ -28,6 +29,7 @@ static const char *RTLNames[] = {ENABLED_OFFLOAD_PLUGINS};
2829
Expected<std::unique_ptr<PluginAdaptorTy>>
2930
PluginAdaptorTy::create(const std::string &Name) {
3031
DP("Attempting to load library '%s'...\n", Name.c_str());
32+
TIMESCOPE_WITH_NAME_AND_IDENT(Name, (const ident_t *)nullptr);
3133

3234
std::string ErrMsg;
3335
auto LibraryHandler = std::make_unique<DynamicLibrary>(
@@ -101,6 +103,7 @@ void PluginAdaptorTy::addOffloadEntries(DeviceImageTy &DI) {
101103
}
102104

103105
void PluginManager::init() {
106+
TIMESCOPE();
104107
DP("Loading RTLs...\n");
105108

106109
// Attempt to open all the plugins and, if they exist, check if the interface
@@ -123,6 +126,7 @@ void PluginManager::init() {
123126
void PluginAdaptorTy::initDevices(PluginManager &PM) {
124127
if (isUsed())
125128
return;
129+
TIMESCOPE();
126130

127131
// If this RTL is not already in use, initialize it.
128132
assert(getNumberOfPluginDevices() > 0 &&

0 commit comments

Comments
 (0)