@@ -249,7 +249,7 @@ void Stochastic_Iter<T, Device>::check_precision(const double ref, const double
249249 }
250250
251251#ifdef __MPI
252- MPI_Allreduce (MPI_IN_PLACE, & error, 1 , MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD );
252+ Parallel_Reduce::reduce_all ( error);
253253#endif
254254 double relative_error = std::abs (error / ref);
255255 GlobalV::ofs_running << info << " Relative Chebyshev Precision: " << relative_error * 1e9 << " E-09" << std::endl;
@@ -473,7 +473,7 @@ double Stochastic_Iter<T, Device>::calne(elecstate::ElecState* pes)
473473 {
474474 MPI_Allreduce (MPI_IN_PLACE, &KS_ne, 1 , MPI_DOUBLE, MPI_SUM, BP_WORLD);
475475 }
476- MPI_Allreduce (MPI_IN_PLACE, & sto_ne, 1 , MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD );
476+ Parallel_Reduce::reduce_all ( sto_ne);
477477#endif
478478
479479 totne = KS_ne + sto_ne;
@@ -540,7 +540,7 @@ void Stochastic_Iter<T, Device>::sum_stoeband(Stochastic_WF<T, Device>& stowf,
540540 {
541541 MPI_Allreduce (MPI_IN_PLACE, &pes->f_en .demet , 1 , MPI_DOUBLE, MPI_SUM, BP_WORLD);
542542 }
543- MPI_Allreduce (MPI_IN_PLACE, & stodemet, 1 , MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD );
543+ Parallel_Reduce::reduce_all ( stodemet);
544544#endif
545545 pes->f_en .demet += stodemet;
546546 this ->check_precision (pes->f_en .demet , 1e-4 , " TS" );
@@ -581,7 +581,7 @@ void Stochastic_Iter<T, Device>::sum_stoeband(Stochastic_WF<T, Device>& stowf,
581581 }
582582 }
583583#ifdef __MPI
584- MPI_Allreduce (MPI_IN_PLACE, & sto_eband, 1 , MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD );
584+ Parallel_Reduce::reduce_all ( sto_eband);
585585#endif
586586 pes->f_en .eband += sto_eband;
587587 ModuleBase::timer::tick (" Stochastic_Iter" , " sum_stoeband" );
@@ -695,7 +695,7 @@ void Stochastic_Iter<T, Device>::cal_storho(const UnitCell& ucell,
695695 sto_ne *= ucell.omega / wfc_basis->nxyz ;
696696
697697#ifdef __MPI
698- MPI_Allreduce (MPI_IN_PLACE, & sto_ne, 1 , MPI_DOUBLE, MPI_SUM, POOL_WORLD );
698+ Parallel_Reduce::reduce_pool ( sto_ne);
699699#endif
700700 double factor = targetne / (KS_ne + sto_ne);
701701 if (std::abs (factor - 1 ) > 1e-10 )
0 commit comments