[petsc-dev] PETSc, VS2013 and OpenMP

Jed Brown jed at jedbrown.org
Sat Sep 6 18:34:25 CDT 2014


Paul Mullowney <paulmullowney at gmail.com> writes:

> Hi,
> Now I'm trying to build petsc-dev next in cygwin with the threadcomm/OpenMP
> package (CUDA also but I solved my build issues for this already).
>
> I successfully configured and built, however I ran into 3 problems.

This is being heavily refactored and should not be used right now.

> 1) I don't think that the OpenMP package should depend on pthreadsclasses.py
> In openmp.py, I commented out lines 17-18:
>     #self.pthreadclasses =
> framework.require('PETSc.packages.pthreadclasses',self)
>     #self.deps = [self.pthreadclasses]
>
> 2) Then, in include/petscerror.h.
> line 409:
> #if defined(PETSC_HAVE_PTHREADCLASSES) || defined (PETSC_HAVE_OPENMP)
> ...
> #include <pthread.h>
> #endif
>
> should be
>
> #if defined(PETSC_HAVE_PTHREADCLASSES)
> ...
> #include <pthread.h>
> #endif
>
> 3) Also, in include/petscerror.h
> PETSC_EXTERN PetscStack *petscstack;
> #pragma omp threadprivate(petscstack)
>
> doesn't work in recent visual studio compilers (
> http://stackoverflow.com/questions/12560243/using-threadprivate-directive-in-visual-studio
> ):

Is there a reason you want to use such a buggy compiler instead of one
of the several alternatives that are capable of implementing ancient
standards?

> I commented out the 2 lines above and replaced with:
> PETSC_EXTERN __declspec(thread) PetscStack *petscstack;
>
> I doubt this is the correct solution for all architectures. Perhaps someone
> more familiar with this OpenMP code can suggest other changes which might
> be necessary.

Definitely not portable.  There are at least five ways of specifying
thread local variables, several of which are standardized.

  _Thread_local           C11 standard
  pthread get/setspecific Any POSIX system; does not need compiler support
  omp threadprivate       Any OpenMP implementation, except MSVC (evidently)
  __thread                GCC, Clang, Intel/Linux, IBM XL, Solaris
  __declspec(thread)      MSVC, Intel/Windows


MSVC has the unique distinction of offering none of the standard
mechanisms.

I wish the vendors would implement the standards (any standards, really)
so that portable threaded programming wasn't such a gong show, but it
appears that only the free compilers can afford to implement standards
and fix bugs instead of counting on customers to work around incomplete,
buggy implementations.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20140906/bde559b7/attachment.sig>


More information about the petsc-dev mailing list