Skip to content

Commit

Permalink
Address clang-tidy warnings in ProcessGroupNCCL (pytorch#50131)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#50131

Noticed that in the internal diff for
pytorch#49069 there was a clang-tidy warning to
use emplace instead of push_back. This can save us a copy as it eliminates the
unnecessary in-place construction
ghstack-source-id: 119560979

Test Plan: CI

Reviewed By: pritamdamania87

Differential Revision: D25800134

fbshipit-source-id: 243e57318f5d6e43de524d4e5409893febe6164c
  • Loading branch information
rohan-varma authored and hwangdeyu committed Jan 14, 2021
1 parent d20b21b commit 7e73fd2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions torch/lib/c10d/ProcessGroupNCCL.cpp
Expand Up @@ -1413,7 +1413,7 @@ c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupNCCL::barrier(
// Use user defined GPU device ids if provided
if (!opts.device_ids.empty()) {
for (auto device : opts.device_ids) {
devices.push_back(at::Device(at::DeviceType::CUDA, device));
devices.emplace_back(at::DeviceType::CUDA, device);
}
} else if (usedDeviceIdxs_.empty()) {
// This means there is not yet a NCCL collective being called
Expand All @@ -1423,10 +1423,10 @@ c10::intrusive_ptr<ProcessGroup::Work> ProcessGroupNCCL::barrier(
// ensure that each process is on a different GPU
auto numGPUs = at::cuda::getNumGPUs();
int16_t deviceIdx = static_cast<int16_t>(rank_ % numGPUs);
devices.push_back(at::Device(at::DeviceType::CUDA, deviceIdx));
devices.emplace_back(at::DeviceType::CUDA, deviceIdx);
} else {
for (auto usedDeviceIdx : usedDeviceIdxs_) {
devices.push_back(at::Device(at::DeviceType::CUDA, usedDeviceIdx));
devices.emplace_back(at::DeviceType::CUDA, usedDeviceIdx);
}
}

Expand Down

0 comments on commit 7e73fd2

Please sign in to comment.