* avx runtime check
@ 2014-05-16 2:47 Mike Stump
2014-05-16 6:52 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Mike Stump @ 2014-05-16 2:47 UTC (permalink / raw)
To: Uros Bizjak; +Cc: gcc-patches
This reorders the avx checks and gates on a target triplet check before compiling any code.
Ok?
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
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: avx runtime check
2014-05-16 2:47 avx runtime check Mike Stump
@ 2014-05-16 6:52 ` Richard Biener
2014-05-16 14:20 ` Mike Stump
0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2014-05-16 6:52 UTC (permalink / raw)
To: Mike Stump, Uros Bizjak; +Cc: gcc-patches
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?
>Ok?
>
>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
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: avx runtime check
2014-05-16 6:52 ` Richard Biener
@ 2014-05-16 14:20 ` Mike Stump
2014-05-19 8:47 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Mike Stump @ 2014-05-16 14:20 UTC (permalink / raw)
To: Richard Biener; +Cc: Uros Bizjak, gcc-patches
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.
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
>> }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: avx runtime check
2014-05-16 14:20 ` Mike Stump
@ 2014-05-19 8:47 ` Richard Biener
0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2014-05-19 8:47 UTC (permalink / raw)
To: Mike Stump; +Cc: Uros Bizjak, gcc-patches
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
>>> }
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-19 8:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-16 2:47 avx runtime check Mike Stump
2014-05-16 6:52 ` Richard Biener
2014-05-16 14:20 ` Mike Stump
2014-05-19 8:47 ` Richard Biener
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).