PLZ help to solve this problem, i m new in parallel programming...............<br><br><br>#include <iostream><br>#include <vector><br>#include <string><br>#include"mpi.h"<br>using namespace std;<br>
<br>main(int argc, char *argv[])<br>{<br> MPI::Status status;<br> MPI::Init(argc,argv);<br> int myrank = MPI::COMM_WORLD.Get_rank();<br> int numprocs = MPI::COMM_WORLD.Get_size();<br> MPI_Datatype type[6]={MPI_CHAR,MPI_CHAR,MPI_CHAR,MPI_CHAR,MPI_CHAR,MPI_CHAR};<br>
MPI_Datatype strtype;<br> int blocklen[6]={1,1,1,1,1,1};<br> MPI_Aint disp[6]={0,1,2,3,4,5};<br> MPI_Type_struct(6,blocklen,disp,type,&strtype);<br> MPI_Type_commit(&strtype);<br>
vector<string> SS;<br> if(myrank == 0){<br> SS.push_back("The10");<br> SS.push_back("The20");<br> SS.push_back("The30");<br><br> cout << "At root Node: "<< endl;<br>
<br> int ii;<br> for(ii=0; ii < SS.size(); ii++)<br> {<br> cout << SS[ii] << endl;<br> }<br> <br> MPI::COMM_WORLD.Send(&SS[0][0],1,strtype, 1, 1);<br> MPI::COMM_WORLD.Send(&SS[1][0],1,strtype, 1, 1);<br>
MPI::COMM_WORLD.Send(&SS[2][0],1,strtype, 1, 1);<br> }<br>else{<br> SS.resize(6);<br> MPI::COMM_WORLD.Recv(&SS[0][0],1,strtype,0,1);<br> MPI::COMM_WORLD.Recv(&SS[1][0],1,strtype,0,1);<br>
MPI::COMM_WORLD.Recv(&SS[2][0],1,strtype,0,1);<br> int i,j;<br> cout << "At worker Node: " << endl;<br> for(i=0; i < 3; i++){<br> for(j=0;j<6;j++){<br> cout << SS[i][j];<br>
}cout<<endl;<br> }<br> }<br> MPI::Finalize();<br>}<br><br><br><br><br>My O/P is :<br><br>mpirun -np 2 ./vDemo.out <br>At root Node: <br>The10<br>The20<br>The30<br>At worker Node: <br>The30<br>The30<br>
The30<br><br>But I want my O/P like:<br> mpirun -np 2 ./vDemo.out <br>At root Node: <br>The10<br>The20<br>The30<br>At worker Node: <br>The10<br>
The20<br>
The30<br><br>