+2020-05-21 H.J. Lu <hongjiu.lu@intel.com>
+
+ * m4/matmul.m4: Don't include <config/i386/cpuinfo.h>. Use
+ __builtin_cpu_is/__builtin_cpu_supports
+ * generated/matmul_c10.c: Regenerated.
+ * generated/matmul_c16.c: Likewise.
+ * generated/matmul_c4.c: Likewise.
+ * generated/matmul_c8.c: Likewise.
+ * generated/matmul_i1.c: Likewise.
+ * generated/matmul_i16.c: Likewise.
+ * generated/matmul_i2.c: Likewise.
+ * generated/matmul_i4.c: Likewise.
+ * generated/matmul_i8.c: Likewise.
+ * generated/matmul_r10.c: Likewise.
+ * generated/matmul_r16.c: Likewise.
+ * generated/matmul_r4.c: Likewise.
+ * generated/matmul_r8.c: Likewise.
+
2020-05-15 H.J. Lu <hongjiu.lu@intel.com>
PR bootstrap/95147
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_c10 (gfc_array_c10 * const restrict retarray,
gfc_array_c10 * const restrict a, gfc_array_c10 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_c10_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_c10_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_c10_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_c10_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_c10_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_c10_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_c16 (gfc_array_c16 * const restrict retarray,
gfc_array_c16 * const restrict a, gfc_array_c16 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_c16_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_c16_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_c16_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_c16_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_c16_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_c16_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_c4 (gfc_array_c4 * const restrict retarray,
gfc_array_c4 * const restrict a, gfc_array_c4 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_c4_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_c4_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_c4_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_c4_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_c4_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_c4_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_c8 (gfc_array_c8 * const restrict retarray,
gfc_array_c8 * const restrict a, gfc_array_c8 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_c8_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_c8_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_c8_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_c8_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_c8_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_c8_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_i1 (gfc_array_i1 * const restrict retarray,
gfc_array_i1 * const restrict a, gfc_array_i1 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_i1_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_i1_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_i1_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_i1_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_i1_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_i1_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_i16 (gfc_array_i16 * const restrict retarray,
gfc_array_i16 * const restrict a, gfc_array_i16 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_i16_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_i16_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_i16_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_i16_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_i16_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_i16_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_i2 (gfc_array_i2 * const restrict retarray,
gfc_array_i2 * const restrict a, gfc_array_i2 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_i2_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_i2_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_i2_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_i2_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_i2_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_i2_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_i4 (gfc_array_i4 * const restrict retarray,
gfc_array_i4 * const restrict a, gfc_array_i4 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_i4_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_i4_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_i4_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_i4_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_i4_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_i4_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_i8 (gfc_array_i8 * const restrict retarray,
gfc_array_i8 * const restrict a, gfc_array_i8 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_i8_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_i8_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_i8_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_i8_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_i8_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_i8_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_r10 (gfc_array_r10 * const restrict retarray,
gfc_array_r10 * const restrict a, gfc_array_r10 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_r10_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_r10_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_r10_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_r10_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_r10_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_r10_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_r16 (gfc_array_r16 * const restrict retarray,
gfc_array_r16 * const restrict a, gfc_array_r16 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_r16_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_r16_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_r16_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_r16_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_r16_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_r16_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_r4 (gfc_array_r4 * const restrict retarray,
gfc_array_r4 * const restrict a, gfc_array_r4 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_r4_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_r4_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_r4_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_r4_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_r4_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_r4_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_r8 (gfc_array_r8 * const restrict retarray,
gfc_array_r8 * const restrict a, gfc_array_r8 * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_r8_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_r8_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_r8_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_r8_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_r8_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_r8_avx128_fma4;
goto store;
/* Currently, this is i386 only. Adjust for other architectures. */
-#include <config/i386/cpuinfo.h>
void matmul_'rtype_code` ('rtype` * const restrict retarray,
'rtype` * const restrict a, 'rtype` * const restrict b, int try_blas,
int blas_limit, blas_call gemm)
if (matmul_fn == NULL)
{
matmul_fn = matmul_'rtype_code`_vanilla;
- if (__cpu_model.__cpu_vendor == VENDOR_INTEL)
+ if (__builtin_cpu_is ("intel"))
{
/* Run down the available processors in order of preference. */
#ifdef HAVE_AVX512F
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX512F))
+ if (__builtin_cpu_supports ("avx512f"))
{
matmul_fn = matmul_'rtype_code`_avx512f;
goto store;
#endif /* HAVE_AVX512F */
#ifdef HAVE_AVX2
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX2))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx2")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_'rtype_code`_avx2;
goto store;
#endif
#ifdef HAVE_AVX
- if (__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
+ if (__builtin_cpu_supports ("avx"))
{
matmul_fn = matmul_'rtype_code`_avx;
goto store;
}
#endif /* HAVE_AVX */
}
- else if (__cpu_model.__cpu_vendor == VENDOR_AMD)
+ else if (__builtin_cpu_is ("amd"))
{
#if defined(HAVE_AVX) && defined(HAVE_FMA3) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma"))
{
matmul_fn = matmul_'rtype_code`_avx128_fma3;
goto store;
}
#endif
#if defined(HAVE_AVX) && defined(HAVE_FMA4) && defined(HAVE_AVX128)
- if ((__cpu_model.__cpu_features[0] & (1 << FEATURE_AVX))
- && (__cpu_model.__cpu_features[0] & (1 << FEATURE_FMA4)))
+ if (__builtin_cpu_supports ("avx")
+ && __builtin_cpu_supports ("fma4"))
{
matmul_fn = matmul_'rtype_code`_avx128_fma4;
goto store;