Open MPI logo

Open MPI User's Mailing List Archives

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

From: Bert Wesarg (wesarg_at_[hidden])
Date: 2007-05-02 14:38:54


I quote from the SUSv3:

Many functions provide an error number in errno, which has type int and is
defined in <errno.h>. The value of errno shall be defined only after a
call to a function for which it is explicitly stated to be set and until
it is changed by the next function call or if the application assigns it a
value. The value of errno should only be examined when it is indicated to
be valid by a function's return value. Applications shall obtain the
definition of errno by the inclusion of <errno.h>. No function in this
volume of IEEE Std 1003.1-2001 shall set errno to 0. The setting of errno
after a successful call to a function is unspecified unless the
description of that function specifies that errno shall not be modified.

So in my understanding errno is only valid after you called a function
that explicitly set errno in case of an *error* and only if the function
returns an error indicator. In your example you call MPI_Init() which the
manpage says nothing about errno and therefor the errno value is
unspeciefied after the call and has no meaning.


Chudin, Eugene wrote:
> I am trying to experiment with openmpi and following trivial code
> (although runs) affects value of errno
> #include <cerrno>
> #include <mpi.h>
> int main(int argc, char** argv)
> {
> int _procid, _np;
> std::cout << "errno=\t" << errno << std::endl;
> MPI_Init(&argc, &argv);
> std::cout << "errno=\t" << errno << "\tafter MPI_Init()\t" <<
> std::endl;
> MPI_Comm_rank (MPI_COMM_WORLD, &_procid);
> MPI_Comm_size (MPI_COMM_WORLD, &_np);
> std::cout << "errno msg=\t" << strerror(errno) << "\tprocessor=\t"
> << _procid << std::endl;
> MPI_Finalize();
> return 0;
> }
> Compiled with
> mpiCC -Wall test.cpp -o test
> Produces following output when run just on single processor using
> mpirun -np 1 --prefix /toolbox/openmpi ./test
> errno= 0
> errno= 2 after MPI_Init()
> errno msg= No such file or directory processor= 0
> When run on two processors using
> mpirun -np 2 --prefix /toolbox/openmpi ./test
> errno= 0
> errno= 0
> errno= 11 after MPI_Init()
> errno= 115 after MPI_Init()
> errno msg= Operation now in progress processor= 0
> errno msg= Resource temporarily unavailable processor= 1
> The output of ompi_info --all is attached
> <<ompi_info.txt>>
> ------------------------------------------------------------------------------
> Notice: This e-mail message, together with any attachments, contains
> information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
> New Jersey, USA 08889), and/or its affiliates (which may be known
> outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD
> and in Japan, as Banyu - direct contact information for affiliates is
> available at that may be
> confidential, proprietary copyrighted and/or legally privileged. It is
> intended solely for the use of the individual or entity named on this
> message. If you are not the intended recipient, and have received this
> message in error, please notify us immediately by reply e-mail and then
> delete it from your system.
> ------------------------------------------------------------------------------
> ------------------------------------------------------------------------
> _______________________________________________
> users mailing list
> users_at_[hidden]