On Oct 21, 2004, at 10:20 AM, Bogdan Costescu wrote:
> On Thu, 21 Oct 2004, Josh Hursey wrote:
>
>> LAM/MPI redirects stderr and stdout from all 'children' to 'parent'
>> node, so when a child prints a message to stdout it is actually
>> printed
>> on the parents terminal.
>
> Hmm, let's be more precise: the stdout/stderr of _mpirun_ is connected
> to the terminal.
Yes that's what I meant, thanks.
>
>> What I would like to do is, in software, take this stream and put it
>> into a file. You can do this in *nix via command line redirection, but
>> I need to do it in C.
>
> This is the part that is not very clear. Where do you want this C
> program to run with respect to mpirun and the MPI application ?
This MPI program will run on rank 0 with mpirun. So just after MPI_Init
I call
freopen() to route all stdio to a file. I am able to access the stderr
and stdout
from the current process, but I need to access the incomming streams
from other ranks
so I can route them to the same file [or if necessary another file] on
the rank 0 node.
> Do you want to do this in the MPI application itself ? I don't think
> that this is possible; the most reliable way would be to send through
> MPI the strings from n1-nX nodes to n0 and make only n0 write into a
> file - then you are already aware of the ordering problem :-)
freopen() was the first solution that occurred to be for this problem
since it is
least friction, and reduces the amount of code that has to be
changed/added to the existing
structure.
Sending the strings over MPI calls was my second option, but I wanted
to make sure that
the first option was invalid before writing a wrapper for
printf/fprintf.
The ordering problem is a bit of an issue, but we just need a simple
central 'log' of what
happens on each node [mostly for debugging]. In general messages to
stdout are fairly infrequent,
so we decided to live with disordering of messages for this central log
since each message has a
node rank and time stamp associated with it.
Thanks for your help,
Josh
>
> --
> Bogdan Costescu
>
> IWR - Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen
> Universitaet Heidelberg, INF 368, D-69120 Heidelberg, GERMANY
> Telephone: +49 6221 54 8869, Telefax: +49 6221 54 8868
> E-mail: Bogdan.Costescu_at_[hidden]
>
>
> _______________________________________________
> This list is archived at http://www.lam-mpi.org/MailArchives/lam/
|