public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Mike Stump <mikestump@comcast.net>
Cc: Uros Bizjak <ubizjak@gmail.com>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: avx runtime check
Date: Mon, 19 May 2014 08:47:00 -0000	[thread overview]
Message-ID: <CAFiYyc03xFpMSUPDqQJkR4wCYi=OVF9n3jkvkmBg_i_C3Avk8A@mail.gmail.com> (raw)
In-Reply-To: <CF012473-07CE-4442-99CB-C4DE5DD573C3@comcast.net>

On Fri, May 16, 2014 at 4:20 PM, Mike Stump <mikestump@comcast.net> wrote:
> On May 15, 2014, at 11:52 PM, Richard Biener <richard.guenther@gmail.com> wrote:
>> On May 16, 2014 4:47:11 AM CEST, Mike Stump <mikestump@comcast.net> wrote:
>>> This reorders the avx checks and gates on a target triplet check before
>>> compiling any code.
>>
>> Can you explain why?
>
> Sure, because check_avx_hw_available runs [istarget x86_64-*-*] || [istarget i?86-*-*] before doing anything, like compiling:
>
>        typedef double __m512d __attribute__ ((__vector_size__ (64)));
>
>         __m512d _mm512_add (__m512d a)
>         {
>           return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
>         }
>
> with -mavx512f, which my target doesn’t have, but even running a compilation of that seems wrong.  The other possibility would be to add in a:
>
>         # If this is not the right target then we can skip the test.
>         if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
>             expr 0
>         } else {
>
> into the test for check_effective_target_avx512f.

Yes, that looks like a better fix.

Ok with that change.

Thanks,
Richard.

>
> proc check_effective_target_avx512f { } {
>     return [check_no_compiler_messages avx512f object {
>         typedef double __m512d __attribute__ ((__vector_size__ (64)));
>
>         __m512d _mm512_add (__m512d a)
>         {
>           return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
>         }
>     } "-O2 -mavx512f" ]
> }
>
> proc check_avx_hw_available { } {
>     return [check_cached_effective_target avx_hw_available {
>         # If this is not the right target then we can skip the test.
>         if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
>             expr 0
>         } else {
>             check_runtime_nocache avx_hw_available {
>                 #include "cpuid.h"
>                 int main ()
>                 {
>                   unsigned int eax, ebx, ecx, edx;
>                   if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
>                     return ((ecx & (bit_AVX | bit_OSXSAVE))
>                             != (bit_AVX | bit_OSXSAVE));
>                   return 1;
>                 }
>             } ""
>         }
>     }]
> }
>
>
>>> diff --git a/gcc/testsuite/lib/target-supports.exp
>>> b/gcc/testsuite/lib/target-supports.exp
>>> index 40b5414..103a28a 100644
>>> --- a/gcc/testsuite/lib/target-supports.exp
>>> +++ b/gcc/testsuite/lib/target-supports.exp
>>> @@ -1353,8 +1353,8 @@ proc check_effective_target_sse2_runtime { } {
>>> # Return 1 if the target supports running AVX executables, 0 otherwise.
>>>
>>> proc check_effective_target_avx_runtime { } {
>>> -    if { [check_effective_target_avx]
>>> -        && [check_avx_hw_available]
>>> +    if { [check_avx_hw_available]
>>> +        && [check_effective_target_avx]
>>>        && [check_avx_os_support_available] } {
>>>       return 1
>>>    }

      reply	other threads:[~2014-05-19  8:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-16  2:47 Mike Stump
2014-05-16  6:52 ` Richard Biener
2014-05-16 14:20   ` Mike Stump
2014-05-19  8:47     ` Richard Biener [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFiYyc03xFpMSUPDqQJkR4wCYi=OVF9n3jkvkmBg_i_C3Avk8A@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mikestump@comcast.net \
    --cc=ubizjak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).