CPUID/NBI: Prep for GMP 6.1.2

Add Skylake support (ticket #1869)
Recognize more Intel "Lake" processors
Clean up CLI output
This commit is contained in:
zzz
2019-06-06 13:28:44 +00:00
parent 6d72aeed8c
commit e82a547bce
4 changed files with 88 additions and 41 deletions

View File

@@ -343,7 +343,7 @@ public class CPUID {
System.out.println("**CPUInfo**");
String mname = getCPUModelName();
if (mname != null)
System.out.println("CPU Model Name: " + mname);
System.out.println("CPU Name: " + mname);
String vendor = getCPUVendorID();
System.out.println("CPU Vendor: " + vendor);
// http://en.wikipedia.org/wiki/Cpuid
@@ -359,7 +359,7 @@ public class CPUID {
family += getCPUExtendedFamily();
}
System.out.println("CPU Family: " + family);
System.out.println("CPU Model: " + model);
System.out.println("CPU Model: " + model + " (0x" + Integer.toHexString(model) + ')');
System.out.println("CPU Stepping: " + getCPUStepping());
System.out.println("CPU Flags (EDX): 0x" + Integer.toHexString(getEDXCPUFlags()));
System.out.println("CPU Flags (ECX): 0x" + Integer.toHexString(getECXCPUFlags()));
@@ -370,7 +370,7 @@ public class CPUID {
CPUInfo c = getInfo();
System.out.println("\n**More CPUInfo**");
System.out.println("CPU model string: " + c.getCPUModelString());
System.out.println("CPU model name: " + c.getCPUModelString());
System.out.println("CPU has MMX: " + c.hasMMX());
System.out.println("CPU has SSE: " + c.hasSSE());
System.out.println("CPU has SSE2: " + c.hasSSE2());
@@ -390,34 +390,36 @@ public class CPUID {
System.out.println("CPU has MOVBE: " + c.hasMOVBE());
System.out.println("CPU has ABM: " + c.hasABM());
if(c instanceof IntelCPUInfo){
IntelCPUInfo cc = (IntelCPUInfo) c;
System.out.println("\n**Intel-info**");
System.out.println("Is PII-compatible: "+((IntelCPUInfo)c).IsPentium2Compatible());
System.out.println("Is PIII-compatible: "+((IntelCPUInfo)c).IsPentium3Compatible());
System.out.println("Is PIV-compatible: "+((IntelCPUInfo)c).IsPentium4Compatible());
System.out.println("Is Atom-compatible: "+((IntelCPUInfo)c).IsAtomCompatible());
System.out.println("Is Pentium M compatible: "+((IntelCPUInfo)c).IsPentiumMCompatible());
System.out.println("Is Core2-compatible: "+((IntelCPUInfo)c).IsCore2Compatible());
System.out.println("Is Corei-compatible: "+((IntelCPUInfo)c).IsCoreiCompatible());
System.out.println("Is Sandy-compatible: "+((IntelCPUInfo)c).IsSandyCompatible());
System.out.println("Is Ivy-compatible: "+((IntelCPUInfo)c).IsIvyCompatible());
System.out.println("Is Haswell-compatible: "+((IntelCPUInfo)c).IsHaswellCompatible());
System.out.println("Is Broadwell-compatible: "+((IntelCPUInfo)c).IsBroadwellCompatible());
}
if(c instanceof AMDCPUInfo){
System.out.println("Is PII-compatible: " + cc.IsPentium2Compatible());
System.out.println("Is PIII-compatible: " + cc.IsPentium3Compatible());
System.out.println("Is PIV-compatible: " + cc.IsPentium4Compatible());
System.out.println("Is Atom-compatible: " + cc.IsAtomCompatible());
System.out.println("Is Pentium M compatible: " + cc.IsPentiumMCompatible());
System.out.println("Is Core2-compatible: " + cc.IsCore2Compatible());
System.out.println("Is Corei-compatible: " + cc.IsCoreiCompatible());
System.out.println("Is Sandy-compatible: " + cc.IsSandyCompatible());
System.out.println("Is Ivy-compatible: " + cc.IsIvyCompatible());
System.out.println("Is Haswell-compatible: " + cc.IsHaswellCompatible());
System.out.println("Is Broadwell-compatible: " + cc.IsBroadwellCompatible());
System.out.println("Is Skylake-compatible: " + cc.IsSkylakeCompatible());
} else if (c instanceof AMDCPUInfo) {
AMDCPUInfo cc = (AMDCPUInfo) c;
System.out.println("\n**AMD-info**");
System.out.println("Is K6-compatible: "+((AMDCPUInfo)c).IsK6Compatible());
System.out.println("Is K6_2-compatible: "+((AMDCPUInfo)c).IsK6_2_Compatible());
System.out.println("Is K6_3-compatible: "+((AMDCPUInfo)c).IsK6_3_Compatible());
System.out.println("Is Geode-compatible: "+((AMDCPUInfo)c).IsGeodeCompatible());
System.out.println("Is Athlon-compatible: "+((AMDCPUInfo)c).IsAthlonCompatible());
System.out.println("Is Athlon64-compatible: "+((AMDCPUInfo)c).IsAthlon64Compatible());
System.out.println("Is Bobcat-compatible: "+((AMDCPUInfo)c).IsBobcatCompatible());
System.out.println("Is K10-compatible: "+((AMDCPUInfo)c).IsK10Compatible());
System.out.println("Is Jaguar-compatible: "+((AMDCPUInfo)c).IsJaguarCompatible());
System.out.println("Is Bulldozer-compatible: "+((AMDCPUInfo)c).IsBulldozerCompatible());
System.out.println("Is Piledriver-compatible: "+((AMDCPUInfo)c).IsPiledriverCompatible());
System.out.println("Is Steamroller-compatible: "+((AMDCPUInfo)c).IsSteamrollerCompatible());
System.out.println("Is Excavator-compatible: "+((AMDCPUInfo)c).IsExcavatorCompatible());
System.out.println("Is K6-compatible: " + cc.IsK6Compatible());
System.out.println("Is K6_2-compatible: " + cc.IsK6_2_Compatible());
System.out.println("Is K6_3-compatible: " + cc.IsK6_3_Compatible());
System.out.println("Is Geode-compatible: " + cc.IsGeodeCompatible());
System.out.println("Is Athlon-compatible: " + cc.IsAthlonCompatible());
System.out.println("Is Athlon64-compatible: " + cc.IsAthlon64Compatible());
System.out.println("Is Bobcat-compatible: " + cc.IsBobcatCompatible());
System.out.println("Is K10-compatible: " + cc.IsK10Compatible());
System.out.println("Is Jaguar-compatible: " + cc.IsJaguarCompatible());
System.out.println("Is Bulldozer-compatible: " + cc.IsBulldozerCompatible());
System.out.println("Is Piledriver-compatible: " + cc.IsPiledriverCompatible());
System.out.println("Is Steamroller-compatible: " + cc.IsSteamrollerCompatible());
System.out.println("Is Excavator-compatible: " + cc.IsExcavatorCompatible());
}
}

View File

@@ -139,4 +139,11 @@ public interface IntelCPUInfo extends CPUInfo {
* @since 0.9.26
*/
public boolean IsBroadwellCompatible();
/**
* Supports the AVX-512 instrutions.
*
* @since 0.9.41
*/
public boolean IsSkylakeCompatible();
}

View File

@@ -23,6 +23,7 @@ class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
private static boolean isIvyCompatible;
private static boolean isHaswellCompatible;
private static boolean isBroadwellCompatible;
private static boolean isSkylakeCompatible;
// If modelString != null, the cpu is considered correctly identified.
private static final String smodel = identifyCPU();
@@ -39,6 +40,11 @@ class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
public boolean IsIvyCompatible(){ return isIvyCompatible; }
public boolean IsHaswellCompatible(){ return isHaswellCompatible; }
public boolean IsBroadwellCompatible(){ return isBroadwellCompatible; }
/**
* Supports the AVX-512 instrutions.
* @since 0.9.41
*/
public boolean IsSkylakeCompatible() { return isSkylakeCompatible; }
public String getCPUModelString() throws UnknownCPUException
{
@@ -61,6 +67,10 @@ class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
if (family == 15 || family == 6) {
// Intel uses extended model for family = 15 or family = 6,
// which is not what wikipedia says
// we construct the model from EAX as follows:
// ext. model is 5th byte, base model is 2nd byte
// So e.g. for a published CPUID value of "306C1"
// the model here would be 0x3c, it's a Haswell.
model += CPUID.getCPUExtendedModel() << 4;
}
if (family == 15) {
@@ -439,15 +449,23 @@ class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
// See Haswell notes above
case 0x4e:
case 0x55:
case 0x5e: {
case 0x5c: // Apollo Lake
case 0x5e:
case 0x66: // Cannon Lake
case 0x67: // Cannon Lake
case 0x6c: // Apollo Lake
{
CPUIDCPUInfo c = new CPUIDCPUInfo();
if (c.hasAVX2() && c.hasBMI1() && c.hasBMI2() &&
c.hasFMA3() && c.hasMOVBE() && c.hasABM()) {
isSandyCompatible = true;
isIvyCompatible = true;
isHaswellCompatible = true;
if (c.hasADX())
if (c.hasADX()) {
isBroadwellCompatible = true;
if (c.hasAVX512())
isSkylakeCompatible = true;
}
modelString = "Skylake Core i3/i5/i7";
} else {
// This processor is "corei" compatible, as we define it,
@@ -463,23 +481,37 @@ class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
break;
}
// TODO case 0x5f: // Goldmont / Atom
// TODO case 0x7a: // Gemini Lake
// TODO case 0x7e: // Ice Lake
// following are for extended model == 8 or 9
// most flags are set above
// isCoreiCompatible = true is the default
// Kaby Lake
// ref: https://github.com/InstLatx64/InstLatx64/commit/9d2ea1a9eb727868dc514900da9e2f175710f9bf
// ref: https://github.com/InstLatx64/InstLatx64/blob/master/ChangeLog.htm
// ref: https://github.com/coreboot/coreboot/blob/master/src/soc/intel/common/block/include/intelblocks/mp_init.h
// See Haswell notes above
case 0x8e:
case 0x9e: {
case 0x8e: // also Whiskey Lake, Coffee Lake
case 0x9e: // also Whiskey Lake, Coffee Lake
case 0xa5: // Comet Lake
case 0xa6: // Comet Lake
{
CPUIDCPUInfo c = new CPUIDCPUInfo();
if (c.hasAVX2() && c.hasBMI1() && c.hasBMI2() &&
c.hasFMA3() && c.hasMOVBE() && c.hasABM()) {
isSandyCompatible = true;
isIvyCompatible = true;
isHaswellCompatible = true;
if (c.hasADX())
if (c.hasADX()) {
isBroadwellCompatible = true;
if (c.hasAVX512())
isSkylakeCompatible = true;
}
modelString = "Kaby Lake Core i3/i5/i7";
} else {
// This processor is "corei" compatible, as we define it,

View File

@@ -172,6 +172,8 @@ public class NativeBigInteger extends BigInteger {
private final static String JBIGI_OPTIMIZATION_EXCAVATOR = "excavator";
private final static String JBIGI_OPTIMIZATION_BOBCAT = "bobcat";
private final static String JBIGI_OPTIMIZATION_JAGUAR = "jaguar";
/** @since 0.9.41 */
private final static String JBIGI_OPTIMIZATION_SKYLAKE = "skylake";
/**
* Non-x86, no fallbacks to older libs or to "none"
@@ -233,7 +235,8 @@ public class NativeBigInteger extends BigInteger {
private final static String[] JBIGI_COMPAT_LIST_INTEL_PENTIUM = {JBIGI_OPTIMIZATION_PENTIUM4, JBIGI_OPTIMIZATION_PENTIUMM, JBIGI_OPTIMIZATION_PENTIUM3,
JBIGI_OPTIMIZATION_PENTIUM2, JBIGI_OPTIMIZATION_PENTIUMMMX, JBIGI_OPTIMIZATION_PENTIUM,
JBIGI_OPTIMIZATION_X86};
private final static String[] JBIGI_COMPAT_LIST_INTEL_CORE = {JBIGI_OPTIMIZATION_COREI_BWL, JBIGI_OPTIMIZATION_COREI_HWL, JBIGI_OPTIMIZATION_COREI_SBR,
private final static String[] JBIGI_COMPAT_LIST_INTEL_CORE = {JBIGI_OPTIMIZATION_SKYLAKE,
JBIGI_OPTIMIZATION_COREI_BWL, JBIGI_OPTIMIZATION_COREI_HWL, JBIGI_OPTIMIZATION_COREI_SBR,
JBIGI_OPTIMIZATION_COREI, JBIGI_OPTIMIZATION_CORE2, JBIGI_OPTIMIZATION_PENTIUMM,
JBIGI_OPTIMIZATION_PENTIUM3, JBIGI_OPTIMIZATION_X86};
@@ -293,6 +296,7 @@ public class NativeBigInteger extends BigInteger {
put(JBIGI_OPTIMIZATION_COREI_SBR, JBIGI_COMPAT_LIST_INTEL_CORE);
put(JBIGI_OPTIMIZATION_COREI_HWL, JBIGI_COMPAT_LIST_INTEL_CORE);
put(JBIGI_OPTIMIZATION_COREI_BWL, JBIGI_COMPAT_LIST_INTEL_CORE);
put(JBIGI_OPTIMIZATION_SKYLAKE, JBIGI_COMPAT_LIST_INTEL_CORE);
}};
/**
@@ -387,6 +391,8 @@ public class NativeBigInteger extends BigInteger {
return JBIGI_OPTIMIZATION_K6;
} else if (c instanceof IntelCPUInfo) {
IntelCPUInfo intelcpu = (IntelCPUInfo) c;
if (intelcpu.IsSkylakeCompatible())
return JBIGI_OPTIMIZATION_SKYLAKE;
if (intelcpu.IsBroadwellCompatible())
return JBIGI_OPTIMIZATION_COREI_BWL;
if (intelcpu.IsHaswellCompatible())