[Gmp-commit] /var/hg/gmp: 2 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Mon Jun 15 16:59:29 UTC 2015
details: /var/hg/gmp/rev/30c9cf97935a
changeset: 16713:30c9cf97935a
user: Torbjorn Granlund <torbjorng at google.com>
date: Mon Jun 15 18:03:10 2015 +0200
description:
Rewrite code for AVX handling to deal with broken cpuid states.
details: /var/hg/gmp/rev/5423329f78dd
changeset: 16714:5423329f78dd
user: Torbjorn Granlund <torbjorng at google.com>
date: Mon Jun 15 18:05:00 2015 +0200
description:
ChangeLog
diffstat:
ChangeLog | 7 +++-
config.guess | 112 +++++++++++++++++++++++++++++++---------------------------
2 files changed, 65 insertions(+), 54 deletions(-)
diffs (190 lines):
diff -r 4450bf49b523 -r 5423329f78dd ChangeLog
--- a/ChangeLog Mon Jun 15 12:57:10 2015 +0200
+++ b/ChangeLog Mon Jun 15 18:05:00 2015 +0200
@@ -1,3 +1,8 @@
+2015-06-15 Torbjörn Granlund <torbjorng at google.com>
+
+ * config.guess: Rewrite code for AVX handling to deal with broken cpuid
+ states.
+
2015-06-11 Torbjörn Granlund <torbjorng at google.com>
* mpn/x86/k7/gcd_1.asm: Align stack for calls.
@@ -7,7 +12,7 @@
* mpn/generic/sqrtrem.c: Use sqrtrem1 for single limb operands.
- * tests/mpz/t-root.c: Check also mpz_root retunr value.
+ * tests/mpz/t-root.c: Check also mpz_root return value.
* mpn/generic/rootrem.c: Shorten first and last loop.
* mpn/generic/toom2_sqr.c: Add some ASSERTs.
diff -r 4450bf49b523 -r 5423329f78dd config.guess
--- a/config.guess Mon Jun 15 12:57:10 2015 +0200
+++ b/config.guess Mon Jun 15 18:05:00 2015 +0200
@@ -766,25 +766,23 @@
main ()
{
char vendor_string[13];
- char dummy_string[12];
+ char feature_string[12];
long fms;
- int family, model, stepping;
+ int family, model;
const char *modelstr, *suffix;
- int cpu_64bit = 0;
+ int cpu_64bit = 0, cpu_avx = 0;
int cpuid_64bit, cpuid_avx, cpuid_osxsave;
CPUID (vendor_string, 0);
vendor_string[12] = 0;
- fms = CPUID (dummy_string, 1);
+ fms = CPUID (feature_string, 1);
family = ((fms >> 8) & 0xf) + ((fms >> 20) & 0xff);
model = ((fms >> 4) & 0xf) + ((fms >> 12) & 0xf0);
- stepping = fms & 0xf;
- cpuid_avx = (dummy_string[11] >> 4) & 1;
- cpuid_osxsave = (dummy_string[11] >> 3) & 1;
- suffix = cpuid_avx > cpuid_osxsave ? "noavx" : "";
+ cpuid_avx = (feature_string[11] >> 4) & 1;
+ cpuid_osxsave = (feature_string[11] >> 3) & 1;
modelstr = "$guess_cpu";
@@ -800,48 +798,48 @@
else if (model >= 4) modelstr = "pentiummmx";
break;
case 6:
- if (model <= 1) modelstr = "pentiumpro";
- else if (model <= 6) modelstr = "pentium2";
- else if (model <= 8) modelstr = "pentium3";
- else if (model <= 9) modelstr = "pentiumm";
- else if (model <= 0x0c) modelstr = "pentium3";
- else if (model <= 0x0e) modelstr = "pentiumm";
- else if (model <= 0x19) cpu_64bit = 1, modelstr = "core2";
- else if (model == 0x1a) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Gainestown */
- else if (model == 0x1c) cpu_64bit = 1, modelstr = "atom"; /* Silverthorne */
- else if (model == 0x1d) cpu_64bit = 1, modelstr = "core2"; /* PNR Dunnington */
- else if (model == 0x1e) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Lynnfield/Jasper */
- else if (model == 0x25) cpu_64bit = 1, modelstr = "westmere"; /* WSM Clarkdale/Arrandale */
- else if (model == 0x26) cpu_64bit = 1, modelstr = "atom"; /* Lincroft */
- else if (model == 0x27) cpu_64bit = 1, modelstr = "atom"; /* Saltwell */
- else if (model == 0x2a) cpu_64bit = 1, modelstr = "sandybridge";/* SB */
- else if (model == 0x2c) cpu_64bit = 1, modelstr = "westmere"; /* WSM Gulftown */
- else if (model == 0x2d) cpu_64bit = 1, modelstr = "sandybridge";/* SBC-EP */
- else if (model == 0x2e) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Beckton */
- else if (model == 0x2f) cpu_64bit = 1, modelstr = "westmere"; /* WSM Eagleton */
- else if (model == 0x36) cpu_64bit = 1, modelstr = "atom"; /* Cedarview/Saltwell */
- else if (model == 0x37) cpu_64bit = 1, modelstr = "silvermont"; /* Atom Silvermont */
- else if (model == 0x3a) cpu_64bit = 1, modelstr = "ivybridge"; /* IBR */
- else if (model == 0x3c) cpu_64bit = 1, modelstr = "haswell"; /* Haswell client */
- else if (model == 0x3d) cpu_64bit = 1, modelstr = "broadwell"; /* Broadwell */
- else if (model == 0x3e) cpu_64bit = 1, modelstr = "ivybridge"; /* Ivytown */
- else if (model == 0x3f) cpu_64bit = 1, modelstr = "haswell"; /* Haswell server */
- else if (model == 0x45) cpu_64bit = 1, modelstr = "haswell"; /* Haswell ULT */
- else if (model == 0x46) cpu_64bit = 1, modelstr = "haswell"; /* Crystal Well */
- else if (model == 0x47) cpu_64bit = 1, modelstr = "broadwell"; /* Broadwell */
- else if (model == 0x4a) cpu_64bit = 1, modelstr = "silvermont"; /* Silvermont */
- else if (model == 0x4c) cpu_64bit = 1, modelstr = "silvermont"; /* Airmont */
- else if (model == 0x4d) cpu_64bit = 1, modelstr = "silvermont"; /* Silvermont/Avoton */
- else if (model == 0x4f) cpu_64bit = 1, modelstr = "broadwell"; /* Broadwell server */
- else if (model == 0x56) cpu_64bit = 1, modelstr = "broadwell"; /* Broadwell microserver */
- else cpu_64bit = 1, modelstr = "nehalem"; /* default */
+ if (model <= 1) modelstr = "pentiumpro";
+ else if (model <= 6) modelstr = "pentium2";
+ else if (model <= 8) modelstr = "pentium3";
+ else if (model <= 9) modelstr = "pentiumm";
+ else if (model <= 0x0c) modelstr = "pentium3";
+ else if (model <= 0x0e) modelstr = "pentiumm";
+ else if (model <= 0x19) cpu_64bit = 1, modelstr = "core2";
+ else if (model == 0x1a) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Gainestown */
+ else if (model == 0x1c) cpu_64bit = 1, modelstr = "atom"; /* Silverthorne */
+ else if (model == 0x1d) cpu_64bit = 1, modelstr = "core2"; /* PNR Dunnington */
+ else if (model == 0x1e) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Lynnfield/Jasper */
+ else if (model == 0x25) cpu_64bit = 1, modelstr = "westmere"; /* WSM Clarkdale/Arrandale */
+ else if (model == 0x26) cpu_64bit = 1, modelstr = "atom"; /* Lincroft */
+ else if (model == 0x27) cpu_64bit = 1, modelstr = "atom"; /* Saltwell */
+ else if (model == 0x2a) cpu_64bit = 1, cpu_avx=1, modelstr = "sandybridge";/* SB */
+ else if (model == 0x2c) cpu_64bit = 1, modelstr = "westmere"; /* WSM Gulftown */
+ else if (model == 0x2d) cpu_64bit = 1, cpu_avx=1, modelstr = "sandybridge";/* SBC-EP */
+ else if (model == 0x2e) cpu_64bit = 1, modelstr = "nehalem"; /* NHM Beckton */
+ else if (model == 0x2f) cpu_64bit = 1, modelstr = "westmere"; /* WSM Eagleton */
+ else if (model == 0x36) cpu_64bit = 1, modelstr = "atom"; /* Cedarview/Saltwell */
+ else if (model == 0x37) cpu_64bit = 1, modelstr = "silvermont"; /* Atom Silvermont */
+ else if (model == 0x3a) cpu_64bit = 1, cpu_avx=1, modelstr = "ivybridge"; /* IBR */
+ else if (model == 0x3c) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell"; /* Haswell client */
+ else if (model == 0x3d) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell"; /* Broadwell */
+ else if (model == 0x3e) cpu_64bit = 1, cpu_avx=1, modelstr = "ivybridge"; /* Ivytown */
+ else if (model == 0x3f) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell"; /* Haswell server */
+ else if (model == 0x45) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell"; /* Haswell ULT */
+ else if (model == 0x46) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell"; /* Crystal Well */
+ else if (model == 0x47) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell"; /* Broadwell */
+ else if (model == 0x4a) cpu_64bit = 1, modelstr = "silvermont"; /* Silvermont */
+ else if (model == 0x4c) cpu_64bit = 1, modelstr = "silvermont"; /* Airmont */
+ else if (model == 0x4d) cpu_64bit = 1, modelstr = "silvermont"; /* Silvermont/Avoton */
+ else if (model == 0x4f) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell"; /* Broadwell server */
+ else if (model == 0x56) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell"; /* Broadwell microserver */
+ else cpu_64bit = 1, modelstr = "nehalem"; /* default */
if (strcmp (modelstr, "haswell") == 0)
{
/* Some Haswells lack BMI2. Let them appear as Sandybridges for
now. */
- CPUID (dummy_string, 7);
- if ((dummy_string[0 + 8 / 8] & (1 << (8 % 8))) == 0)
+ CPUID (feature_string, 7);
+ if ((feature_string[0 + 8 / 8] & (1 << (8 % 8))) == 0)
modelstr = "sandybridge";
}
@@ -885,7 +883,7 @@
cpu_64bit = 1, modelstr = "bobcat";
break;
case 21: /* Bulldozer */
- cpu_64bit = 1;
+ cpu_64bit = 1, cpu_avx = 1;
if (model <= 1)
modelstr = "bulldozer";
else if (model < 0x20) /* really 2, [0x10-0x20) */
@@ -896,7 +894,7 @@
modelstr = "excavator";
break;
case 22: /* Jaguar, an improved bobcat */
- cpu_64bit = 1, modelstr = "jaguar";
+ cpu_64bit = 1, cpu_avx = 1, modelstr = "jaguar";
break;
}
}
@@ -916,15 +914,23 @@
}
}
- CPUID (dummy_string, 0x80000001);
- cpuid_64bit = (dummy_string[7] >> 5) & 1;
+ CPUID (feature_string, 0x80000001);
+ cpuid_64bit = (feature_string[7] >> 5) & 1;
- /* If our cpuid-based CPU identification thinks this is a 32-bit CPU but
- cpuid claims AMD64 capabilities, then revert to the generic "x86_64".
- This is of course wrong, but it can happen in some emulators, so this
- workaround allows for successful 64-bit builds. */
+ suffix = "";
+
if (cpuid_64bit && ! cpu_64bit)
+ /* If our cpuid-based CPU identification thinks this is a 32-bit CPU but
+ cpuid claims AMD64 capabilities, then revert to the generic "x86_64".
+ This is of course wrong, but it can happen in some virtualisers and
+ emulators, so this workaround allows for successful 64-bit builds. */
modelstr = "x86_64";
+ else if (cpu_avx && ! (cpuid_avx && cpuid_osxsave))
+ /* For CPUs nominally capable of executing AVX, append "noavx" when not
+ both the AVX and OSXSAVE cpuid bits are set. We tolerate weirdness
+ here, as some virtualisers set a broken cpuid state here, while other
+ virtualisers allow users to set a broken state. */
+ suffix = "noavx";
printf ("%s%s", modelstr, suffix);
return 0;
More information about the gmp-commit
mailing list