<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.5730.11" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=032324814-14112006><FONT face=Arial
color=#0000ff size=2>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. <A
href="http://www.mpi-forum.org/docs/mpi-20-html/node162.htm">http://www.mpi-forum.org/docs/mpi-20-html/node162.htm</A></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=032324814-14112006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=032324814-14112006><FONT face=Arial
color=#0000ff size=2>Rajeev</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=032324814-14112006><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV><BR>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> owner-mpich-discuss@mcs.anl.gov
[mailto:owner-mpich-discuss@mcs.anl.gov] <B>On Behalf Of </B>Thati
Ravi<BR><B>Sent:</B> Tuesday, November 14, 2006 6:29 AM<BR><B>To:</B>
mpich-discuss@mcs.anl.gov<BR><B>Subject:</B> [MPICH] I 'm trying to use
threads in my MPI programs but....<BR></FONT><BR></DIV>
<DIV></DIV>Hi all,<BR><BR> Our cluster is an AIX5.1 and configured with
mpich-1.2.4 .<BR>I am trying to execute a program in which each process
creates one thread.<BR>And task of the thread is that it will also be invoking
the MPI routines as same as the main thread. <BR>The sample code of the
program is like this
:<BR><BR>main()<BR>{<BR>MPI_Init(&argc,&argv);<BR>if(rank==0)<BR>{<BR>MPI_Send(&sendbuf,1,MPI_INT,1,111,MPI_COMM_WORLD);<BR>pthread_create(&pth,NULL,&recv_thread,void
*params); <BR>................ rest of the program calls some other MPI
routines.<BR>}<BR>else<BR>{<BR>some mpi calls from other processes and threads
for them similar to the root processs.<BR>.......<BR>}<BR>return
0;<BR>}<BR> <BR>And the thread code is like this for the root process and
is similar with other process also.<BR><BR><BR>void * recv_thread(void
*info)<BR>{<BR>int
rank;<BR>MPI_Comm_rank(MPI_COMM_WORLD,&rank);<BR>MPI_Irecv(&recvbuf,1,MPI_INT,1,222,MPI_COMM_WORLD,&req);
<BR>...... and executes some MPI routines like MPI_test, MPI_Wait<BR>}<BR>This
way each process will have its thread to execute the MPI
routines.<BR><BR>My problem is that, the program is successfully
executing for the communicator size as two, I mean with two processes. <BR>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.<BR><BR><BR>I have read somewhere that the MPICH library should be
thread-safe. I don't understand what is it mean by thread-safe. <BR>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?<BR>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 <BR><BR>Any help is appreciated.<BR><BR
clear=all><BR>Ravi.Thati<BR>Our Attempts may fail but we should not fail to
attempt. </BLOCKQUOTE></BODY></HTML>