Added more fine grained compatability for cpus in CPUID. Not implemented in NativeBigInteger yet.

This commit is contained in:
dev
2011-06-08 18:07:46 +00:00
parent 2cebe86524
commit 26899e488e

View File

@ -198,32 +198,44 @@ public class CPUID {
protected abstract static class CPUIDCPUInfo
{
protected boolean isX64 = false;
public String getVendor()
{
return getCPUVendorID();
}
public boolean hasMMX(){
public boolean hasMMX()
{
return (getEDXCPUFlags() & 0x800000) >0; //EDX Bit 23
}
public boolean hasSSE(){
return (getEDXCPUFlags() & 0x2000000) >0; //EDX Bit 25
}
public boolean hasSSE2(){
public boolean hasSSE2()
{
return (getEDXCPUFlags() & 0x4000000) >0; //EDX Bit 26
}
public boolean hasSSE3(){
public boolean hasSSE3()
{
return (getEDXCPUFlags() & 0x1) >0; //ECX Bit 0
}
public boolean hasSSE41(){
public boolean hasSSE41()
{
return (getEDXCPUFlags() & 0x80000) >0; //ECX Bit 19
}
public boolean hasSSE42(){
public boolean hasSSE42()
{
return (getEDXCPUFlags() & 0x100000) >0; //ECX Bit 20
}
public boolean hasSSE4A(){
public boolean hasSSE4A()
{
return (getExtendedECXCPUFlags() & 0x40) >0; //Extended ECX Bit 6
}
public boolean IsC3Compatible() { return false; }
public boolean hasX64()
{
return isX64;
}
}
protected static class VIAC3Impl extends CPUIDCPUInfo implements CPUInfo {
@ -234,41 +246,24 @@ public class CPUID {
protected static class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo
{
protected static boolean isK6Compatible = false;
protected static boolean isK6_2_Compatible = false;
protected static boolean isK6_3_Compatible = false;
protected static boolean isAthlonCompatible = false;
protected static boolean isAthlon64Compatible = false;
protected static boolean isBobcatCompatible = false;
//AMD-family = getCPUFamily()+getCPUExtendedFamily()
//AMD-model = getCPUModel()+getCPUExtendedModel()
public boolean IsK6Compatible(){
return (getCPUFamily() + getCPUExtendedFamily()) >= 5 && (getCPUModel() + getCPUExtendedModel()) >= 6;
}
public boolean IsK6_2_Compatible(){
return (getCPUFamily() + getCPUExtendedFamily()) >= 5 && (getCPUModel() + getCPUExtendedModel()) >= 8;
}
public boolean IsK6_3_Compatible(){
return (getCPUFamily() + getCPUExtendedFamily()) >= 5 && (getCPUModel() + getCPUExtendedModel()) >= 9;
}
public boolean IsAthlonCompatible(){
return (getCPUFamily() + getCPUExtendedFamily()) >= 6;
}
public boolean IsAthlon64Compatible(){
//AMD64 class
if ((getCPUFamily() + getCPUExtendedFamily()) == 15){
return true;
//Stars (Phenom II/Athlon II/Third-Generation Opteron/Opteron 4100 & 6100/Sempron 1xx)
} else if ((getCPUFamily() + getCPUExtendedFamily()) == 16){
return true;
//K8 mobile+HT3 (Turion X2/Athlon X2/Sempron)
} else if ((getCPUFamily() + getCPUExtendedFamily()) == 17){
return true;
} else {
return false;
}
}
public String getCPUModelString() throws UnknownCPUException {
public boolean IsK6Compatible(){ return isK6Compatible; }
public boolean IsK6_2_Compatible(){ return isK6_2_Compatible; }
public boolean IsK6_3_Compatible(){ return isK6_3_Compatible; }
public boolean IsAthlonCompatible(){ return isAthlonCompatible; }
public boolean IsAthlon64Compatible(){ return isAthlon64Compatible; }
public boolean IsBobcatCompatible(){ return isBobcatCompatible; }
public String getCPUModelString() throws UnknownCPUException
{
//i486 class (Am486, 5x86)
if(getCPUFamily() + getCPUExtendedFamily() == 4){
switch(getCPUModel() + getCPUExtendedModel()){
@ -288,6 +283,7 @@ public class CPUID {
}
//i586 class (K5/K6/K6-2/K6-III)
if(getCPUFamily() + getCPUExtendedFamily() == 5){
isK6Compatible = true;
switch(getCPUModel() + getCPUExtendedModel()){
case 0:
return "K5/SSA5";
@ -302,15 +298,23 @@ public class CPUID {
case 7:
return "K6";
case 8:
isK6_2_Compatible = true;
return "K6-2";
case 9:
isK6_2_Compatible = true;
isK6_3_Compatible = true;
return "K6-3";
case 13:
isK6_2_Compatible = true;
return "K6-2+ or K6-III+";
}
}
//i686 class (Athlon/Athlon XP/Duron/K7 Sempron)
if(getCPUFamily() + getCPUExtendedFamily() == 6){
isK6Compatible = true;
isK6_2_Compatible = true;
isK6_3_Compatible = true;
isAthlonCompatible = true;
switch(getCPUModel() + getCPUExtendedModel()){
case 0:
return "Athlon (250 nm)";
@ -334,6 +338,12 @@ public class CPUID {
}
//AMD64 class (A64/Opteron/A64 X2/K8 Sempron/Turion/Second-Generation Opteron/Athlon Neo)
if(getCPUFamily() + getCPUExtendedFamily() == 15){
isK6Compatible = true;
isK6_2_Compatible = true;
isK6_3_Compatible = true;
isAthlonCompatible = true;
isAthlon64Compatible = true;
isX64 = true;
switch(getCPUModel() + getCPUExtendedModel()){
case 4:
return "Athlon 64/Mobile XP-M";
@ -419,6 +429,12 @@ public class CPUID {
}
//Stars (Phenom II/Athlon II/Third-Generation Opteron/Opteron 4100 & 6100/Sempron 1xx)
if(getCPUFamily() + getCPUExtendedFamily() == 16){
isK6Compatible = true;
isK6_2_Compatible = true;
isK6_3_Compatible = true;
isAthlonCompatible = true;
isAthlon64Compatible = true;
isX64 = true;
switch(getCPUModel() + getCPUExtendedModel()){
case 2:
return "Phenom / Athlon / Opteron Gen 3 (Barcelona/Agena/Toliman/Kuma, 65 nm)";
@ -438,6 +454,12 @@ public class CPUID {
}
//K8 mobile+HT3 (Turion X2/Athlon X2/Sempron)
if(getCPUFamily() + getCPUExtendedFamily() == 17){
isK6Compatible = true;
isK6_2_Compatible = true;
isK6_3_Compatible = true;
isAthlonCompatible = true;
isAthlon64Compatible = true;
isX64 = true;
switch(getCPUModel() + getCPUExtendedModel()){
case 3:
return "AMD Turion X2/Athlon X2/Sempron (Lion/Sable, 65 nm)";
@ -445,6 +467,13 @@ public class CPUID {
}
//Bobcat
if(getCPUFamily() + getCPUExtendedFamily() == 20){
isK6Compatible = true;
isK6_2_Compatible = true;
isK6_3_Compatible = true;
isAthlonCompatible = true;
isAthlon64Compatible = true;
isBobcatCompatible = true;
isX64 = true;
switch(getCPUModel() + getCPUExtendedModel()){
case 1:
return "Bobcat APU";
@ -459,67 +488,26 @@ public class CPUID {
protected static class IntelInfoImpl extends CPUIDCPUInfo implements IntelCPUInfo
{
public boolean IsPentiumCompatible()
{
return getCPUFamily() >= 5;
}
public boolean IsPentiumMMXCompatible()
{
return IsPentium2Compatible() || (getCPUFamily() == 5 && (getCPUModel() ==4 || getCPUModel() == 8));
}
public boolean IsPentium2Compatible()
{
return getCPUFamily() > 6 || (getCPUFamily() == 6 && getCPUModel() >=3);
}
public boolean IsPentium3Compatible()
{
return getCPUFamily() > 6 || (getCPUFamily() == 6 && getCPUModel() >=7);
}
public boolean IsPentium4Compatible()
{
// P4
if (getCPUFamily() >= 15){
return true;
// Core i3/i5/i7
// Remove when implemented isCoreiCompatible in BigInteger
} else if (getCPUExtendedModel() == 2 && (getCPUFamily() == 6)){
// Xeon MP (45nm) or Core i7
// Remove when implemented isCoreiCompatible in BigInteger
} else if (getCPUExtendedModel() == 1 && (getCPUFamily() == 6 && (getCPUModel() == 10 || getCPUModel() == 13 || getCPUModel() == 14))){
return true;
// Core 2 Duo
// Remove when implemented isCore7Compatible in BigInteger
} else if (getCPUExtendedModel() == 0 && getCPUFamily() == 6 && getCPUModel() == 15){
return true;
}
return false;
}
public boolean IsAtomCompatible()
{
if (getCPUExtendedModel() == 0 && getCPUFamily() == 6 && getCPUModel() == 12){
return true;
}
return false;
protected static boolean isPentiumCompatible = false;
protected static boolean isPentiumMMXCompatible = false;
protected static boolean isPentium2Compatible = false;
protected static boolean isPentium3Compatible = false;
protected static boolean isPentium4Compatible = false;
protected static boolean isAtomCompatible = false;
protected static boolean isCore2Compatible = false;
protected static boolean isCoreiCompatible = false;
}
public boolean IsCore2Compatible()
public boolean IsPentiumCompatible(){ return isPentiumCompatible; }
public boolean IsPentiumMMXCompatible(){ return isPentiumMMXCompatible; }
public boolean IsPentium2Compatible(){ return isPentium2Compatible; }
public boolean IsPentium3Compatible(){ return isPentium3Compatible; }
public boolean IsPentium4Compatible(){ return isPentium4Compatible; }
public boolean IsAtomCompatible(){ return isAtomCompatible; }
public boolean IsCore2Compatible(){ return isCore2Compatible; }
public boolean IsCoreiCompatible(){ return isCoreiCompatible; }
public String getCPUModelString() throws UnknownCPUException
{
if (getCPUExtendedModel() == 0 && getCPUFamily() == 6 && getCPUModel() == 15){
return true;
}
return false;
}
public boolean IsCoreiCompatible()
{
// Core i3/i5/i7
if (getCPUExtendedModel() == 2 && (getCPUFamily() == 6)){
// Xeon MP (45nm) or Core i7
} else if (getCPUExtendedModel() == 1 && (getCPUFamily() == 6 && (getCPUModel() == 10 || getCPUModel() == 13 || getCPUModel() == 14))){
return true;
}
return false;
}
public String getCPUModelString() throws UnknownCPUException {
if (getCPUExtendedModel() == 0){
if(getCPUFamily() == 4){
switch(getCPUModel()){
@ -546,6 +534,7 @@ public class CPUID {
}
if (getCPUExtendedModel() == 0){
if(getCPUFamily() == 5){
isPentiumCompatible = true;
switch(getCPUModel()){
case 0:
return "Pentium 60/66 A-step";
@ -556,56 +545,108 @@ public class CPUID {
case 3:
return "OverDrive PODP5V83";
case 4:
isPentiumMMXCompatible = true;
return "Pentium MMX";
case 7:
return "Mobile Pentium 75 - 200";
case 8:
isPentiumMMXCompatible = true;
return "Mobile Pentium MMX";
}
}
}
if(getCPUFamily() == 6){
if (getCPUExtendedModel() == 0){
isPentiumCompatible = true;
isPentiumMMXCompatible = true;
switch(getCPUModel()){
case 0:
return "Pentium Pro A-step";
case 1:
return "Pentium Pro";
case 3:
isPentium2Compatible = true;
return "Pentium II (Klamath)";
case 5:
isPentium2Compatible = true;
return "Pentium II (Deschutes), Celeron (Covington), Mobile Pentium II (Dixon)";
case 6:
isPentium2Compatible = true;
return "Mobile Pentium II, Celeron (Mendocino)";
case 7:
isPentium2Compatible = true;
isPentium3Compatible = true;
return "Pentium III (Katmai)";
case 8:
isPentium2Compatible = true;
isPentium3Compatible = true;
return "Pentium III (Coppermine), Celeron w/SSE";
case 9:
return "Mobile Pentium III (Banias)";
isPentium2Compatible = true;
isPentium3Compatible = true;
isX64 = true;
return "Pentium M (Banias)";
case 10:
isPentium2Compatible = true;
isPentium3Compatible = true;
return "Pentium III Xeon (Cascades)";
case 11:
isPentium2Compatible = true;
isPentium3Compatible = true;
return "Pentium III (130 nm)";
case 13:
return "Mobile Pentium III (Dothan)";
isPentium2Compatible = true;
isPentium3Compatible = true;
isX64 = true;
return "Core (Yonah)";
case 14:
return "Mobile Core (Yonah)";
isPentium2Compatible = true;
isPentium3Compatible = true;
isCore2Compatible = true;
isX64 = true;
return "Core 2 (Conroe)";
case 15:
isPentium2Compatible = true;
isPentium3Compatible = true;
isCore2Compatible = true;
isX64 = true;
return "Core 2 (Conroe)";
}
} else if (getCPUExtendedModel() == 1){
isPentiumCompatible = true;
isPentiumMMXCompatible = true;
isPentium2Compatible = true;
isPentium3Compatible = true;
isPentium4Compatible = true;
isCore2Compatible = true;
isX64 = true;
switch(getCPUModel()){
case 6:
return "Celeron";
case 10:
isCoreiCompatible = true;
return "Core i7 (45nm)";
case 12:
isAtomCompatible = true;
isCore2Compatible = false;
isPentium4Compatible = false;
isX64 = true;
return "Atom";
case 13:
isCoreiCompatible = true;
return "Xeon MP (45nm)";
case 14:
isCoreiCompatible = true;
return "Core i5/i7 (45nm)";
}
} else if (getCPUExtendedModel() == 2){
isPentiumCompatible = true;
isPentiumMMXCompatible = true;
isPentium2Compatible = true;
isPentium3Compatible = true;
isCore2Compatible = true;
isCoreiCompatible = true;
isX64 = true;
switch(getCPUModel()){
case 5:
return "Core i3 or i5/i7 mobile (32nm)";
@ -627,6 +668,11 @@ public class CPUID {
}
if(getCPUFamily() == 15){
if(getCPUExtendedFamily() == 0){
isPentiumCompatible = true;
isPentiumMMXCompatible = true;
isPentium2Compatible = true;
isPentium3Compatible = true;
isPentium4Compatible = true;
switch(getCPUModel()){
case 0:
return "Pentium IV (180 nm)";
@ -637,8 +683,10 @@ public class CPUID {
case 3:
return "Pentium IV (90 nm)";
case 4:
isX64 = true;
return "Pentium IV (90 nm)";
case 6:
isX64 = true;
return "Pentium IV (65 nm)";
}
}