* Calls to auto-vectorized AVX512 functions
@ 2021-02-08 2:51 Naoki Shibata
2021-02-08 10:42 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Naoki Shibata @ 2021-02-08 2:51 UTC (permalink / raw)
To: gcc
Hello,
I have a question as to the auto-vectorizer in GCC.
When AVX512 instruction is available, the auto-vectorizer in gcc
sometimes generates calls to AVX2 functions instead of AVX512 functions.
$ cat vabitest.c
#include <stdio.h>
#include <math.h>
_Pragma ("omp declare simd simdlen(8) notinbranch")
__attribute__((const)) double myfunc(double x);
#define N 1024
__attribute__ ((__aligned__(256))) double a[N], b[N], c[N];
int main(void) {
for (int i = 0; i < N; i++) a[i] = myfunc(b[i]);
for (int i = 0; i < N; i++) c[i] = sin(b[i]);
}
$ gcc-10 -ffast-math -O3 -mavx512f -fopenmp vabitest.c -S -o- | grep _ZGV
call _ZGVdN8v_myfunc@PLT
call _ZGVeN8v_sin@PLT
Is there a way to force gcc to generate calls to AVX512 function in
cases like this?
Regards,
Naoki Shibata
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Calls to auto-vectorized AVX512 functions
2021-02-08 2:51 Calls to auto-vectorized AVX512 functions Naoki Shibata
@ 2021-02-08 10:42 ` Richard Biener
2021-02-08 10:55 ` Jakub Jelinek
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2021-02-08 10:42 UTC (permalink / raw)
To: Naoki Shibata; +Cc: GCC Development
On Mon, Feb 8, 2021 at 4:26 AM Naoki Shibata via Gcc <gcc@gcc.gnu.org> wrote:
>
>
> Hello,
>
> I have a question as to the auto-vectorizer in GCC.
>
> When AVX512 instruction is available, the auto-vectorizer in gcc
> sometimes generates calls to AVX2 functions instead of AVX512 functions.
>
>
> $ cat vabitest.c
> #include <stdio.h>
> #include <math.h>
>
> _Pragma ("omp declare simd simdlen(8) notinbranch")
> __attribute__((const)) double myfunc(double x);
>
> #define N 1024
> __attribute__ ((__aligned__(256))) double a[N], b[N], c[N];
>
> int main(void) {
> for (int i = 0; i < N; i++) a[i] = myfunc(b[i]);
> for (int i = 0; i < N; i++) c[i] = sin(b[i]);
> }
>
> $ gcc-10 -ffast-math -O3 -mavx512f -fopenmp vabitest.c -S -o- | grep _ZGV
> call _ZGVdN8v_myfunc@PLT
> call _ZGVeN8v_sin@PLT
>
>
> Is there a way to force gcc to generate calls to AVX512 function in
> cases like this?
Not sure, the sin function get's called with a %zmm argument but
myfunc is called with two %ymm arguments but returns a %zmm.
Something seems messed up somewhere.
Can you open a bugreport?
Richard.
> Regards,
>
> Naoki Shibata
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Calls to auto-vectorized AVX512 functions
2021-02-08 10:42 ` Richard Biener
@ 2021-02-08 10:55 ` Jakub Jelinek
0 siblings, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2021-02-08 10:55 UTC (permalink / raw)
To: Richard Biener; +Cc: Naoki Shibata, GCC Development
On Mon, Feb 08, 2021 at 11:42:13AM +0100, Richard Biener via Gcc wrote:
> > I have a question as to the auto-vectorizer in GCC.
> >
> > When AVX512 instruction is available, the auto-vectorizer in gcc
> > sometimes generates calls to AVX2 functions instead of AVX512 functions.
> >
> >
> > $ cat vabitest.c
> > #include <stdio.h>
> > #include <math.h>
> >
> > _Pragma ("omp declare simd simdlen(8) notinbranch")
> > __attribute__((const)) double myfunc(double x);
> >
> > #define N 1024
> > __attribute__ ((__aligned__(256))) double a[N], b[N], c[N];
> >
> > int main(void) {
> > for (int i = 0; i < N; i++) a[i] = myfunc(b[i]);
> > for (int i = 0; i < N; i++) c[i] = sin(b[i]);
> > }
> >
> > $ gcc-10 -ffast-math -O3 -mavx512f -fopenmp vabitest.c -S -o- | grep _ZGV
> > call _ZGVdN8v_myfunc@PLT
> > call _ZGVeN8v_sin@PLT
> >
> >
> > Is there a way to force gcc to generate calls to AVX512 function in
> > cases like this?
>
> Not sure, the sin function get's called with a %zmm argument but
> myfunc is called with two %ymm arguments but returns a %zmm.
> Something seems messed up somewhere.
>
> Can you open a bugreport?
I'd guess it is -mprefer-vector-width=256 by default, though it surprises me
%zmm is used for sin.
In any case, I'd retry with mprefer-vector-width=512.
Jakub
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-08 10:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-08 2:51 Calls to auto-vectorized AVX512 functions Naoki Shibata
2021-02-08 10:42 ` Richard Biener
2021-02-08 10:55 ` Jakub Jelinek
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).