Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions libkineto/src/EventProfilerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ vector<unique_ptr<SampleListener>>& onDemandLoggers(
return res;
}

} // anon namespace

// Keep an eye on profiling threads.
// We've observed deadlocks in Cuda11 in libcuda / libcupti..
namespace detail {

class HeartbeatMonitor {

public:
Expand Down Expand Up @@ -157,6 +161,9 @@ class HeartbeatMonitor {
seconds period_{0};
};

} // namespace detail

namespace {
// Profiler map singleton
std::map<CUcontext, unique_ptr<EventProfilerController>>& profilerMap() {
static std::map<CUcontext, unique_ptr<EventProfilerController>> instance;
Expand All @@ -174,7 +181,7 @@ void reportLateSample(
}

void configureHeartbeatMonitor(
HeartbeatMonitor& monitor, const Config& base, const Config& onDemand) {
detail::HeartbeatMonitor& monitor, const Config& base, const Config& onDemand) {
seconds base_period =
base.eventProfilerHeartbeatMonitorPeriod();
seconds on_demand_period =
Expand All @@ -198,7 +205,7 @@ void EventProfilerController::addOnDemandLoggerFactory(
EventProfilerController::EventProfilerController(
CUcontext context,
ConfigLoader& configLoader,
HeartbeatMonitor& heartbeatMonitor)
detail::HeartbeatMonitor& heartbeatMonitor)
: configLoader_(configLoader), heartbeatMonitor_(heartbeatMonitor) {
auto cupti_events = std::make_unique<CuptiEventInterface>(context);
auto cupti_metrics =
Expand Down Expand Up @@ -226,7 +233,7 @@ EventProfilerController::~EventProfilerController() {
void EventProfilerController::start(CUcontext ctx) {
profilerMap()[ctx] = unique_ptr<EventProfilerController>(
new EventProfilerController(
ctx, ConfigLoader::instance(), HeartbeatMonitor::instance()));
ctx, ConfigLoader::instance(), detail::HeartbeatMonitor::instance()));
}

// Must be called under lock
Expand Down
6 changes: 3 additions & 3 deletions libkineto/src/EventProfilerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ConfigLoader;
class EventProfiler;
class SampleListener;

namespace {
namespace detail {
class HeartbeatMonitor;
}

Expand All @@ -45,12 +45,12 @@ class EventProfilerController {
explicit EventProfilerController(
CUcontext context,
ConfigLoader& configLoader,
HeartbeatMonitor& heartbeatMonitor);
detail::HeartbeatMonitor& heartbeatMonitor);
bool enableForDevice(Config& cfg);
void profilerLoop();

ConfigLoader& configLoader_;
HeartbeatMonitor& heartbeatMonitor_;
detail::HeartbeatMonitor& heartbeatMonitor_;
std::unique_ptr<EventProfiler> profiler_;
std::unique_ptr<std::thread> profilerThread_;
std::atomic_bool stopRunloop_{false};
Expand Down