This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH]: BZ #14648: Define HAS_FMA with bit_FMA_Usable
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Andreas Jaeger <aj at suse dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 1 Oct 2012 11:55:37 -0700
- Subject: Re: [PATCH]: BZ #14648: Define HAS_FMA with bit_FMA_Usable
- References: <20121001151310.GA14836@gmail.com><5069DA62.1040609@suse.com>
On Mon, Oct 1, 2012 at 11:01 AM, Andreas Jaeger <aj@suse.com> wrote:
> On 10/01/2012 05:13 PM, H.J. Lu wrote:
>>
>> Hi,
>>
>> This patch properly detects FMA support and defines HAS_FMA with
>> bit_FMA_Usable. Tested on FMA machine. OK for trunk and all applicable
>> branches?
>
>
> Please explain the reason for the change better:
According to AVX spec:
http://software.intel.com/sites/default/files/319433-014.pdf
to detect FMA support, we should do
INT supports_fma()
{
; result in eax
mov eax, 1
cpuid
and ecx, 018001000H
cmp ecx, 018001000H; check OSXSAVE, AVX, FMA feature flags
jne not_supported
; processor supports AVX,FMA instructions and XGETBV is enabled by OS
mov ecx, 0; specify 0 for XFEATURE_ENABLED_MASK register
XGETBV; result in EDX:EAX
and eax, 06H
cmp eax, 06H; check OS has enabled both XMM and YMM state support
jne not_supported
mov eax, 1
jmp done
NOT_SUPPORTED:
mov eax, 0
done:
}
> Do you only need this to implement 14649? Why do you need to backport this?
It is a real bug.
> Do we use HAS_FMA anywhere - and what is the bug if this does not go in?
>
The bug is similar to
http://sourceware.org/bugzilla/show_bug.cgi?id=13583
http://sourceware.org/bugzilla/show_bug.cgi?id=14059
If not fixed, program may crash on FMA machines.
--
H.J.