I agree that this solves most of my problems.  I still need MPI_QUERY_THREAD to be multi-thread-safe so I can distinguish between SERIALIZED and MULTIPLE inside of library calls though.  If you want me to instead call INIT_THREAD(..) then your ref count will probably need to be a 64b integer because I very well could do <div>

<br></div><div>MPI_QUERY_THREAD();</div><div>if SERIALIZED:</div><div>  THREAD_LOCK</div><div>  MPI_FOO</div><div>  THREAD_UNLOCK</div><div>else</div><div>  MPI_FOO</div><div>endif</div><div><br></div><div>in every library call that calls MPI, in which case it could happen more than 2^31 times if I've got >>10 threads per process making these library calls.  I'm not saying that this is going be common, but 1000 threads times 24 hours times 30 calls per second = 32b-overflow.</div>

<div><div><br></div><div>Jeff<br><br><div class="gmail_quote">On Tue, Jun 18, 2013 at 7:47 AM, Jeff Squyres (jsquyres) <span dir="ltr"><<a href="mailto:jsquyres@cisco.com" target="_blank">jsquyres@cisco.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">For comment...<br>
<br>
Here's a first cut at slides that we discussed yesterday.  It's meant to be a rollup of all the issues surrounding:<br>
<br>
- thread safe INIT / FINALIZE<br>
- reference-counting INIT / FINALIZE<br>
- nesting of INIT / FINALIZE<br>
<br>
I discovered a new issue when making up these slides: with ref-counting INIT/FINALIZE, since INIT/FINALIZE are collective, we have the same ref counts in all procs in MPI_COMM_WORLD.  But the ref counts may be different in non-COMM_WORLD connected processes.  What happens when they try to finalize over all connected processes?  See slide 12 for an example.  I'm not sure what the right answer is yet.<br>


<span class="HOEnZb"><font color="#888888"><br>
--<br>
Jeff Squyres<br>
<a href="mailto:jsquyres@cisco.com">jsquyres@cisco.com</a><br>
For corporate legal information go to: <a href="http://www.cisco.com/web/about/doing_business/legal/cri/" target="_blank">http://www.cisco.com/web/about/doing_business/legal/cri/</a><br>
</font></span><br>_______________________________________________<br>
Mpi3-hybridpm mailing list<br>
<a href="mailto:Mpi3-hybridpm@lists.mpi-forum.org">Mpi3-hybridpm@lists.mpi-forum.org</a><br>
<a href="http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi3-hybridpm" target="_blank">http://lists.mpi-forum.org/mailman/listinfo.cgi/mpi3-hybridpm</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Jeff Hammond<br>

Argonne Leadership Computing Facility<br>University of Chicago Computation Institute<br><a href="mailto:jhammond@alcf.anl.gov" target="_blank">jhammond@alcf.anl.gov</a> / (630) 252-5381<br><a href="http://www.linkedin.com/in/jeffhammond" target="_blank">http://www.linkedin.com/in/jeffhammond</a><br>

<a href="https://wiki.alcf.anl.gov/parts/index.php/User:Jhammond" target="_blank">https://wiki.alcf.anl.gov/parts/index.php/User:Jhammond</a><br>ALCF docs: <a href="http://www.alcf.anl.gov/user-guides" target="_blank">http://www.alcf.anl.gov/user-guides</a>
</div></div>