How to build gcc with AVX512?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to build gcc with AVX512?

Cameron Fletcher (CF)
I am trying to build gcc 8.3 with using --with-fpmath=avx but it only builds gcc with AVX1.

Can someone help me on how to build gcc with avx512 support?

--
CF
Reply | Threaded
Open this post in threaded view
|

Re: How to build gcc with AVX512?

Stefan Ring
On Thu, Nov 14, 2019 at 6:31 AM Cameron Fletcher (CF)
<[hidden email]> wrote:
>
> I am trying to build gcc 8.3 with using --with-fpmath=avx but it only builds gcc with AVX1.
>
> Can someone help me on how to build gcc with avx512 support?

Do you mean you want a compiler that understands the avx512
instruction set and can generate code for it?
Reply | Threaded
Open this post in threaded view
|

Re: How to build gcc with AVX512?

Cameron Fletcher (CF)
On 14/11/19 1:41 pm, Stefan Ring wrote:

> On Thu, Nov 14, 2019 at 6:31 AM Cameron Fletcher (CF)
> <[hidden email]> wrote:
>>
>> I am trying to build gcc 8.3 with using --with-fpmath=avx but it only builds gcc with AVX1.
>>
>> Can someone help me on how to build gcc with avx512 support?
>
> Do you mean you want a compiler that understands the avx512
> instruction set and can generate code for it?
>
Yes. I have a cascade lake xeon on which I am building gcc.


--
--
CF
Reply | Threaded
Open this post in threaded view
|

Re: How to build gcc with AVX512?

Xi Ruoyao-3
On 2019-11-14 14:46 +0530, Cameron Fletcher (CF) wrote:

> On 14/11/19 1:41 pm, Stefan Ring wrote:
> > On Thu, Nov 14, 2019 at 6:31 AM Cameron Fletcher (CF)
> > <[hidden email]> wrote:
> > > I am trying to build gcc 8.3 with using --with-fpmath=avx but it
> > > only builds gcc with AVX1.
> > >
> > > Can someone help me on how to build gcc with avx512 support?
> >
> > Do you mean you want a compiler that understands the avx512
> > instruction set and can generate code for it?
> >
> Yes. I have a cascade lake xeon on which I am building gcc.

You'll need `-march=cascadelake` to tell GCC your CPU is a Cascade
Lake, and `-ftree-vectorize` to tell GCC to vectorize some loops into
AVX/AVX2/AVX512 instructions.

If you want to fully utilize AVX512 `-mprefer-vector-width=512` may be
necessary.  Without this option GCC will use AVX512 instructions (with
`-march=cascadelake`) but only the 256-bit and 128-bit variants.

And we shoule notice that using AVX512 may slow down the system (due to
downclocking).  Daniel Lemire wrote a nice article discussing these
issues:

https://lemire.me/blog/2018/09/07/avx-512-when-and-how-to-use-these-new-instructions/

Reply | Threaded
Open this post in threaded view
|

Re: How to build gcc with AVX512?

Cameron Fletcher (CF)
On 14/11/19 9:12 pm, Xi Ruoyao wrote:

> On 2019-11-14 14:46 +0530, Cameron Fletcher (CF) wrote:
>> On 14/11/19 1:41 pm, Stefan Ring wrote:
>>> On Thu, Nov 14, 2019 at 6:31 AM Cameron Fletcher (CF)
>>> <[hidden email]> wrote:
>>>> I am trying to build gcc 8.3 with using --with-fpmath=avx but it
>>>> only builds gcc with AVX1.
>>>>
>>>> Can someone help me on how to build gcc with avx512 support?
>>>
>>> Do you mean you want a compiler that understands the avx512
>>> instruction set and can generate code for it?
>>>
>> Yes. I have a cascade lake xeon on which I am building gcc.
>
> You'll need `-march=cascadelake` to tell GCC your CPU is a Cascade
> Lake, and `-ftree-vectorize` to tell GCC to vectorize some loops into
> AVX/AVX2/AVX512 instructions.

I am trying to build GCC to support  AVX,
not building the application with AVX which I will be doing later.

>
> If you want to fully utilize AVX512 `-mprefer-vector-width=512` may be
> necessary.  Without this option GCC will use AVX512 instructions (with
> `-march=cascadelake`) but only the 256-bit and 128-bit variants.
>
> And we shoule notice that using AVX512 may slow down the system (due to
> downclocking).  Daniel Lemire wrote a nice article discussing these
> issues:
>
> https://lemire.me/blog/2018/09/07/avx-512-when-and-how-to-use-these-new-instructions/
Thanks for this article.


Reply | Threaded
Open this post in threaded view
|

Re: How to build gcc with AVX512?

Jonathan Wakely-4
On Fri, 15 Nov 2019 at 09:49, Cameron Fletcher (CF)
<[hidden email]> wrote:

>
> On 14/11/19 9:12 pm, Xi Ruoyao wrote:
> > On 2019-11-14 14:46 +0530, Cameron Fletcher (CF) wrote:
> >> On 14/11/19 1:41 pm, Stefan Ring wrote:
> >>> On Thu, Nov 14, 2019 at 6:31 AM Cameron Fletcher (CF)
> >>> <[hidden email]> wrote:
> >>>> I am trying to build gcc 8.3 with using --with-fpmath=avx but it
> >>>> only builds gcc with AVX1.
> >>>>
> >>>> Can someone help me on how to build gcc with avx512 support?
> >>>
> >>> Do you mean you want a compiler that understands the avx512
> >>> instruction set and can generate code for it?
> >>>
> >> Yes. I have a cascade lake xeon on which I am building gcc.
> >
> > You'll need `-march=cascadelake` to tell GCC your CPU is a Cascade
> > Lake, and `-ftree-vectorize` to tell GCC to vectorize some loops into
> > AVX/AVX2/AVX512 instructions.
>
> I am trying to build GCC to support  AVX,
> not building the application with AVX which I will be doing later.

You shouldn't need to do anything special to get a GCC that can
generate AVX instructions, that happens automatically if your
assembler supports them.

There's probably no benefit to compiling GCC itself with AVX
instructions, as it's not likely to benefit from them.