MPI_Bcast problem, bug?

Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications High Performance Computing MPI_Bcast problem, bug?
# 1  
MPI_Bcast problem, bug?

Hi, I'm trying to define an MPI_datatype for a structure, then do message passing for this created datatype. However, when I tried to broadcast the initialized data from rank 0, I found that part of the received data at other ranks are not correct. Could you please help me take a look at my code and suggest possible errors I made? Thanks a lot!

-----------
//definition of datatype:
-----------
typedef struct paramtwo {
int exist;
double phi0;
double ap;
double r0;
double rc_low;
double rc;
} PARAMTWO;

PARAMTWO **para2;// global variable

//in main.cpp:
----------
void main(){
......
MPI_Datatype paramtwompi;
define_MPI_Paramtwo(&paramtwompi);

para2= (PARAMTWO **)(malloc(NTYPEMAX*sizeof(PARAMTWO*)));
for(i=0;i<NTYPEMAX;i++){
para2[i]=(PARAMTWO*)(malloc(NTYPEMAX*sizeof(PARAMTWO)));
}

if(myrank==0) initialize_para2(); //initialize para2[][] values at rank 0
MPI_Bcast(&(para2[0][0]), (NTYPEMAX*NTYPEMAX), paramtwompi, 0, MPI_COMM_WORLD);

...... output from all ranks ......

}

int define_MPI_Paramtwo(MPI_Datatype *paramtwompi){
int blocklen[6]={1,1,1,1,1,1};
MPI_Aint disp[6];
MPI_Datatype type[6]={MPI_INT,MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE, MPI_DOUBLE};
PARAMTWO findsize[2];
MPI_Aint findsize_addr, exist_addr, phi0_addr, dumb_addr, ap_addr, r0_addr, rc_low_addr, rc_addr;

MPI_Get_address(&findsize[0], &findsize_addr);
MPI_Get_address(&(findsize[0]).exist, &exist_addr);
MPI_Get_address(&(findsize[0]).phi0, &phi0_addr);
MPI_Get_address(&(findsize[0]).ap, &ap_addr);
MPI_Get_address(&(findsize[0]).r0, &r0_addr);
MPI_Get_address(&(findsize[0]).rc_low, &rc_low_addr);
MPI_Get_address(&(findsize[0]).rc, &rc_addr);

disp[0]=exist_addr-findsize_addr;
disp[1]=phi0_addr-findsize_addr;
disp[2]=ap_addr-findsize_addr;
disp[3]=r0_addr-findsize_addr;
disp[4]=rc_low_addr-findsize_addr;
disp[5]=rc_addr-findsize_addr;


MPI_Type_create_struct(6, blocklen, disp, type, paramtwompi);
MPI_Type_commit(paramtwompi);

return 1;
}

void initialize_para2(){
for(i=1;i<=3;i++){
for(j=1;j<=3;j++){
para2[i][j].exist= ..;
para2[i][j].phi0 = ..;
... ...
para2[i][j].rc = ..;
}
}
}

==================================
From the output:

rank: 0 phi0,ap,r0,rc_low,rc: 0.075832 1.6752 3.64207 0 5
rank: 0 phi0,ap,r0,rc_low,rc: 0.807371 0.73124 4.49714 0 5.5
rank: 0 phi0,ap,r0,rc_low,rc: 0.974501 1.2846 3.08858 0 4
rank: 0 phi0,ap,r0,rc_low,rc: 0.807371 0.73124 4.49714 0 5.5
rank: 0 phi0,ap,r0,rc_low,rc: 0.066001 2.8757 4.31169 0 5
rank: 0 phi0,ap,r0,rc_low,rc: 0.581624 1.2566 3.25062 0 4
rank: 0 phi0,ap,r0,rc_low,rc: 0.974501 1.2846 3.08858 0 4
rank: 0 phi0,ap,r0,rc_low,rc: 0.581624 1.2566 3.25062 0 4
rank: 0 phi0,ap,r0,rc_low,rc: 0.085009 2.2124 4.20311 0 5.5

