Added hasBMI2() feature detection and use it to list some Celeron Haswell CPUs as non-Haswell CPUs.

This commit is contained in:
dev
2015-12-14 18:54:58 +00:00
parent fe3642edd4
commit 2c8179f057
4 changed files with 29 additions and 9 deletions

View File

@@ -324,6 +324,7 @@ public class CPUID {
System.out.println("\n **More CPUInfo**");
System.out.println("CPU model string: " + c.getCPUModelString());
System.out.println("CPU has MMX: " + c.hasMMX());
System.out.println("CPU has BMI2: " + c.hasBMI2());
System.out.println("CPU has SSE: " + c.hasSSE());
System.out.println("CPU has SSE2: " + c.hasSSE2());
System.out.println("CPU has SSE3: " + c.hasSSE3());

View File

@@ -17,6 +17,10 @@ abstract class CPUIDCPUInfo implements CPUInfo
return (CPUID.getEDXCPUFlags() & (1 << 23)) != 0; //EDX Bit 23
}
public boolean hasBMI2(){
return (CPUID.getExtendedEBXFeatureFlags() & (1 << 8)) != 0; // Extended EBX Bit 8
}
public boolean hasSSE(){
return (CPUID.getEDXCPUFlags() & (1 << 25)) != 0; //EDX Bit 25
}

View File

@@ -22,6 +22,7 @@ public interface CPUInfo
* @return A string indicating the vendor of the CPU.
*/
public String getVendor();
/**
* @return A string detailing what type of CPU that is present in the machine. I.e. 'Pentium IV' etc.
* @throws UnknownCPUException If for any reason the retrieval of the requested information
@@ -29,32 +30,39 @@ public interface CPUInfo
* cause of the failure.
*/
public String getCPUModelString() throws UnknownCPUException;
/**
* @return true iff the CPU support the MMX instruction set.
* @return true iff the CPU supports the MMX instruction set.
*/
public boolean hasMMX();
/**
* @return true iff the CPU support the SSE instruction set.
* @return true iff the CPU supports the BMI2 instruction set.
*/
public boolean hasBMI2();
/**
* @return true iff the CPU supports the SSE instruction set.
*/
public boolean hasSSE();
/**
* @return true iff the CPU support the SSE2 instruction set.
* @return true iff the CPU supports the SSE2 instruction set.
*/
public boolean hasSSE2();
/**
* @return true iff the CPU support the SSE3 instruction set.
* @return true iff the CPU supports the SSE3 instruction set.
*/
public boolean hasSSE3();
/**
* @return true iff the CPU support the SSE4.1 instruction set.
* @return true iff the CPU supports the SSE4.1 instruction set.
*/
public boolean hasSSE41();
/**
* @return true iff the CPU support the SSE4.2 instruction set.
* @return true iff the CPU supports the SSE4.2 instruction set.
*/
public boolean hasSSE42();
@@ -62,7 +70,7 @@ public interface CPUInfo
* AMD K10 only. Not supported on Intel.
* ref: https://en.wikipedia.org/wiki/SSE4.2#SSE4a
*
* @return true iff the CPU support the SSE4A instruction set.
* @return true iff the CPU supports the SSE4A instruction set.
*/
public boolean hasSSE4A();
@@ -105,6 +113,7 @@ public interface CPUInfo
* @since 0.9.21
*/
public boolean hasTBM();
/**
* @return true iff the CPU supports the AES-NI instruction set.
* @since 0.9.14

View File

@@ -37,7 +37,13 @@ class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
public boolean IsCoreiCompatible(){ return isCoreiCompatible; }
public boolean IsSandyCompatible(){ return isSandyCompatible; }
public boolean IsIvyCompatible(){ return isIvyCompatible; }
public boolean IsHaswellCompatible(){ return isHaswellCompatible; }
public boolean IsHaswellCompatible(){
// Some Celeron Haswell CPUs do not support BMI2, which
// GMP-6.0 assumes is present in all Haswell CPUs and causes
// crashes. Mark these CPUs as non-Haswell.
return this.hasBMI2() && isHaswellCompatible;
}
public boolean IsBroadwellCompatible(){ return isBroadwellCompatible; }
public String getCPUModelString() throws UnknownCPUException