[mpich-discuss] mpich2 and sending message from a task to itself

Rajeev Thakur thakur at mcs.anl.gov
Thu May 29 15:29:36 CDT 2008


The send-to-yourself needs to be either a nonblocking send or the receive
must be posted before the send. MPI_Send will block for the receive to be
posted. 

Rajeev

> -----Original Message-----
> From: owner-mpich-discuss at mcs.anl.gov 
> [mailto:owner-mpich-discuss at mcs.anl.gov] On Behalf Of Bryan Putnam
> Sent: Thursday, May 29, 2008 3:26 PM
> To: mpich-discuss at mcs.anl.gov
> Subject: [mpich-discuss] mpich2 and sending message from a 
> task to itself
> 
> Hi,
> 
> I've found that if I take a standard "hello, world" program 
> (where master 
> sends "hello" to all tasks except itself), and modify it so 
> that master 
> sends "hello" to all tasks including itself, I get a 
> "MPI_Send" error when 
> using mpich2-1.0.7, of the form
> 
> Fatal error in MPI_Send: Error message texts are not 
> available[cli_0]: 
> aborting job:
> 
> From what we can tell, sending a message to yourself is 
> allowed by the MPI 
> standard:
> 
> From MPI: The Complete Reference (I-37):
> 
> +++++++++++++++
> The range of valid values for [the destination argument] is 0..n-1,
> where n is the number of processes in the group. This range includes
> the rank of the sender: if [the communicator] is an intracommunicator,
> then a process may send a message to itself.
> 
> MPI::COMM_WORLD is indeed an intracommunicator.
> +++++++++++++++
> 
> For your enjoyment, I've included my original code, and followed it 
> by the modified code.
> 
> Thanks!
> Bryan
> 
> 
>       program hellof
>       include 'mpif.h'
>       integer me, nt, mpierr, status(MPI_STATUS_SIZE)
>       integer tag
>       character*12  message, inmsg
>   
>       call MPI_INIT(mpierr)
>       call MPI_COMM_SIZE(MPI_COMM_WORLD, nt, mpierr)
>       call MPI_COMM_RANK(MPI_COMM_WORLD, me, mpierr)
>       tag = 1
>   
>       if(me .eq. 0) then
>         message = 'Hello world!'
>         do i=1,nt-1
>            call MPI_SEND(message, 12, MPI_CHARACTER, i, tag,
>      &                   MPI_COMM_WORLD, mpierr)
>         enddo
>         write(6,*) 'node', me, ': ', message
>       else
>         call MPI_RECV(inmsg, 12, MPI_CHARACTER, 0, tag,
>      &                MPI_COMM_WORLD, status, mpierr)
>         write(6,*) 'node', me, ': ', inmsg
>       endif
>       call MPI_FINALIZE(mpierr)
>       end 
> 
> 
> Modified code:
> 
> 
>       program hellof
>       include 'mpif.h'
>       integer me, nt, mpierr, status(MPI_STATUS_SIZE)
>       integer tag
>       character*12  message, inmsg
>   
>       call MPI_INIT(mpierr)
>       call MPI_COMM_SIZE(MPI_COMM_WORLD, nt, mpierr)
>       call MPI_COMM_RANK(MPI_COMM_WORLD, me, mpierr)
>       tag = 1
>   
>       if(me .eq. 0) then
>         message = 'Hello world!'
>         do i=0,nt-1
>            call MPI_SEND(message, 12, MPI_CHARACTER, i, tag,
>      &                   MPI_COMM_WORLD, mpierr)
>         enddo
>         write(6,*) 'node', me, ': ', message
>       endif
>       call MPI_RECV(inmsg, 12, MPI_CHARACTER, 0, tag,
>      &              MPI_COMM_WORLD, status, mpierr)
>         write(6,*) 'node', me, ': ', inmsg
>       call MPI_FINALIZE(mpierr)
>       end
> 
> 
> 




More information about the mpich-discuss mailing list