Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] Problem with MPI_Send and MPI_Recv
From: Sofia Aparicio Secanellas (saparicio_at_[hidden])
Date: 2008-09-17 03:51:17


Hello Gus,

Thank you very much for your answer but I do not think that this is the
problem.I have changed everything in a C program and I obtain the same
result.

Does anyone have any idea about the problem?

Sofia

----- Original Message -----
From: "Gus Correa" <gus_at_[hidden]>
To: "Open MPI Users" <users_at_[hidden]>
Sent: Tuesday, September 16, 2008 9:42 PM
Subject: Re: [OMPI users] Problem with MPI_Send and MPI_Recv

> Hello Sofia and list
>
> I am not a C++ person, I must say.
> However, I noticed that you wrote the program in C++,
> compiled it with the mpiCC (C++) compiler wrapper,
> but your MPI calls are written with the MPI C binding syntax,
> not the MPI C++ binding syntax.
>
> E.g. :
>
> MPI_Send(&sum,1,MPI_INT,0,1,MPI_COMM_WORLD);
>
> instead of something like this:
>
> comm.Send(&sum,1,MPI::INT,0,1);
>
> I wonder if this mixed C++ / C environment may have caused some of the
> trouble,
> although I am not sure about that.
>
> Since the specific C++ commands that you use are basically for
> printing messages, it may be easier to transform the program into
> a C program, by replacing the appropriate include files
> and the C++ specific I/O commands by C commands,
> and then compile the program again with mpicc.
> An alternative is to write the MPI function calls in the C++ binding
> syntax.
>
> I hope this helps.
>
> Gus Correa
>
> --
> ---------------------------------------------------------------------
> Gustavo J. Ponce Correa, PhD - Email: gus_at_[hidden]
> Lamont-Doherty Earth Observatory - Columbia University
> P.O. Box 1000 [61 Route 9W] - Palisades, NY, 10964-8000 - USA
> ---------------------------------------------------------------------
>
>
> Sofia Aparicio Secanellas wrote:
>
>> Hello,
>> I am new using MPI. I want to run a simple program (I enclose the
>> program) in 2 different computers. I have installed MPI in both
>> computers. I have compiled the program using:
>> mpiCC -o PruebaSumaParalela.out PruebaSumaParalela.cpp
>> I have copied the executable PruebaSumaParalela.out to my /home
>> directoy in both computers. Then I run:
>> mpirun -np 2 --host 10.4.5.123,edu_at_10.4.5.126 --prefix /usr/local
>> ./PruebaSumaParalela.out
>> The 10.4.5.123 computer prints:
>> Inicio
>> Inicio
>> totalnodes:2
>> mynode:0
>> Inicio Recv
>> totalnodes:2
>> mynode:1
>> Inicio Send
>> sum:375250
>> The edu_at_10.4.5.126 <mailto:edu_at_10.4.5.126> computer prints:
>> Inicio
>> Inicio
>> totalnodes:2
>> mynode:1
>> Inicio Send
>> sum:375250
>> totalnodes:2
>> mynode:0
>> Inicio Recv
>> But the program does not finish on any computer. It seems that the Send
>> and Recv does not work. Master computer is waiting to receive something
>> that the slave does not send.
>> Do you know what the problem could be ?
>> Thank you very much.
>> Sofia
>>
>>
>> No virus found in this outgoing message
>> Checked by PC Tools AntiVirus (4.0.0.26 - 10.100.007).
>> http://www.pctools.com/free-antivirus/
>>
>>------------------------------------------------------------------------
>>
>>#include<iostream.h>
>>#include<mpi.h>
>>int main(int argc, char ** argv){
>>int mynode, totalnodes;
>>int sum,startval,endval,accum;
>>printf("Inicio\n");
>>MPI_Status status;
>>MPI_Init(&argc,&argv);
>>MPI_Comm_size(MPI_COMM_WORLD, &totalnodes);
>>MPI_Comm_rank(MPI_COMM_WORLD, &mynode);
>>printf("totalnodes: %d\n",totalnodes);
>>printf("mynode: %d\n",mynode);
>>sum = 0;
>>startval = 1000*mynode/totalnodes+1;
>>endval = 1000*(mynode+1)/totalnodes;
>>for(int i=startval;i<=endval;i=i+1)
>>sum = sum + i;
>>if(mynode!=0){
>>printf("Inicio Send\n");
>>printf("sum: %d\n",sum);
>>MPI_Send(&sum,1,MPI_INT,0,1,MPI_COMM_WORLD);
>>printf("Send sum\n");
>>}
>>else
>>for(int j=1;j<totalnodes;j=j+1){
>>printf("Inicio Recv\n");
>>MPI_Recv(&accum,1,MPI_INT,j,1,MPI_COMM_WORLD, &status);
>>printf("RECV accum\n");
>>sum = sum + accum;
>>printf("Sum\n");
>>}
>>printf("Final\n");
>>if(mynode == 0)
>>cout << "The sum from 1 to 1000 is: " << sum << endl;
>>MPI_Finalize();
>>}
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>users mailing list
>>users_at_[hidden]
>>http://www.open-mpi.org/mailman/listinfo.cgi/users
>>
>
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users
>
>
>
> No virus found in this incoming message
> Checked by PC Tools AntiVirus (4.0.0.26 - 10.100.007).
> http://www.pctools.com/free-antivirus/

No virus found in this outgoing message
Checked by PC Tools AntiVirus (4.0.0.26 - 10.100.007).
http://www.pctools.com/free-antivirus/