title: MPI_Rsend:how to know that a receive buffer is already posted
body: <p>By <a href="https://www.open-mpi.org/doc/v1.8/man3/MPI_Rsend.3.php" rel="nofollow noreferrer">MPI_Rsend man papers</a>,in order to use MPI_Rsend,we need to guarantee that a receive is already posted. It is an error if the receive is not posted before the ready send is called.But how to guarantee that a receive is already posted ???.I try to find some examples about MPI_Rsend,but i can not find anything.And how to get this error ? <br>
  In this link <a href="https://stackoverflow.com/questions/34223226/mpi-rsend-not-raising-error-when-it-should">MPI_RSend_error</a> ,finally some one said that : &quot;<em>Simply do not use MPI_Rsend - it is an archaism, its behaviour is not well-defined, and it was made obsolete by all of the protocol optimisations in modern MPI libraries</em>&quot;.So,which MPI libraries exactly implement RSend ? In fact,using MPI_Rsend will give better performance than MPI_Send in some algorithms.<br>
  Example code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>void AllGather_ring_RSend(void* data, int count, MPI_Datatype datatype,MPI_Comm communicator) 
  {
    int me; 
    MPI_Comm_rank(communicator, &amp;me); 
    int world_size; 
    MPI_Comm_size(communicator, &amp;world_size);
    int next=me+1;
    if(next&gt;=world_size)
        next=0;
    int prev=me-1;
    if(prev&lt;0)
        prev=world_size-1;
    int i,curi=me;
    for(i=0;i&lt;world_size-1;i++)
    {
       MPI_Rsend(data+curi*sizeof(int), count, datatype, next, 0, communicator);
       curi=curi-1;
       if(curi&lt;0)
           curi=world_size-1;
       MPI_Recv(data+curi*sizeof(int), count, datatype, prev, 0, communicator, MPI_STATUS_IGNORE);     
    }
  }
  void main(int argc, char** argv) {
      char processor_name[MPI_MAX_PROCESSOR_NAME];
      MPI_Init(&amp;argc,&amp;argv); 
      int world_rank,world_size,namelen; 
      MPI_Comm_size(MPI_COMM_WORLD, &amp;world_size);
      MPI_Comm_rank(MPI_COMM_WORLD, &amp;world_rank);
      int* buff=(int*) malloc(world_size*sizeof(int));
        int i;
        for (i = 0; i &lt; world_size; i++) {
            buff[i]=world_rank;
        }
        if(world_rank==0)
        for (i = 0; i &lt; world_size; i++) 
           printf("%d\n",buff[i]);
      MPI_Barrier(MPI_COMM_WORLD); 
      AllGather_ring_RSend(buff,1,MPI_INT,MPI_COMM_WORLD);
      MPI_Barrier(MPI_COMM_WORLD);
      MPI_Finalize();   
  }</code></pre>
  </div>
  </div>
  </p>
  <p>In this code,is receive process already posted???</p>