Sequential Sections II


Up: Tools for writing libraries Next: Sequential Sections III Previous: Sequential Sections



MPI_Attr_get( comm, MPE_Seq_keyval, (void *)&local_comm, 
              &flag );
if (!flag) {
    /* This expects a communicator to be a pointer */
    MPI_Comm_dup( comm, &local_comm );
    MPI_Attr_put( comm, MPE_Seq_keyval, 
                  (void *)local_comm );
    }
MPI_Comm_rank( comm, &lidx );
MPI_Comm_size( comm, &np );
if (lidx != 0) {
    MPI_Recv( NULL, 0, MPI_INT, lidx-1, 0, local_comm, 
              &status );
    }
/* Send to the next process in the group unless we 
   are the last process in the processor set */
if ( (lidx % ng) < ng - 1 && lidx != np - 1) {
    MPI_Send( NULL, 0, MPI_INT, lidx + 1, 0, local_comm );
    }
}



Up: Tools for writing libraries Next: Sequential Sections III Previous: Sequential Sections