[MPICH] I 'm trying to use threads in my MPI programs but....

Rajeev Thakur thakur at mcs.anl.gov
Tue Nov 14 08:53:50 CST 2006


With MPICH-1.2.4, an old version of MPICH, you can't call MPI functions
simultaneously from two threads (which is what not thread safe means). The
latest version of MPICH2 allows you to do that. You need to call
MPI_Init_thread with MPI_THREAD_MULTIPLE (and check what the function
returns as supported). I would recommend reading the portion of the MPI-2
standard that specifies how MPI and threads interact.
http://www.mpi-forum.org/docs/mpi-20-html/node162.htm
 
Rajeev
 


  _____  

From: owner-mpich-discuss at mcs.anl.gov
[mailto:owner-mpich-discuss at mcs.anl.gov] On Behalf Of Thati Ravi
Sent: Tuesday, November 14, 2006 6:29 AM
To: mpich-discuss at mcs.anl.gov
Subject: [MPICH] I 'm trying to use threads in my MPI programs but....


Hi all,

 Our cluster is an AIX5.1 and configured with mpich-1.2.4 .
I am trying to execute a program in which each process creates one thread.
And task of the thread is that it will also be invoking the MPI routines as
same as the main thread. 
The sample code of the program is like this :

main()
{
MPI_Init(&argc,&argv);
if(rank==0)
{
MPI_Send(&sendbuf,1,MPI_INT,1,111,MPI_COMM_WORLD);
pthread_create(&pth,NULL,&recv_thread,void *params); 
................ rest of the program calls some other MPI routines.
}
else
{
some mpi calls from other processes and threads for them similar to the root
processs.
.......
}
return 0;
}
 
And the thread code is like this for the root process and is similar with
other process also.


void * recv_thread(void *info)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
MPI_Irecv(&recvbuf,1,MPI_INT,1,222,MPI_COMM_WORLD,&req); 
...... and executes some MPI routines like MPI_test, MPI_Wait
}
This way each process will have its thread to execute the MPI routines.

My  problem is that, the program is successfully executing for the
communicator size as two, I mean with two processes. 
But it is faiing for processes>2. Some of the mpi routines are not getting
completed like MPI_Test() even though the correspoding operation has got
finished.


I have read somewhere that the MPICH library should be thread-safe. I don't
understand what is it mean by thread-safe. 
If at all the mpich is to be configured as thread-safe inorder to execute
MPI routines in threads of the programs, how can I know whether my mpich is
thread-safe or not?
How many threads can be created and allowed to use MPI routines for a single
process in a application ? any such conditions ? how to know if they are
there 

Any help is appreciated.


Ravi.Thati
Our Attempts may fail but we should not fail to attempt. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20061114/fbb507b2/attachment.htm>


More information about the mpich-discuss mailing list