Re[2]: [Gc] [libatomic_ops] Intel Compiler with gcc compatible mode

Ivan Maidanski ivmai at mail.ru
Fri Feb 19 00:43:54 PST 2010


Patrick MARLIER <patrick.marlier at unine.ch> wrote:
> It seems that Intel 11.1+ has support for __sync_ primitive.
> So maybe we can also do this in my previous patch:
> 
> - /* Intel Compiler in gcc compatible mode (but not support __sync_ 
> primitive) */
> + /* Intel Compiler in gcc compatible mode */
> + #  if __INTEL_COMPILER > 1110
> + #   define HAVE_GCC_ATOMIC_BUILTINS 1
> + #  endif /* __INTEL_COMPILER */
> 
> Patrick Marlier

1. I'd prefer something like AO_USE_SYNC_CAS_BUILTIN instead of HAVE_GCC_ATOMIC_BUILTINS as we are talking about CAS only.

2. Is it really worth adding to libatomics auto-detection of all possible compilers that have correctly working built-in CAS provided the supplied asm variant works for them fine (just to save a couple of CPU cycles?) - I'd prefer to auto-define that macro for GCC v4.2+ amd64 and check it in gcc/x86 and gcc/x86_64. (We could add more auto-detection in the next libatomics release.)

> 
> Patrick MARLIER wrote:
> > Since Intel Compiler (icc) is gcc compatible mode by default under 
> > linux, libatomic_ops can use the gcc definition to support more 
> > architecture.
> > 
> > Here a proposed patch.
> > 
> > Patrick Marlier.
> 
> Index: src/atomic_ops.h
> ===================================================================
> RCS file: /cvsroot/bdwgc/bdwgc/libatomic_ops/src/atomic_ops.h,v
> retrieving revision 1.3
> diff -u -r1.3 atomic_ops.h
> --- src/atomic_ops.h	17 Dec 2009 07:16:46 -0000	1.3
> +++ src/atomic_ops.h	19 Feb 2010 07:58:38 -0000
> @@ -199,6 +199,9 @@
>  
>  #if defined(__GNUC__) && !defined(AO_USE_PTHREAD_DEFS) \
>      && !defined(__INTEL_COMPILER)
> +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
> +#  define HAVE_GCC_ATOMIC_BUILTINS 1
> +# endif
>  # if defined(__i386__)
>  #   include "atomic_ops/sysdeps/gcc/x86.h"
>  # endif /* __i386__ */
> @@ -252,6 +255,18 @@
>  #   include "atomic_ops/sysdeps/icc/ia64.h"
>  #   define AO_GENERALIZE_TWICE
>  # endif
> +# if defined(__GNUC__)
> +  /* Intel Compiler in gcc compatible mode */
> +#  if __INTEL_COMPILER > 1110
> +#   define HAVE_GCC_ATOMIC_BUILTINS 1
> +#  endif /* __INTEL_COMPILER */
> +#  if defined(__i386__)
> +#   include "atomic_ops/sysdeps/gcc/x86.h"
> +#  endif /* __i386__ */
> +#  if defined (__x86_64__)
> +#   include "atomic_ops/sysdeps/gcc/x86_64.h"
> +#  endif
> +# endif
>  #endif
>  
>  #if defined(_HPUX_SOURCE) && !defined(__GNUC__) && !defined(AO_USE_PTHREAD_DEFS)
> Index: src/atomic_ops/sysdeps/gcc/x86_64.h
> ===================================================================
> RCS file: /cvsroot/bdwgc/bdwgc/libatomic_ops/src/atomic_ops/sysdeps/gcc/x86_64.h,v
> retrieving revision 1.3
> diff -u -r1.3 x86_64.h
> --- src/atomic_ops/sysdeps/gcc/x86_64.h	18 Feb 2010 10:12:08 -0000	1.3
> +++ src/atomic_ops/sysdeps/gcc/x86_64.h	19 Feb 2010 07:58:38 -0000
> @@ -121,7 +121,7 @@
>  AO_INLINE int
>  AO_compare_and_swap_full(volatile AO_t *addr, AO_t old, AO_t new_val)
>  {
> -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
> +# ifdef HAVE_GCC_ATOMIC_BUILTINS
>      return (int)__sync_bool_compare_and_swap(addr, old, new_val);
>  # else
>      char result;



More information about the Gc mailing list