This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] Bug 201689: Belt-and-suspenders detection of FMA.
- From: Carlos O'Donell <carlos at redhat dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 17 Oct 2016 19:40:27 -0400
- Subject: Re: [PATCH] Bug 201689: Belt-and-suspenders detection of FMA.
- Authentication-results: sourceware.org; auth=none
- References: <firstname.lastname@example.org> <CAMe9rOr5dmNN4EChF-5_a=5UhkfWgGUnG77P2Oy2+VE=UakGpg@mail.gmail.com> <email@example.com>
On 10/17/2016 11:44 AM, Carlos O'Donell wrote:
> On 10/14/2016 03:12 PM, H.J. Lu wrote:
>> On Fri, Oct 14, 2016 at 11:09 AM, Carlos O'Donell <firstname.lastname@example.org> wrote:
>>> In the Intel Architecture Instruction Set Extensions Programming reference
>>> the recommended way to test for FMA in section '2.2.1 Detection of FMA'
>>> "Application Software must identify that hardware supports AVX as explained
>>> in ... after that it must also detect support for FMA..."
>>> We don't do that in glibc. We use osxsave to detect the use of xgetbv, and
>>> after that we check for AVX and FMA orthogonally. It is conceivable that
>>> you could have the AVX bit clear and the FMA bit in an undefined state.
>>> I have never seen a machine with the AVX bit clear and the FMA bit set, but
>>> we should follow the intel specifications and adjust our check as the following
>>> patch works.
>> One can't write a program with FMA nor AVX2 without using AVX
>> instructions. AVX2/FMA aren't usable if AVX isn't. We should do
>> if (CPU_FEATURES_CPU_P (cpu_features, AVX))
>> Set AVX available
>> if (CPU_FEATURES_CPU_P (cpu_features, AVX2))
>> Set AVX2 available
>> if (CPU_FEATURES_CPU_P (cpu_features, FMA))
>> Set FMA available
> Agreed. I double checked the manual, here is a new patch.
> Testing on x86_64 and i686.
> OK to commit if the results are clean?
> - Move FMA and AVX2 check up into AVX check since they depend upon it.
> 2016-10-14 Carlos O'Donell <email@example.com>
> [BZ #20689]
> * sysdeps/x86/cpu-features.c: Only enable FMA and AVX2 if
> AVX is usable.