rank: 1 phi0,ap,r0,rc_low,rc: 0.075832 1.6752 3.64207 0 5
rank: 1 phi0,ap,r0,rc_low,rc: 0.807371 0.73124 4.49714 0 5.5
rank: 1 phi0,ap,r0,rc_low,rc: 0.974501 1.2846 3.08858 0 4
rank: 1 phi0,ap,r0,rc_low,rc: 0.807371 0 4.49714 0 5.5
rank: 1 phi0,ap,r0,rc_low,rc: 0.066001 0 4.31169 0 5
rank: 1 phi0,ap,r0,rc_low,rc: 0.581624 0 3.25062 0 4
rank: 1 phi0,ap,r0,rc_low,rc: 0.974501 1.2846 3.08858 0 4
rank: 1 phi0,ap,r0,rc_low,rc: 0.581624 1.2566 3.25062 0 4
rank: 1 phi0,ap,r0,rc_low,rc: 0.085009 2.2124 4.20311 0 5.5

the problem lies in the second data column, last 4~6 rows, their values are actually zero, while all other data are correct.
The partially correct data from other ranks indicates that the Broadcast has been performed, however, I don't understand how can partial data be wrong.
So my question is, why the broadcast partially fails? What did I do wrong in my coding? Thanks for the help!
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #847
Difficulty: Medium
Proximity marketing is the localized wireless distribution of advertising content associated with a particular place.
True or False?

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

A $(( expression )) bug?

This is for the big guns... I have been modifying AudioScope.sh to bring it inline with more current practices. I hit a bug which IS not present in the original code but was after modification. Shell check first:- #!/bin/sh txt="1234567890" echo "$(( $txt ))" echo "$(( ${#txt} - 1 ))" echo... (17 Replies)
Discussion started by: wisecracker
17 Replies

2. Programming

C++ Bug probably scope problem

Hello, I have some difficulty to understand the scope of this program adapted from C++ book of D.S. Malik I am reading. I put the header and the main program as attachment to save space. My problem is the output:$ ./prog1009_die Line 4: Not yet rolled, die1 gets default number: 1 Line 5: Not... (5 Replies)
Discussion started by: yifangt
5 Replies

3. Shell Programming and Scripting

How to fix this bug?

Hi gurus, I have script as below: #!/bin/ksh while : do cat /dev/null > srcfile exit_time=`TZ=GMT-20 date +%Y%m%d1950` cur_time=`date +%Y%m%d%H%M` flag=1 if ; then ... (7 Replies)
Discussion started by: ken6503
7 Replies

4. Programming

is this a bug of g++?

Hello, Im using the g++(g++ Ubuntu/Linaro 4.4.4-14ubuntu5 4.4.5) and im trying to compile a small snippet code and got into an endless loop.I recompiled that in VS2010 under Windows 7 and the answer is as expected.so i wonder is this a bug of g++?here is my code. #include<iostream> using... (5 Replies)
Discussion started by: homeboy
5 Replies

5. UNIX for Dummies Questions & Answers

where's the bug?

#!/bin/bash if then #echo "infinite loop" exit 0 fi when I run this file I get the following error: ./test_infinite_loop: line 5: syntax error near unexpected token `fi' ./test_infinite_loop: line 5: `fi' :confused: (4 Replies)
Discussion started by: jon80
4 Replies

6. AIX

bug in 43 ???

xxxxserver# lsattr -El inet0 | grep 255.240.0.0,32.224.0.0,32.78.120.254 | grep '.40' route net,-hopcount,1,-netmask,255.240.0.0,32.224.0.0,32.78.120.254 How this is possible? (1 Reply)
Discussion started by: itik
1 Replies

7. Shell Programming and Scripting

Is it a bug ..?

Hi All, I am using Red Hat Linux on my servers. The problem that I am facing is, sometimes the /opt usage on the server shows used percentage as 100% , when actually it is simply 20%. When I reboot the system, it comes back to 20%.Is this a bug in the system or my settings have gone wrong... (1 Reply)
Discussion started by: nua7
1 Replies

8. Shell Programming and Scripting

Is this a bug or a limitation?

Hi, I'm having a problem with a while loop syntax that doesn't seem to loop correctly. TODAY=`date +%d%m%Y` while read hostname #for hostname in $(cat $CONFIG) do OUTFILE=/tmp/health_check.$hostname.$TODAY if then touch $OUTFILE func_header else rm $OUTFILE ... (2 Replies)
Discussion started by: gilberteu
2 Replies

Featured Tech Videos