Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: [OMPI users] random MPI_UNIVERSE_SIZE
From: Mathieu Gontier (mg.mailing-list_at_[hidden])
Date: 2010-02-18 09:31:06


Hello,

I am trying to use MPI_Comm_spawn (MPI-2 standard only) and I have an
problem when I use MPI_UNIVERSE_SIZE. Here my code:

int main( int argc, char *argv[] )
{
   int wsize=0, wrank=-1 ;
   int usize=0, urank=-1 ;
   int ier ;
   int usize_attr=0, flag=0 ;
   MPI_Comm MPI_COMM_UNIVERSE;
   ier = MPI_Init( &argc, &argv ) ;
   ier = MPI_Comm_size( MPI_COMM_WORLD, &wsize ) ;
   ier = MPI_Comm_rank( MPI_COMM_WORLD, &wrank ) ;
   ier = MPI_Comm_get_attr( MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, (void*)
&usize_attr, &flag ) ;
   if ( !flag ) { printf( "[manager][error] This MPI does not support
MPI_UNIVERSE_SIZE.\n" ) ; return 1 ; }
   if( wrank==0 ) {
       ier = MPI_Comm_spawn( "./worker", argv, ( wsize/2 > 2 ? wsize/2 :
2 ), MPI_INFO_NULL, 0, MPI_COMM_SELF, &MPI_COMM_UNIVERSE,
MPI_ERRCODES_IGNORE);
       ier = MPI_Comm_size( MPI_COMM_UNIVERSE, &usize ) ;
       ier = MPI_Comm_rank( MPI_COMM_UNIVERSE, &urank ) ;
   }
   printf( "[manager] I am the process %d on %d in world (universe attr
size: %d) and %d on %d in universe\n", wrank, wsize, usize_attr, urank,
usize ) ;
   MPI_Finalize();
   return 0;
}

When I call MPI_Comm_get_attr() with MPI_UNIVERSE_SIZE, my variable
u_size_attr is random. Any idea?

Thank you.