Skip to content

Commit

Permalink
[OpenMP][NFC] Improve profiling for the offload runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
jdoerfert committed Dec 12, 2023
1 parent 2ada7bb commit 5dd1fc7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion openmp/libomptarget/include/Shared/Profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion openmp/libomptarget/src/OffloadRTL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -32,7 +35,6 @@ __attribute__((constructor(101))) void init() {

PM->init();

Profiler::get();
PM->registerDelayedLibraries();
}

Expand Down
4 changes: 4 additions & 0 deletions openmp/libomptarget/src/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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>(
Expand Down Expand Up @@ -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
Expand All @@ -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 &&
Expand Down

0 comments on commit 5dd1fc7

Please sign in to comment.