Skip to content

Commit ac820e0

Browse files
committed
do not show warning for balance issues on cpus
1 parent dc80444 commit ac820e0

1 file changed

Lines changed: 41 additions & 35 deletions

File tree

src/timeIntegrator.cpp

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -197,47 +197,53 @@ double TimeIntegrator::ComputeBalance() {
197197
// Check MPI imbalance
198198
double imbalance = 0;
199199
#ifdef WITH_MPI
200-
const double allowedImbalance = 20.0;
201-
std::vector<double> computeLogPerCore(idfx::psize);
202-
MPI_Gather(&computeLastLog, 1, MPI_DOUBLE, computeLogPerCore.data(), 1, MPI_DOUBLE, 0,
203-
MPI_COMM_WORLD);
204-
computeLastLog = 0; // reset timer for all cores
205-
if(idfx::prank==0) {
206-
// Compute the average, the min and the max
207-
double computeMin = computeLogPerCore[0];
208-
double computeMax = computeLogPerCore[0];
209-
double computeMean = 0;
210-
211-
for(int i = 0 ; i < idfx::psize ; i++) {
212-
computeMean += computeLogPerCore[i];
213-
if(computeLogPerCore[i]>computeMax) {
214-
computeMax = computeLogPerCore[i];
215-
}
216-
if(computeLogPerCore[i]<computeMin) {
217-
computeMin = computeLogPerCore[i];
218-
}
219-
}
220-
computeMean /= idfx::psize;
221-
imbalance = (computeMax-computeMin)/computeMean*100;
200+
// only do this on GPUs
201+
#if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP) || defined(KOKKOS_ENABLE_SYCL)
202+
const double allowedImbalance = 20.0;
203+
std::vector<double> computeLogPerCore(idfx::psize);
204+
MPI_Gather(&computeLastLog, 1, MPI_DOUBLE, computeLogPerCore.data(), 1, MPI_DOUBLE, 0,
205+
MPI_COMM_WORLD);
206+
computeLastLog = 0; // reset timer for all cores
207+
if(idfx::prank==0) {
208+
// Compute the average, the min and the max
209+
double computeMin = computeLogPerCore[0];
210+
double computeMax = computeLogPerCore[0];
211+
double computeMean = 0;
222212

223-
if(imbalance>allowedImbalance ) {
224-
idfx::cout << "-------------------------------------------------------------"<< std::endl;
225-
idfx::cout << "Warning: MPI imbalance found in this run " << std::endl;
226-
idfx::cout << std::fixed;
227213
for(int i = 0 ; i < idfx::psize ; i++) {
228-
if(computeLogPerCore[i]/computeMean - 1> allowedImbalance/2/100) {
229-
idfx::cout << "+" << 100*(computeLogPerCore[i]/computeMean-1)
230-
<< "% (proc " << i << ")" << std::endl;
214+
computeMean += computeLogPerCore[i];
215+
if(computeLogPerCore[i]>computeMax) {
216+
computeMax = computeLogPerCore[i];
231217
}
232-
if(1-computeLogPerCore[i]/computeMean > allowedImbalance/2/100) {
233-
idfx::cout << "-" << 100*(1-computeLogPerCore[i]/computeMean)
234-
<< "% (proc " << i << ")" << std::endl;
218+
if(computeLogPerCore[i]<computeMin) {
219+
computeMin = computeLogPerCore[i];
235220
}
236221
}
237-
idfx::cout << "You should probably check these nodes are running properly." << std::endl;
238-
idfx::cout << "-------------------------------------------------------------"<< std::endl;
222+
computeMean /= idfx::psize;
223+
imbalance = (computeMax-computeMin)/computeMean*100;
224+
225+
if(imbalance>allowedImbalance ) {
226+
idfx::cout << "-------------------------------------------------------------"
227+
<< std::endl;
228+
idfx::cout << "Warning: MPI imbalance found in this run " << std::endl;
229+
idfx::cout << std::fixed;
230+
for(int i = 0 ; i < idfx::psize ; i++) {
231+
if(computeLogPerCore[i]/computeMean - 1> allowedImbalance/2/100) {
232+
idfx::cout << "+" << 100*(computeLogPerCore[i]/computeMean-1)
233+
<< "% (proc " << i << ")" << std::endl;
234+
}
235+
if(1-computeLogPerCore[i]/computeMean > allowedImbalance/2/100) {
236+
idfx::cout << "-" << 100*(1-computeLogPerCore[i]/computeMean)
237+
<< "% (proc " << i << ")" << std::endl;
238+
}
239+
}
240+
idfx::cout << "You should probably check these nodes are running properly."
241+
<< std::endl;
242+
idfx::cout << "-------------------------------------------------------------"
243+
<< std::endl;
244+
}
239245
}
240-
}
246+
#endif
241247
#endif
242248
return(imbalance);
243249
}

0 commit comments

Comments
 (0)