Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nccl trace #58338

Merged
merged 3 commits into from
Oct 24, 2023
Merged
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
5 changes: 5 additions & 0 deletions paddle/fluid/distributed/collective/process_group_nccl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ ProcessGroupNCCL::ProcessGroupNCCL(
pg_timeout_(timeout) {
LOG(INFO) << "ProcessGroupNCCL pg_timeout_ " << pg_timeout_;
}
ProcessGroupNCCL::~ProcessGroupNCCL() {
LOG(INFO) << "ProcessGroupNCCL destruct ";
auto& comm_task_manager = phi::distributed::CommTaskManager::GetInstance();
comm_task_manager.Stop();
}

void ProcessGroupNCCL::GroupStart() {
NCCL_CHECK(phi::dynload::ncclGroupStart());
Expand Down
1 change: 1 addition & 0 deletions paddle/fluid/distributed/collective/process_group_nccl.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class ProcessGroupNCCL final : public ProcessGroupWithStream {
int size,
int gid,
int64_t timeout = 20 * 1000);
~ProcessGroupNCCL();

std::string GetBackendName() const override { return "NCCL"; }

Expand Down
19 changes: 18 additions & 1 deletion paddle/phi/core/distributed/comm_task_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ void CommTaskManager::CommTaskEnqueue(std::shared_ptr<CommTask> comm_task) {
}
}

void CommTaskManager::Stop() {
terminated_.store(true);

LOG(INFO) << "CommTaskManager stopped begin.";
if (comm_task_loop_thread_.joinable()) {
comm_task_loop_thread_.join();
comm_task_list_cv_.notify_one();
}
LOG(INFO) << "CommTaskManager stopped.";
}

void CommTaskManager::CommTaskLoop() {
bool done = false;
while (!terminated_.load() || !done) {
Expand All @@ -100,7 +111,11 @@ void CommTaskManager::CommTaskLoop() {
}
iter = comm_task_list_.erase(iter);
} else {
++iter;
if (task->IsStarted() && task->IsCompleted()) {
iter = comm_task_list_.erase(iter);
} else {
++iter;
}
}
}

Expand Down Expand Up @@ -131,6 +146,8 @@ void CommTaskManager::CommTaskLoop() {
if (comm_task_list_.empty() && init_comm_task_map_.empty() &&
start_comm_task_map_.empty()) {
done = true;
} else {
done = false;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions paddle/phi/core/distributed/comm_task_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class CommTaskManager {
}

void CommTaskEnqueue(std::shared_ptr<CommTask> comm_task);
void Stop();

private:
void CommTaskLoop();
Expand Down