[petsc-dev] Configuring for atomics

Barry Smith bsmith at mcs.anl.gov
Sat Apr 14 12:08:12 CDT 2012


On Apr 14, 2012, at 11:44 AM, Jed Brown wrote:

> Lots of other compilers support GCC-style intrinsics like __sync_bool_compare_and_swap() and similar, so we really can't be doing this kind of logic in lockfree.c.
> 
> #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
> #define PetscAtomicCompareandSwap(ptr, oldval, newval) (OSAtomicCompareAndSwapPtr(oldval,newval,ptr))
> #elif defined(_MSC_VER)
> #define PetscAtomicCompareandSwap(ptr, oldval, newval) (InterlockedCompareExchange(ptr,newval,oldval))
> #elif (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
> #define PetscAtomicCompareandSwap(ptr, oldval, newval) (__sync_bool_compare_and_swap(ptr,oldval,newval))
> #else
> #  error No maping for PetscAtomicCompareandSwap
> #endif
> 
> 
> What does everyone else think about using Dave Goodell's Open Portable Atomics (https://trac.mcs.anl.gov/projects/openpa/, used by MPICH2) instead of maintaining our own suite of configuration tests?

   I guess it is worth trying.

   Barry





More information about the petsc-dev mailing list