[petsc-users] using OpenMP in PETSc

Xiangdong Liang xdliang at gmail.com
Tue Mar 13 16:39:33 CDT 2012


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).

Any helps or hints on this would be appreciated.

Best,
Xiangdong


More information about the petsc-users mailing list