Skip to content

Commit

Permalink
[Offload] [OMPT] Move trace record manager to plugin manager.
Browse files Browse the repository at this point in the history
Removed the global trace record manager object, instead creating
and destroying it now as part of runtime init/deinit. This leads
to a deterministic lifetime for the trace record manager.

Change-Id: Id351d7e9a6fc42c222dd865d84c7f02bda0a50de
  • Loading branch information
dhruvachak authored and ronlieb committed Oct 31, 2024
1 parent 6c0e154 commit 08778a1
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 59 deletions.
3 changes: 0 additions & 3 deletions offload/include/OmptTracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ extern thread_local uint64_t TraceRecordStopTime;
/// Thread local thread-id.
extern thread_local uint64_t ThreadId;

/// Manage all tracing records in one place.
extern OmptTracingBufferMgr TraceRecordManager;

/// OMPT global tracing status. Indicates if at least one device is traced.
extern bool TracingActive;

Expand Down
2 changes: 2 additions & 0 deletions offload/include/OmptTracingBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,8 @@ class OmptTracingBufferMgr {
int flushAllBuffers(int DeviceId);
};

#else
class OmptTracingBufferMgr {};
#endif // OMPT_SUPPORT

#endif // OPENMP_LIBOMPTARGET_OMPTTRACINGBUFFER_H
12 changes: 11 additions & 1 deletion offload/include/PluginManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef OMPTARGET_PLUGIN_MANAGER_H
#define OMPTARGET_PLUGIN_MANAGER_H

#include "OmptTracingBuffer.h"
#include "PluginInterface.h"

#include "DeviceImage.h"
Expand Down Expand Up @@ -46,7 +47,7 @@ struct PluginManager {
/// Exclusive accessor type for the device container.
using ExclusiveDevicesAccessorTy = Accessor<DeviceContainerTy>;

PluginManager() {}
PluginManager() : TraceRecordManager(nullptr) {}

void init();

Expand Down Expand Up @@ -144,6 +145,13 @@ struct PluginManager {
return count;
}

auto getTraceRecordManager() const {
// Must be called after runtime is initialized. Since the runtime init
// allocates TraceRecordManager, we assert below.
assert(TraceRecordManager && "Trace record manager not initialized");
return TraceRecordManager;
}

private:
bool RTLsLoaded = false;
llvm::SmallVector<__tgt_bin_desc *> DelayedBinDesc;
Expand All @@ -169,6 +177,8 @@ struct PluginManager {

/// Devices associated with plugins, accesses to the container are exclusive.
ProtectedObj<DeviceContainerTy> Devices;

OmptTracingBufferMgr *TraceRecordManager;
};

/// Initialize the plugin manager and OpenMP runtime.
Expand Down
Loading

0 comments on commit 08778a1

Please sign in to comment.