Skip to content

Commit

Permalink
add notifyCurrentRunloopState to dynolog
Browse files Browse the repository at this point in the history
  • Loading branch information
tangliang-mt committed Sep 19, 2024
1 parent da68208 commit adead90
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libkineto/src/ActivityProfilerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,18 @@ void ActivityProfilerController::scheduleTrace(const Config& config) {
return;
}
profiler_->setOnDemandProfilingPending(true);
configLoader_.notifyCurrentRunloopState(4); // 4 - on-demand profiling pending
LOG(INFO) << "On-demand profiling enter [pending] status.";
// If has another ongoing sync profiling, wait until it is finished normally.
while (profiler_->isSyncProfilingRunning()) {
// Block here, until sync profiling is finished.
LOG(INFO) << "wait until sync profiling finished.";
// sleep in main thread, readOnDemandConfigFromDaemon will be blocked.
usleep(500000); // 500ms
}
profiler_->setOnDemandProfilingRunning(true);
profiler_->setOnDemandProfilingPending(false);
configLoader_.notifyCurrentRunloopState(1); // 1 - on-demand profiling running
LOG(INFO) << "On-demand profiling enter [running] status.";

int64_t currentIter = iterationCount_;
Expand Down
7 changes: 7 additions & 0 deletions libkineto/src/ConfigLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ std::string ConfigLoader::readOnDemandConfigFromDaemon(
return daemonConfigLoader_->readOnDemandConfig(events, activities, currentRunloopState);
}

void ConfigLoader::notifyCurrentRunloopState(int state) {
if (!daemonConfigLoader_) {
return;
}
daemonConfigLoader_->readOnDemandConfig(false, true, state);
}

int ConfigLoader::contextCountForGpu(uint32_t device) {
if (!daemonConfigLoader_) {
// FIXME: Throw error?
Expand Down
2 changes: 2 additions & 0 deletions libkineto/src/ConfigLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class ConfigLoader {
}
}

void notifyCurrentRunloopState(int state);

bool canHandlerAcceptConfig(ConfigKind kind) {
std::lock_guard<std::mutex> lock(updateThreadMutex_);
for (ConfigHandler* handler : handlers_[kind]) {
Expand Down

0 comments on commit adead90

Please sign in to comment.