[petsc-users] KSP in OpenMP Parallel For Loop

Barry Smith bsmith at mcs.anl.gov
Sat Apr 5 13:34:37 CDT 2014


   There is a branch in the petsc bitbucket repository http://www.mcs.anl.gov/petsc/developers/index.html called barry/make-petscoptionsobject-nonglobal  where one can call the PETSc operations in threads without any conflicts. Otherwise it just won’t work.

   Barry

On Apr 5, 2014, at 12:25 PM, D H <mrhyde at stanford.edu> wrote:

> Hi,
> 
> I have a C++ program where I would like to call some of PETSc's KSP methods (KSPCreate, KSPSolve, etc.) from inside a for loop that has a "#pragma omp parallel for" in front of it.  Without this OpenMP pragma, my code runs fine.  But when I add in this parallelism, my program segfaults with PETSc reporting some memory corruption errors.
> 
> I've read online in a few places that PETSc is not thread-safe, but before I give up hope, I thought I would ask to see if anyone has had success working with KSP routines when they are being called simultaneously from multiple threads (or whether such a feat is definitely not possible with PETSc).  Thanks very much for your advice!
> 
> Best,
> 
> David



More information about the petsc-users mailing list