Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: Re: [OMPI users] How to create multi-thread parallel program using thread-safe send and recv?
From: Eugene Loh (Eugene.Loh_at_[hidden])
Date: 2009-09-22 13:32:50


guosong wrote:
Thanks for responding. I used a linux cluster. I think I would like to create a model that is multithreaded and each thread can make MPI calls. I attached test code as follow. It has two pthreads and there are MPI calls in both of those two threads. In the main function, there are also MPI calls. Should I use a full multithreading?
I guess so.  It seems like the created threads are expected to make independent/concurrent message-passing calls.  Do read the link I sent.  You need to convert from MPI_Init to MPI_Init_thread(), asking for a full-multithreaded model and checking that you got it.  Also note in main() that the MPI_Isend() calls should be matched with MPI_Wait() or similar calls.  I guess the parent thread will sit in such calls while the child threads do their own message passing.  Good luck.