Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: Re: [OMPI users] function fgets hangs a mpi program when it is used ompi-ps command
From: Ralph Castain (rhc_at_[hidden])
Date: 2010-09-22 10:24:13


Printouts of less than 100 bytes would be unusual...but possible

On Wed, Sep 22, 2010 at 8:15 AM, Jeff Squyres <jsquyres_at_[hidden]> wrote:

> Are you running on machines with OpenFabrics devices (that Open MPI is
> using)?
>
> Is ompi-ps printing 100 bytes or more?
>
> What does ps show when your program is hung?
>
>
>
> On Sep 17, 2010, at 3:13 PM, Matheus Bersot Siqueira Barros wrote:
>
> > Open MPI Version = 1.4.2
> > OS = Ubuntu 10.04 LTS and CentOS 5.3
> >
> > When I run the mpi program below in the terminal, the function fgets
> hangs.
> > How do I know it? I do a printf before and later the call of fgets and
> only the message "before fgets()" is showed.
> >
> > However, when I run the same program at Eclipse 3.6 with CDT
> 7.0.0.201006141710 or using gdb it runs normally.
> > If you change the command in the function popen to another one(for
> instance: "ls -l"), it will run correctly.
> >
> > I use the following commands to compile and run the program:
> >
> > compile : mpicc teste.c -o teste.run
> >
> > run : mpirun -np 4 ./teste.run
> >
> >
> > Does anyone know why the program behaves like that?
> >
> > Thanks in advance,
> >
> > Matheus Bersot.
> >
> > MPI_PROGRAM:
> >
> > #include <stdio.h>
> > #include "mpi.h"
> >
> > int main(int argc, char *argv[])
> > {
> > int rank, nprocs;
> > FILE * pFile = NULL;
> > char mystring [100];
> >
> > MPI_Init(&argc,&argv);
> > MPI_Comm_size(MPI_COMM_WORLD,&nprocs);
> > MPI_Comm_rank(MPI_COMM_WORLD,&rank);
> >
> > if(rank == 0)
> > {
> > pFile = popen ("ompi-ps" , "r");
> > if (pFile == NULL) perror ("Error opening file");
> > else {
> > while(!feof(pFile))
> > {
> > printf("before fgets()\n");
> > fgets (mystring , 100 , pFile);
> > printf("after fgets()\n");
> > puts (mystring);
> > }
> > pclose (pFile);
> > }
> > }
> >
> > MPI_Finalize();
> > return 0;
> > }
> > _______________________________________________
> > users mailing list
> > users_at_[hidden]
> > http://www.open-mpi.org/mailman/listinfo.cgi/users
>
>
> --
> Jeff Squyres
> jsquyres_at_[hidden]
> For corporate legal information go to:
> http://www.cisco.com/web/about/doing_business/legal/cri/
>
>
> _______________________________________________
> users mailing list
> users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/users
>