Skip to content

Commit ef95b28

Browse files
authored
Fix: bug of divide_mpi_groups (#6120)
1 parent eae7575 commit ef95b28

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

source/module_base/parallel_global.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,16 @@ void Parallel_Global::divide_mpi_groups(const int& procs,
405405
exit(1);
406406
}
407407

408-
if(rank < extra_procs)
408+
if(rank < extra_procs * (procs_in_group + 1))
409409
{
410+
// The first extra_procs groups have procs_in_group + 1 processes.
410411
procs_in_group++;
411412
my_group = rank / procs_in_group;
412413
rank_in_group = rank % procs_in_group;
413414
}
414415
else
415416
{
417+
// The remaining groups have procs_in_group processes.
416418
my_group = (rank - extra_procs) / procs_in_group;
417419
rank_in_group = (rank - extra_procs) % procs_in_group;
418420
}

source/module_cell/test/parallel_kpoints_test.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
np=`cat /proc/cpuinfo | grep "cpu cores" | uniq| awk '{print $NF}'`
44
echo "nprocs in this machine is $np"
55

6-
for i in 4;do
6+
for ((i=3;i<=4;i++));
7+
do
78
if [[ $i -gt $np ]];then
89
continue
910
fi
1011
echo "TEST in parallel, nprocs=$i"
1112
mpirun -np $i ./cell_ParaKpoints
12-
break
13+
if [ $? -ne 0 ]; then
14+
echo "TEST in parallel, nprocs=$i failed"
15+
exit 1
16+
fi
1317
done

0 commit comments

Comments
 (0)