This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/20689] New: Test for FMA should also check for AVX.

            Bug ID: 20689
           Summary: Test for FMA should also check for AVX.
           Product: glibc
           Version: 2.25
            Status: NEW
          Severity: minor
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: carlos at redhat dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

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 follows:

diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 11b9af2..1d52f22 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -83,8 +83,10 @@ get_common_indeces (struct cpu_features *cpu_features,
                      |= bit_arch_AVX512DQ_Usable;
-         /* Determine if FMA is usable.  */
-         if (CPU_FEATURES_CPU_P (cpu_features, FMA))
+         /* Determine if FMA is usable.  The recommended Intel procedure
+            is to check for AVX && FMA to decide if FMA is available.  */
+         if (CPU_FEATURES_CPU_P (cpu_features, AVX)
+             && CPU_FEATURES_CPU_P (cpu_features, FMA))
              |= bit_arch_FMA_Usable;

You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]