Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: [OMPI users] RE : Problems with MPI_Init_Thread(...)
From: Sébastien Boisvert (sebastien.boisvert.3_at_[hidden])
Date: 2011-09-19 08:37:23


Hello,

You need to call MPI_Init before calling MPI_Init_thread.

According to http://cw.squyres.com/columns/2004-02-CW-MPI-Mechanic.pdf (Past MPI Mechanic Columns written by Jeff Squyres)
only 3 functions that can be called before calling MPI_Init and they are:

- MPI_Initialized
- MPI_Finalized
- MPI_Get_version

This information is also listed in Section 8.7 (page 291) in the MPI 2.2 book ( http://www.mpi-forum.org/docs/mpi-2.2/mpi22-report.pdf ).

   Sébastien

     http://github.com/sebhtml/ray

> ________________________________________
> De : users-bounces_at_[hidden] [users-bounces_at_[hidden]] de la part de devendra rai [rai.devendra_at_[hidden]]
> Date d'envoi : 19 septembre 2011 04:15
> À : Open MPI Users
> Objet : [OMPI users] Problems with MPI_Init_Thread(...)
>
> Hello Community,
>
> I am building an application which uses MPI_Ssend(...) and MPI_Recv(...) in threads. So, there is more than one thread which invokes MPI functions.
>
> Based on Jeff's inputs, I rebuilt open-mpi with threads support:
>
> ./configure --enable-mpi-threads=yes --with-threads=posix ...
>
> I believe the above line would do the magic.
>
> Now, I learnt that I need to request thread support when initializing MPI application using MPI_Init_thread(...). This is my code fragment:
>
> int main(int argc, char *argv[])
> {
> int rank;
> int desired_thread_support = MPI_THREAD_MULTIPLE;
> int provided_thread_support;
>
> MPI_Init_thread(&argc, &argv, desired_thread_support, &provided_thread_support);
>
> MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
>
>
> I build my application, and run it on 3 nodes. However, I get this error:
>
> Sun Sep 18 22:25:11 2011[1,1]<stderr>:*** The MPI_Init_thread() function was called before MPI_INIT was invoked.
> Sun Sep 18 22:25:11 2011[1,1]<stderr>:*** This is disallowed by the MPI standard.
> Sun Sep 18 22:25:11 2011[1,1]<stderr>:*** Your MPI job will now abort.
> Sun Sep 18 22:25:11 2011[1,1]<stderr>:[Morpheus.OTZ:9910] Abort before MPI_INIT completed successfully; not able to guarantee that all other processes were killed!
>
> I did read some online examples, and API documentations, and nothing says that I will need to call MPI_Init(...) *followed by* MPI_Init_thread(...).
>
> I have open-mpi 1.4.3 from open-mpi official site, running on Linux kernel 2.6.37.6-0.7.
>
> I do not understand why this error is happening.
>
> Again, the next question is, Am I required to MPI_Init_thread everytime I create a new thread? If yes, will this call be the first line in the thread?
>
> Would be nice if someone can throw some pointers.
>
> Thanks a lot.
>
> Best,
>
> Devendra Rai
>
> ________________________________
>
>