[petsc-users] using OpenMP in PETSc

Matthew Knepley knepley at gmail.com
Tue Mar 13 16:57:05 CDT 2012


On Tue, Mar 13, 2012 at 4:39 PM, Xiangdong Liang <xdliang at gmail.com> wrote:

> Hello everyone,
>
> Can someone provide me advice on using OpenMP in PETSc? I am solving a
> problem like this:
>
> int main()
> {
>  vec vsum;
>
>  for(i=0; i< N; i++)
>    {
>      vec vi;
>      fcomputev(i, vi);
>      VecAXPY(vsum, 1.0, vi); // vsum +=vi;
>    }
>
> }
>
> Can I use OpenMP "omp parallel for" to do the loop in parallel? For
> example, suppose I have 8 processes.   It would be nice if each petsc
> subrountine fcomputev uses 2 processes while 4 different i's are
> computed in parallel (since different i's are independent).
>

PETSc is not threadsafe. This is trivial to do in MPI where the comm for eah
Vec is a group of 2 procs.

  Matt


> Any helps or hints on this would be appreciated.
>
> Best,
> Xiangdong
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120313/a4871dfb/attachment-0001.htm>


More information about the petsc-users mailing list