Sorry to post this long, stupid and simple question.
I found that some time MPI_Barrier cannot stop all the process. I try to write a simple test program to create data_struct shown below:
the output should be looks like:
-- processor iocfccd3.aps.anl.gov, rank 0 out of 4 processors
-- processor iocfccd3.aps.anl.gov, rank 3 out of 4 processors
-- processor iocfccd3.aps.anl.gov, rank 1 out of 4 processors
-- processor iocfccd3.aps.anl.gov, rank 2 out of 4 processors
rank 0(before): x value is 2, 0, 10, 3
rank 1(before): x value is 1197535864, -1, 4994901, 0
rank 2(before): x value is 1591464488, -1, 4994901, 0
rank 3(before): x value is 1851622184, -1, 4994901, 0
rank 0(after): x value is 2, 0, 10, 3
rank 3(after): x value is 2, 0, 10, 3
rank 1(after): x value is 2, 0, 10, 3
rank 2(after): x value is 2, 0, 10, 3
but some time is shows as:
-- processor iocfccd3.aps.anl.gov, rank 0 out of 4 processors
rank 0(before): x value is 2, 0, 10, 3
rank 0(after): x value is 2, 0, 10, 3
-- processor iocfccd3.aps.anl.gov, rank 1 out of 4 processors
rank 1(before): x value is -464731256, -1, 4994901, 0
rank 1(after): x value is 2, 0, 10, 3
-- processor iocfccd3.aps.anl.gov, rank 2 out of 4 processors
rank 2(before): x value is 1863042488, -1, 4994901, 0
rank 2(after): x value is 2, 0, 10, 3
-- processor iocfccd3.aps.anl.gov, rank 3 out of 4 processors
rank 3(before): x value is 1721065144, -1, 4994901, 0
rank 3(after): x value is 2, 0, 10, 3
or
-- processor iocfccd3.aps.anl.gov, rank 0 out of 4 processors
-- processor iocfccd3.aps.anl.gov, rank 1 out of 4 processors
rank 1(before): x value is -1883169624, -1, 4994901, 0
-- processor iocfccd3.aps.anl.gov, rank 2 out of 4 processors
rank 2(before): x value is -451256152, -1, 4994901, 0
-- processor iocfccd3.aps.anl.gov, rank 3 out of 4 processors
rank 3(before): x value is 1715067240, -1, 4994901, 0
rank 0(before): x value is 2, 0, 10, 3
rank 0(after): x value is 2, 0, 10, 3
rank 1(after): x value is 2, 0, 10, 3
rank 2(after): x value is 2, 0, 10, 3
rank 3(after): x value is 2, 0, 10, 3 it is all randomly, I am not sure where is the problem.
The second issue is I use MPI_Datatype to create a MPI struct for broadcast. However, as the program shown above, if I change the struct:
typedef struct
{
int a;
char b;
int c;
int d;
} foo;
as
typedef struct
{
int a;
char b;
int c;
double d;
} foo;
I found the result is:
-- processor ephesus.ece.iit.edu, rank 1 out of 4 processors
-- processor ephesus.ece.iit.edu, rank 2 out of 4 processors
-- processor ephesus.ece.iit.edu, rank 3 out of 4 processors
-- processor ephesus.ece.iit.edu, rank 0 out of 4 processors
rank 0(before): x value is 2, 0, 10, 3.250000
rank 3(before): x value is 0, 0, 547474368, 0.000000
rank 1(before): x value is 0, 0, 547474368, 0.000000
rank 2(before): x value is 0, 0, 547474368, 0.000000
rank 0(after): x value is 2, 0, 10, 3.250000
rank 2(after): x value is 2, 0, 10, 0.000000 <- should be 3.25
rank 3(after): x value is 2, 0, 10, 0.000000 <- should be 3.25
rank 1(after): x value is 2, 0, 10, 0.000000 <- should be 3.25
Do you have any clues on why this happened? Thanks a lot!
--
Best Regards,
Sufeng Niu
ECASP lab, ECE department, Illinois Institute of Technology
Tel: 312-731-7219