<div dir="ltr">On Thu, Feb 14, 2013 at 1:25 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
My concern was if a bad implementation always did some terrible thing with locks (even if only one thread would ever exist) thus hurting performance.<br>
<br>
Is there no way to just tell MPI there ARE and WILL be no threads?<br></blockquote><div><br></div><div style>Yeah, MPI_THREAD_SINGLE, but there is nothing to lock when using MPI_THREAD_FUNNELED. I figure that if the user intends to make calls from threads, they should call MPI_Init before PetscInitialize().</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Barry<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Feb 14, 2013, at 1:22 PM, Jed Brown <<a href="mailto:jedbrown@mcs.anl.gov">jedbrown@mcs.anl.gov</a>> wrote:<br>
<br>
> On Thu, Feb 14, 2013 at 1:16 PM, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
><br>
> Do we really ALWAYS want to call this version even if we are not monkeying with threads at ALL?<br>
><br>
> Thanks<br>
><br>
> Barry<br>
><br>
> ierr = MPI_Initialized(&flag);CHKERRQ(ierr);<br>
> if (!flag) {<br>
> if (PETSC_COMM_WORLD != MPI_COMM_NULL) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"You cannot set PETSC_COMM_WORLD if you have not initialized MPI first");<br>
> #if defined(PETSC_HAVE_MPI_INIT_THREAD)<br>
> {<br>
> PetscMPIInt provided;<br>
> ierr = MPI_Init_thread(argc,args,MPI_THREAD_FUNNELED,&provided);CHKERRQ(ierr);<br>
> }<br>
> #else<br>
> ierr = MPI_Init(argc,args);CHKERRQ(ierr);<br>
><br>
> The implementation of MPI_Init just probes around the environment and calls MPI_Init_thread. There is no performance advantage of MPI_THREAD_SINGLE over MPI_THREAD_FUNNELED so I think the code here is fine.<br>
<br>
</div></div></blockquote></div><br></div></div>