[Mesa-dev] [PATCH 3/9] util: add fma3 or fma4 capable cpu detection

Roland Scheidegger sroland at vmware.com
Mon Jan 6 07:44:05 PST 2014


Am 05.01.2014 00:42, schrieb Maxence Le Doré:
> From: Maxence Le Doré <Maxence Le Doré>
> 
> ---
>  src/gallium/auxiliary/util/u_cpu_detect.c | 5 +++++
>  src/gallium/auxiliary/util/u_cpu_detect.h | 2 ++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c b/src/gallium/auxiliary/util/u_cpu_detect.c
> index d2d1313..19ad4fa 100644
> --- a/src/gallium/auxiliary/util/u_cpu_detect.c
> +++ b/src/gallium/auxiliary/util/u_cpu_detect.c
> @@ -371,6 +371,9 @@ util_cpu_detect(void)
>                                      ((xgetbv() & 6) == 6);    // XMM & YMM
>           util_cpu_caps.has_f16c   = (regs2[2] >> 29) & 1;
>           util_cpu_caps.has_mmx2   = util_cpu_caps.has_sse; /* SSE cpus supports mmxext too */
> +
> +         util_cpu_caps.has_fma3   = (regs2[2] >> 12) & 1;
> +         util_cpu_caps.has_fma4   = (regs2[2] >> 16) & 1;
This isn't correct, since fma4 is only defined for amd cpus it is only
there in ecx in the extended feature flags (i.e. with initial eax value
0x80000000).
And I'm wondering if we should list that as supported only when avx is
supported as this is a requirement for it (and the cpu could well
support it when the environment doesn't support avx). Though that said
this is true for f16c too actually.

Roland


>  #if defined(PIPE_ARCH_X86_64)
>           util_cpu_caps.has_daz = 1;
>  #else
> @@ -451,6 +454,8 @@ util_cpu_detect(void)
>        debug_printf("util_cpu_caps.has_xop = %u\n", util_cpu_caps.has_xop);
>        debug_printf("util_cpu_caps.has_altivec = %u\n", util_cpu_caps.has_altivec);
>        debug_printf("util_cpu_caps.has_daz = %u\n", util_cpu_caps.has_daz);
> +      debug_printf("util_cpu_caps.has_fma3 = %u\n", util_cpu_caps.has_fma3);
> +      debug_printf("util_cpu_caps.has_fma4 = %u\n", util_cpu_caps.has_fma4);
>     }
>  #endif
>  
> diff --git a/src/gallium/auxiliary/util/u_cpu_detect.h b/src/gallium/auxiliary/util/u_cpu_detect.h
> index 5ccfc93..6802e6a 100644
> --- a/src/gallium/auxiliary/util/u_cpu_detect.h
> +++ b/src/gallium/auxiliary/util/u_cpu_detect.h
> @@ -71,6 +71,8 @@ struct util_cpu_caps {
>     unsigned has_xop:1;
>     unsigned has_altivec:1;
>     unsigned has_daz:1;
> +   unsigned has_fma3:1;
> +   unsigned has_fma4:1;
>  };
>  
>  extern struct util_cpu_caps
> 


More information about the mesa-dev mailing list