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

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.


Devendra Rai