I am experimenting with MPI and I kept getting this error when I was running it through mpirun on the command line.
----------------------------------------------------------------------------------------------
mpirun noticed that the job aborted, but has no info as to the process
that caused that situation.
----------------------------------------------------------------------------------------------
I'm not sure why though, because other mpi programs run perfectly fine.
Here is my code.
#include <stdio.h>
#include <mpi.h>
int func(int num){
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (num == 0){
num = 5;
MPI_Bcast(&num, 1, MPI_INT, rank, MPI_COMM_WORLD);
}
return num;
}
int main(int argc, char **argv){
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("On processor %d, func returns %d
", rank, func(rank));
MPI_Finalize();
return 0;
}
the program is still giving me the same error. Is MPI_Bcast within an if statement just not valid? Does it still work if you try broadcasting when you're not the root?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…