From e4e3fe7e261b123e1b93493630cd515eb471124d Mon Sep 17 00:00:00 2001 From: Erik Lindahl Date: Sun, 3 Apr 2016 21:52:08 +0200 Subject: [PATCH] Fix SIMD detection on new AMD AVX CPUs w/o fma We earlier assumed that all AMD CPUs had fma support and could use AVX_128_FMA, but with this change we properly detect it and revert to AVX_256 otherwise. Fixes #1906 for release-5.1. Change-Id: I803a6bfa75c5069b73023688a477cfca03c1ddcd --- src/gromacs/gmxlib/gmx_cpuid.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gromacs/gmxlib/gmx_cpuid.c b/src/gromacs/gmxlib/gmx_cpuid.c index bcf598d57e..48e5ddd253 100644 --- a/src/gromacs/gmxlib/gmx_cpuid.c +++ b/src/gromacs/gmxlib/gmx_cpuid.c @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by + * Copyright (c) 2012,2013,2014,2015,2016, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -1263,9 +1263,20 @@ gmx_cpuid_simd_suggest (gmx_cpuid_t cpuid) } else if (gmx_cpuid_vendor(cpuid) == GMX_CPUID_VENDOR_AMD) { - if (gmx_cpuid_feature(cpuid, GMX_CPUID_FEATURE_X86_AVX)) + if (gmx_cpuid_feature(cpuid, GMX_CPUID_FEATURE_X86_AVX2)) + { + tmpsimd = GMX_CPUID_SIMD_X86_AVX2_256; + } + else if (gmx_cpuid_feature(cpuid, GMX_CPUID_FEATURE_X86_AVX)) { - tmpsimd = GMX_CPUID_SIMD_X86_AVX_128_FMA; + if (gmx_cpuid_feature(cpuid, GMX_CPUID_FEATURE_X86_FMA)) + { + tmpsimd = GMX_CPUID_SIMD_X86_AVX_128_FMA; + } + else + { + tmpsimd = GMX_CPUID_SIMD_X86_AVX_256; + } } else if (gmx_cpuid_feature(cpuid, GMX_CPUID_FEATURE_X86_SSE4_1)) { -- 2.11.4.GIT