<div class="gmail_quote">On Wed, Mar 7, 2012 at 09:12, Lawrence Mitchell <span dir="ltr"><<a href="mailto:lawrence.mitchell@ed.ac.uk">lawrence.mitchell@ed.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div id=":2en">Moving forward, I've done a bunch of this macroisation, which makes the code<br>
more PETSc-like.<br>
<br>
As you point out it's probably unwise to call omp_get_num_threads() on every<br>
loop iteration, so I went for the magic names in the end.  A typical simple<br>
loop now looks like:<br>
<br>
VecOMPParallelBegin(xin, private(i) shared(x));<br>
for (i=__start; i<__end;i++) x[i] = work(x[i]);<br>
VecOMPParallelEnd();<br>
<br>
In the --without-openmp case, this transforms into:<br>
<br>
do {<br>
   PetscInt __start = 0, __end = xin->map->n;<br>
   for ...;<br>
} while (0);<br>
<br>
Rather than adding an nthreads slot to vectors, I put it in the generic<br>
PetscObject struct -- we're threading matrices too.<br></div></blockquote><div><br></div><div>We are going with PetscLayout for distribution information with the pthreads implementations. We have also discussed making "thread communicator" information (how many threads and their affinities) an attribute of an MPI_Comm. I'd be interested to hear your opinions on that.</div>
<div><br></div><div>All, should we consider moving all the "kernels" into their own functions and just doing parallel region dispatch differently for OpenMP and pthreads? I think that is the only reasonable way to have just one version of the code. If we committed to always using separate side-effect-free kernels, we might be able to reuse many of them with TBB and OpenCL as well.</div>
<div><br></div><div>Is there ever a case where we want to have _both_ OpenMP and Pthreads objects in the same application? Maybe, e.g. when servicing two multiphysics applications, one of which chooses OpenMP and one of which chooses Pthreads (perhaps on different communicators so we don't have to fight with over-subscription).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":2en">
<br>
I don't know how to write the correct tests for configure to probe for the<br>
existance of _Pragma, so that's still missing.</div></blockquote></div><br><div>I'll do it.</div>