[1/2] Add _arch_/_cpu_ to index_*/bit_* in x86 cpu-features.h

Message ID 87y49o4ntk.fsf@mid.deneb.enyo.de
State Dropped
Headers

Commit Message

Florian Weimer March 11, 2016, 11:06 p.m. UTC
  * H. J. Lu:

> On Fri, Mar 11, 2016 at 2:55 PM, Roland McGrath <roland@hack.frob.com> wrote:
>>> Roland committed a fix which included <cpu-features.h> (commit
>>> 3bd80c0de2f8e7ca8020d37739339636d169957e) in tst-audit10.c I assumed
>>> that this addressed this particular build failure (it does for me with
>>> GCC 4.7).
>
> <cpu-features.h> shouldn't be used in test.

Why?

> #ifndef bit_AVX512F
> # define bit_AVX512F
> #endif

This would seem more reasonable:
  

Comments

H.J. Lu March 11, 2016, 11:09 p.m. UTC | #1
On Fri, Mar 11, 2016 at 3:06 PM, Florian Weimer <fw@deneb.enyo.de> wrote:
> * H. J. Lu:
>
>> On Fri, Mar 11, 2016 at 2:55 PM, Roland McGrath <roland@hack.frob.com> wrote:
>>>> Roland committed a fix which included <cpu-features.h> (commit
>>>> 3bd80c0de2f8e7ca8020d37739339636d169957e) in tst-audit10.c I assumed
>>>> that this addressed this particular build failure (it does for me with
>>>> GCC 4.7).
>>
>> <cpu-features.h> shouldn't be used in test.
>
> Why?

bit_AVX512F should come from <cpuid.h>.  It is wrong to include
<cpu-features.h> for bit_AVX512F.
  
Roland McGrath March 11, 2016, 11:16 p.m. UTC | #2
> This would seem more reasonable:

That change is fine by me (with ChangeLog entry and verification of testing
with gcc <= 4.8, of course).

Thanks,
Roland
  
Florian Weimer March 25, 2016, 10:40 a.m. UTC | #3
On 03/12/2016 12:06 AM, Florian Weimer wrote:

> This would seem more reasonable:
> 
> diff --git a/sysdeps/x86_64/tst-audit10.c b/sysdeps/x86_64/tst-audit10.c
> index a487b40..0df2275 100644
> --- a/sysdeps/x86_64/tst-audit10.c
> +++ b/sysdeps/x86_64/tst-audit10.c
> @@ -17,13 +17,13 @@
>     <http://www.gnu.org/licenses/>.  */
>  
>  #include <cpuid.h>
> -#include <cpu-features.h>
>  
>  int tst_audit10_aux (void);
>  
>  static int
>  avx512_enabled (void)
>  {
> +#ifdef bit_AVX512F
>    unsigned int eax, ebx, ecx, edx;
>  
>    if (__get_cpuid (1, &eax, &ebx, &ecx, &edx) == 0
> @@ -38,6 +38,9 @@ avx512_enabled (void)
>  
>    /* Verify that ZMM, YMM and XMM states are enabled.  */
>    return (eax & 0xe6) == 0xe6;
> +#else
> +  return 0;
> +#endif
>  }
>  
>  static int

I have committed this, after testing compilation with GCC 4.7 and GCC
5.3.  Bug 19860 mentions a second compilation error, which I did not
see.  I'm waiting for details on that one, maybe it was a spurious issue.

Florian
  
Roland McGrath March 28, 2016, 10:15 p.m. UTC | #4
> > --- a/sysdeps/x86_64/tst-audit10.c
> > +++ b/sysdeps/x86_64/tst-audit10.c
> > @@ -17,13 +17,13 @@
> >     <http://www.gnu.org/licenses/>.  */
> >  
> >  #include <cpuid.h>
> > -#include <cpu-features.h>
> >  
> >  int tst_audit10_aux (void);
> >  
> >  static int
> >  avx512_enabled (void)
> >  {
> > +#ifdef bit_AVX512F
> >    unsigned int eax, ebx, ecx, edx;
> >  
> >    if (__get_cpuid (1, &eax, &ebx, &ecx, &edx) == 0
> > @@ -38,6 +38,9 @@ avx512_enabled (void)
> >  
> >    /* Verify that ZMM, YMM and XMM states are enabled.  */
> >    return (eax & 0xe6) == 0xe6;
> > +#else
> > +  return 0;
> > +#endif
> >  }
> >  
> >  static int
> 
> I have committed this, after testing compilation with GCC 4.7 and GCC
> 5.3.  Bug 19860 mentions a second compilation error, which I did not
> see.  I'm waiting for details on that one, maybe it was a spurious issue.

It occurred to me later that having this use #ifdef HAVE_AVX512_SUPPORT
would be better.  That is, we expect a compiler that accepts -mavx512f
to provide a <cpuid.h> that defines bit_AVX512F.  If we have -mavx512f
support but somehow get a <cpuid.h> missing bit_AVX512F, that should be
a build error because the compiler installation is self-inconsistent.


Thanks,
Roland
  

Patch

diff --git a/sysdeps/x86_64/tst-audit10.c b/sysdeps/x86_64/tst-audit10.c
index a487b40..0df2275 100644
--- a/sysdeps/x86_64/tst-audit10.c
+++ b/sysdeps/x86_64/tst-audit10.c
@@ -17,13 +17,13 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <cpuid.h>
-#include <cpu-features.h>
 
 int tst_audit10_aux (void);
 
 static int
 avx512_enabled (void)
 {
+#ifdef bit_AVX512F
   unsigned int eax, ebx, ecx, edx;
 
   if (__get_cpuid (1, &eax, &ebx, &ecx, &edx) == 0
@@ -38,6 +38,9 @@  avx512_enabled (void)
 
   /* Verify that ZMM, YMM and XMM states are enabled.  */
   return (eax & 0xe6) == 0xe6;
+#else
+  return 0;
+#endif
 }
 
 static int