Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: Re: [OMPI users] sending message to the source(0) from other processors
From: Win Than Aung (keshunli_at_[hidden])
Date: 2008-12-23 14:56:16


thanks for your reply jeff
so i tried following

#include <stdio.h>
#include <mpi.h>

int main(int argc, char **argv) {
 int np, me, sbuf = -1, rbuf = -2,mbuf=1000;
int data[2];
 MPI_Init(&argc,&argv);
 MPI_Comm_size(MPI_COMM_WORLD,&np);
 MPI_Comm_rank(MPI_COMM_WORLD,&me);
 if ( np < 2 ) MPI_Abort(MPI_COMM_WORLD,-1);

 if ( me == 1 ) MPI_Send(&sbuf,1,MPI_INT,0,344,MPI_COMM_WORLD);
if(me==2) MPI_Send( &mbuf,1,MPI_INT,0,344,MPI_COMM_WORLD);
if ( me == 0 ) {

MPI_Recv(data,2,MPI_INT,MPI_ANY_SOURCE,344,MPI_COMM_WORLD,MPI_STATUS_IGNORE);
 }

 MPI_Finalize();

 return 0;
}

it can successfuly receive the one sent from processor 1(me==1) but it
failed to receive the one sent from processor 2(me==2)
mpirun -np 3 hello

thanks
winthan
On Tue, Dec 23, 2008 at 1:15 PM, Jeff Squyres <jsquyres_at_[hidden]> wrote:

> This looks like a question for the MPICH2 developers.
>
> Specifically, it looks like you are using MPICH2, not Open MPI. They are
> entirely different software packages maintained by different people -- we're
> not really qualified to answer questions about MPICH2. The top-level API is
> the same between the two (meaning that you can compile and run your app in
> either Open MPI or MPICH2), but that's where the similarities end.
>
>
>
> On Dec 23, 2008, at 2:07 PM, Win Than Aung wrote:
>
> PS: extra question
>> qsub -I -q standby -l select=1:ncpus=8
>> mpirun -np 4 ./hello
>> running mpdallexit on steele-a137.rcac.purdue.edu
>> LAUNCHED mpd on steele-a137.rcac.purdue.edu via
>> RUNNING: mpd on steele-a137.rcac.purdue.edu
>> steele-a137.rcac.purdue.edu_36959 (172.18.24.147)
>> time for 100 loops = 2.98023223877e-05 seconds
>> too few entries in machinefile
>>
>> the mpi program supposed to print 4 hello msg since there r four
>> processors.
>> but for some reasons, it doesn't print
>> thanks
>> winthan
>>
>>
>> On Tue, Dec 23, 2008 at 1:23 PM, Eugene Loh <Eugene.Loh_at_[hidden]> wrote:
>> Win Than Aung wrote:
>>
>> MPI_Recv(....) << is it possible to receive the message sent from other
>> sources? I tried MPI_ANY_SOURCE in place of source but it doesn't work out
>>
>> Yes of course. Can you send a short example of what doesn't work? The
>> example should presumably be less than about 20 lines. Here is an example
>> that works:
>>
>> % cat a.c
>> #include <stdio.h>
>> #include <mpi.h>
>>
>> int main(int argc, char **argv) {
>> int np, me, sbuf = -1, rbuf = -2;
>>
>> MPI_Init(&argc,&argv);
>> MPI_Comm_size(MPI_COMM_WORLD,&np);
>> MPI_Comm_rank(MPI_COMM_WORLD,&me);
>> if ( np < 2 ) MPI_Abort(MPI_COMM_WORLD,-1);
>>
>> if ( me == 1 ) MPI_Send(&sbuf,1,MPI_INT,0,344,MPI_COMM_WORLD);
>> if ( me == 0 ) {
>>
>> MPI_Recv(&rbuf,1,MPI_INT,MPI_ANY_SOURCE,344,MPI_COMM_WORLD,MPI_STATUS_IGNORE);
>> if ( rbuf == sbuf ) printf("Send/Recv self passed\n");
>> else printf("Send/Recv self FAILED\n");
>> }
>>
>> MPI_Finalize();
>>
>> return 0;
>> }
>> % mpicc a.c
>> % mpirun -np 2 a.out
>> Send/Recv self passed
>> %
>> _______________________________________________
>> 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
>>
>
>
> --
> Jeff Squyres
> Cisco Systems
>
>
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users
>