Skip to content

Commit 0d54b11

Browse files
committed
lint fix
1 parent cc2b175 commit 0d54b11

1 file changed

Lines changed: 19 additions & 22 deletions

File tree

src/caffe/parallel.cpp

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ void DevicePair::compute(const vector<int> devices, vector<DevicePair>* pairs) {
120120
vector<int> remaining(devices);
121121

122122
// Depth for reduction tree
123-
int remaining_depth = (int)ceil(log2(remaining.size()));
123+
int remaining_depth = static_cast<int>(ceil(log2(remaining.size())));
124124

125-
// Group GPUs by board
125+
// Group GPUs by board
126126
for (int d = 0; d < remaining_depth; ++d) {
127127
for (int i = 0; i < remaining.size(); ++i) {
128128
for (int j = i + 1; j < remaining.size(); ++j) {
@@ -131,11 +131,10 @@ void DevicePair::compute(const vector<int> devices, vector<DevicePair>* pairs) {
131131
CUDA_CHECK(cudaGetDeviceProperties(&b, remaining[j]));
132132
if (a.isMultiGpuBoard && b.isMultiGpuBoard) {
133133
if (a.multiGpuBoardGroupID == b.multiGpuBoardGroupID) {
134-
pairs->push_back(DevicePair(remaining[i], remaining[j]));
135-
DLOG(INFO) << "GPU board: " << remaining[i]
136-
<< ":" << remaining[j];
137-
remaining.erase(remaining.begin() + j);
138-
break;
134+
pairs->push_back(DevicePair(remaining[i], remaining[j]));
135+
DLOG(INFO) << "GPU board: " << remaining[i] << ":" << remaining[j];
136+
remaining.erase(remaining.begin() + j);
137+
break;
139138
}
140139
}
141140
}
@@ -153,39 +152,37 @@ void DevicePair::compute(const vector<int> devices, vector<DevicePair>* pairs) {
153152
for (int i = 0; i < remaining.size(); ++i) {
154153
for (int j = i + 1; j < remaining.size(); ++j) {
155154
int access;
156-
CUDA_CHECK(cudaDeviceCanAccessPeer(&access,
157-
remaining[i],
158-
remaining[j]));
155+
CUDA_CHECK(
156+
cudaDeviceCanAccessPeer(&access, remaining[i], remaining[j]));
159157
if (access) {
160-
pairs->push_back(DevicePair(remaining[i], remaining[j]));
161-
DLOG(INFO) << "P2P pair: " << remaining[i]
162-
<< ":" << remaining[j];
163-
remaining.erase(remaining.begin() + j);
164-
break;
158+
pairs->push_back(DevicePair(remaining[i], remaining[j]));
159+
DLOG(INFO) << "P2P pair: " << remaining[i] << ":" << remaining[j];
160+
remaining.erase(remaining.begin() + j);
161+
break;
165162
}
166163
}
167164
}
168165
}
169166
s.str("");
170167
for (int i = 0; i < remaining.size(); ++i) {
171-
s << (i ? ", " : "") << remaining[i];
168+
s << (i ? ", " : "") << remaining[i];
172169
}
173170
DLOG(INFO) << "GPUs paired by P2P access, remaining: " << s.str();
174171

175172
// Group remaining
176173
remaining_depth = ceil(log2(remaining.size()));
177-
for (int d = 0; d < remaining_depth; ++d) {
174+
for (int d = 0; d < remaining_depth; ++d) {
178175
for (int i = 0; i < remaining.size(); ++i) {
179-
pairs->push_back(DevicePair(remaining[i], remaining[i+1]));
180-
DLOG(INFO) << "Remaining pair: " << remaining[i]
181-
<< ":" << remaining[i+1];
182-
remaining.erase(remaining.begin() + i+1);
176+
pairs->push_back(DevicePair(remaining[i], remaining[i + 1]));
177+
DLOG(INFO) << "Remaining pair: " << remaining[i] << ":"
178+
<< remaining[i + 1];
179+
remaining.erase(remaining.begin() + i + 1);
183180
}
184181
}
185182

186183
// Should only be the parent node remaining
187184
CHECK_EQ(remaining.size(), 1);
188-
185+
189186
pairs->insert(pairs->begin(), DevicePair(-1, remaining[0]));
190187

191188
CHECK(pairs->size() == devices.size());

0 commit comments

Comments
 (0)