This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: avx runtime check


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
>>>    }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]