Skip to content

Commit

Permalink
do not call collectTrace in main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
staugust committed Aug 7, 2024
1 parent b6bfae7 commit 1af59c6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libkineto/src/CuptiActivityProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1232,9 +1232,12 @@ const time_point<system_clock> CuptiActivityProfiler::performRunLoopStep(

// currentIter > 0 means this is an iteration-based collection, triggered by pytorch main thread,
// it should be executed in another thread in case pytorch main thread is blocked
if (currentIter > 0 && !collectTraceThread) {
std::lock_guard<std::mutex> guard(mutex_);
collectTraceThread = std::make_unique<std::thread>(&CuptiActivityProfiler::collectTrace, this, collection_done, now);
if (currentIter > 0) {
// if collectTraceThread is already running, there's no need to execute collectTrace twice.
if(!collectTraceThread){
std::lock_guard<std::mutex> guard(mutex_);
collectTraceThread = std::make_unique<std::thread>(&CuptiActivityProfiler::collectTrace, this, collection_done, now);
}
break;
}
collectTrace(collection_done, now);
Expand Down

0 comments on commit 1af59c6

Please sign in to comment.