[PATCH]: BZ #14648: Define HAS_FMA with bit_FMA_Usable

Andreas Jaeger aj@suse.com
Mon Oct 1 18:01:00 GMT 2012


On 10/01/2012 05:13 PM, H.J. Lu wrote:
> Hi,
>
> This patch properly detects FMA support and defines HAS_FMA with
> bit_FMA_Usable.  Tested on FMA machine.  OK for trunk and all applicable
> branches?

Please explain the reason for the change better:
Do you only need this to implement 14649? Why do you need to backport 
this? Do we use HAS_FMA anywhere - and what is the bug if this does not 
go in?

Andreas

> Thanks.
>
> H.J.
> ---
>   sysdeps/x86_64/multiarch/init-arch.c |  3 +++
>   sysdeps/x86_64/multiarch/init-arch.h |  9 +++++++--
>   3 files changed, 21 insertions(+), 2 deletions(-)
>
> 2012-10-01  H.J. Lu  <hongjiu.lu@intel.com>
>
> 	[BZ #14648]
> 	* sysdeps/x86_64/multiarch/init-arch.c (__init_cpu_features):
> 	Set bit_FMA_Usable if FMA is supported.
> 	* sysdeps/x86_64/multiarch/init-arch.h (bit_FMA_Usable): New
> 	macro.
> 	(bit_FMA4_Usable): Updated.
> 	(index_FMA_Usable): New macro.
> 	(CPUID_FMA): Likewise
> 	(HAS_FMA): Defined with bit_FMA_Usable.
>
> diff --git a/sysdeps/x86_64/multiarch/init-arch.c b/sysdeps/x86_64/multiarch/init-arch.c
> index fb44dcf..fed5ab8 100644
> --- a/sysdeps/x86_64/multiarch/init-arch.c
> +++ b/sysdeps/x86_64/multiarch/init-arch.c
> @@ -156,6 +156,9 @@ __init_cpu_features (void)
>   	  /* Determine if AVX is usable.  */
>   	  if (CPUID_AVX)
>   	    __cpu_features.feature[index_AVX_Usable] |= bit_AVX_Usable;
> +	  /* Determine if FMA is usable.  */
> +	  if (CPUID_FMA)
> +	    __cpu_features.feature[index_FMA_Usable] |= bit_FMA_Usable;
>   	  /* Determine if FMA4 is usable.  */
>   	  if (CPUID_FMA4)
>   	    __cpu_features.feature[index_FMA4_Usable] |= bit_FMA4_Usable;
> diff --git a/sysdeps/x86_64/multiarch/init-arch.h b/sysdeps/x86_64/multiarch/init-arch.h
> index 45e2651..f33f1c8 100644
> --- a/sysdeps/x86_64/multiarch/init-arch.h
> +++ b/sysdeps/x86_64/multiarch/init-arch.h
> @@ -22,7 +22,8 @@
>   #define bit_Fast_Unaligned_Load		(1 << 4)
>   #define bit_Prefer_PMINUB_for_stringop	(1 << 5)
>   #define bit_AVX_Usable			(1 << 6)
> -#define bit_FMA4_Usable			(1 << 7)
> +#define bit_FMA_Usable			(1 << 7)
> +#define bit_FMA4_Usable			(1 << 8)
>
>   /* CPUID Feature flags.  */
>   #define bit_SSE2	(1 << 26)
> @@ -56,6 +57,7 @@
>   # define index_Fast_Unaligned_Load	FEATURE_INDEX_1*FEATURE_SIZE
>   # define index_Prefer_PMINUB_for_stringop FEATURE_INDEX_1*FEATURE_SIZE
>   # define index_AVX_Usable		FEATURE_INDEX_1*FEATURE_SIZE
> +# define index_FMA_Usable		FEATURE_INDEX_1*FEATURE_SIZE
>   # define index_FMA4_Usable		FEATURE_INDEX_1*FEATURE_SIZE
>
>   #else	/* __ASSEMBLER__ */
> @@ -131,6 +133,8 @@ extern const struct cpu_features *__get_cpu_features (void)
>     HAS_CPUID_FLAG (COMMON_CPUID_INDEX_1, ecx, bit_OSXSAVE)
>   # define CPUID_AVX \
>     HAS_CPUID_FLAG (COMMON_CPUID_INDEX_1, ecx, bit_AVX)
> +# define CPUID_FMA \
> +  HAS_CPUID_FLAG (COMMON_CPUID_INDEX_1, ecx, bit_FMA)
>   # define CPUID_FMA4 \
>     HAS_CPUID_FLAG (COMMON_CPUID_INDEX_80000001, ecx, bit_FMA4)
>
> @@ -140,7 +144,6 @@ extern const struct cpu_features *__get_cpu_features (void)
>   # define HAS_SSSE3	HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_SSSE3)
>   # define HAS_SSE4_1	HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_SSE4_1)
>   # define HAS_SSE4_2	HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_SSE4_2)
> -# define HAS_FMA	HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_FMA)
>
>   # define index_Fast_Rep_String		FEATURE_INDEX_1
>   # define index_Fast_Copy_Backward	FEATURE_INDEX_1
> @@ -148,6 +151,7 @@ extern const struct cpu_features *__get_cpu_features (void)
>   # define index_Prefer_SSE_for_memop	FEATURE_INDEX_1
>   # define index_Fast_Unaligned_Load	FEATURE_INDEX_1
>   # define index_AVX_Usable		FEATURE_INDEX_1
> +# define index_FMA_Usable		FEATURE_INDEX_1
>   # define index_FMA4_Usable		FEATURE_INDEX_1
>
>   # define HAS_ARCH_FEATURE(name) \
> @@ -159,6 +163,7 @@ extern const struct cpu_features *__get_cpu_features (void)
>   # define HAS_PREFER_SSE_FOR_MEMOP	HAS_ARCH_FEATURE (Prefer_SSE_for_memop)
>   # define HAS_FAST_UNALIGNED_LOAD	HAS_ARCH_FEATURE (Fast_Unaligned_Load)
>   # define HAS_AVX			HAS_ARCH_FEATURE (AVX_Usable)
> +# define HAS_FMA			HAS_ARCH_FEATURE (FMA_Usable)
>   # define HAS_FMA4			HAS_ARCH_FEATURE (FMA4_Usable)
>
>   #endif	/* __ASSEMBLER__ */
>


-- 
  Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
   SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
    GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
     GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126



More information about the Libc-alpha mailing list