From 21f75b58dbcae739db3040ca9091b683672f81fc Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Tue, 23 Nov 2010 21:32:52 +0000 Subject: [PATCH] * Added code to detect amount of physical ram installed on the host computer. * Added logging of host operating system and physical ram to startup. * Removed "PhysicalCores" stuff from both x86emitter and startup logs -- physical cores is losing its relevance with all the new AMD and Intel chip designs. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4048 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Utilities/General.h | 1 + common/include/x86emitter/tools.h | 4 --- common/src/Utilities/Linux/LnxMisc.cpp | 15 ++++++++--- common/src/Utilities/Windows/WinHostSys.cpp | 1 + common/src/Utilities/Windows/WinMisc.cpp | 8 ++++++ common/src/x86emitter/LnxCpuDetect.cpp | 17 +++--------- common/src/x86emitter/WinCpuDetect.cpp | 4 --- common/src/x86emitter/cpudetect.cpp | 23 ---------------- pcsx2/System.cpp | 29 +++++++++++++-------- 9 files changed, 43 insertions(+), 59 deletions(-) diff --git a/common/include/Utilities/General.h b/common/include/Utilities/General.h index d405f9472d..54e0afd373 100644 --- a/common/include/Utilities/General.h +++ b/common/include/Utilities/General.h @@ -251,5 +251,6 @@ namespace HostSys extern void InitCPUTicks(); extern u64 GetTickFrequency(); extern u64 GetCPUTicks(); +extern u64 GetPhysicalMemory(); extern wxString GetOSVersionString(); diff --git a/common/include/x86emitter/tools.h b/common/include/x86emitter/tools.h index 3520db5075..6fd8aa8d23 100644 --- a/common/include/x86emitter/tools.h +++ b/common/include/x86emitter/tools.h @@ -31,8 +31,6 @@ class x86capabilities { public: bool isIdentified; - u32 LogicalCoresPerPhysicalCPU; - u32 PhysicalCoresPerPhysicalCPU; public: x86VendorType VendorID; @@ -106,8 +104,6 @@ public: { isIdentified = false; VendorID = x86Vendor_Unknown; - LogicalCoresPerPhysicalCPU = 1; - PhysicalCoresPerPhysicalCPU = 1; } void Identify(); diff --git a/common/src/Utilities/Linux/LnxMisc.cpp b/common/src/Utilities/Linux/LnxMisc.cpp index f3c00b4d52..f2e11f442a 100644 --- a/common/src/Utilities/Linux/LnxMisc.cpp +++ b/common/src/Utilities/Linux/LnxMisc.cpp @@ -20,11 +20,18 @@ #include #include -extern "C" __aligned16 u8 _xmm_backup[16*2]; -extern "C" __aligned16 u8 _mmx_backup[8*4]; +// Returns 0 on failure (not supported by the operating system). +u64 GetPhysicalMemory() +{ + u64 pages = 0; + +#ifdef _SC_PHYS_PAGES + pages = sysconf(_SC_PHYS_PAGES); +#endif + + return pages * getpagesize(); +} -u8 _xmm_backup[16*2]; -u8 _mmx_backup[8*4]; void InitCPUTicks() { diff --git a/common/src/Utilities/Windows/WinHostSys.cpp b/common/src/Utilities/Windows/WinHostSys.cpp index d35b258246..f010aeec93 100644 --- a/common/src/Utilities/Windows/WinHostSys.cpp +++ b/common/src/Utilities/Windows/WinHostSys.cpp @@ -19,6 +19,7 @@ #include + int SysPageFaultExceptionFilter( EXCEPTION_POINTERS* eps ) { if( eps->ExceptionRecord->ExceptionCode != EXCEPTION_ACCESS_VIOLATION ) diff --git a/common/src/Utilities/Windows/WinMisc.cpp b/common/src/Utilities/Windows/WinMisc.cpp index 07885b994f..89a03d08f4 100644 --- a/common/src/Utilities/Windows/WinMisc.cpp +++ b/common/src/Utilities/Windows/WinMisc.cpp @@ -39,6 +39,14 @@ u64 GetCPUTicks() return count.QuadPart; } +u64 GetPhysicalMemory() +{ + MEMORYSTATUSEX status; + status.dwLength = sizeof(status); + GlobalMemoryStatusEx(&status); + return status.ullTotalPhys; +} + // Windows SDK 7 provides this but previous ones do not, so roll our own in those cases: #ifndef VER_SUITE_WH_SERVER # define VER_SUITE_WH_SERVER 0x00008000 diff --git a/common/src/x86emitter/LnxCpuDetect.cpp b/common/src/x86emitter/LnxCpuDetect.cpp index e79cd37685..145e382d7c 100644 --- a/common/src/x86emitter/LnxCpuDetect.cpp +++ b/common/src/x86emitter/LnxCpuDetect.cpp @@ -21,19 +21,10 @@ // FreeBSD/OsX need something far more complicated (apparently) void x86capabilities::CountLogicalCores() { - const uint numCPU = sysconf( _SC_NPROCESSORS_ONLN ); - if( numCPU > 0 ) - { - //isMultiCore = numCPU > 1; - LogicalCores = numCPU; - PhysicalCores = ( numCPU / LogicalCoresPerPhysicalCPU ) * PhysicalCoresPerPhysicalCPU; - } - else - { - // Indeterminate? - LogicalCores = 1; - PhysicalCores = 1; - } + // Note : GetCPUCount uses sysconf( _SC_NPROCESSORS_ONLN ) internally, which can return 1 + // if sysconf info isn't available (a long standing linux bug). There are no fallbacks or + // alternatives, apparently. + LogicalCores = wxThread::GetCPUCount(); } bool CanEmitShit() diff --git a/common/src/x86emitter/WinCpuDetect.cpp b/common/src/x86emitter/WinCpuDetect.cpp index 02899fef43..7a952e5e6d 100644 --- a/common/src/x86emitter/WinCpuDetect.cpp +++ b/common/src/x86emitter/WinCpuDetect.cpp @@ -37,10 +37,6 @@ void x86capabilities::CountLogicalCores() } LogicalCores = CPUs; - if( LogicalCoresPerPhysicalCPU > CPUs) // for 1-socket HTT-disabled machines - LogicalCoresPerPhysicalCPU = CPUs; - - PhysicalCores = ( CPUs / LogicalCoresPerPhysicalCPU ) * PhysicalCoresPerPhysicalCPU; } bool _test_instruction( void* pfnCall ) diff --git a/common/src/x86emitter/cpudetect.cpp b/common/src/x86emitter/cpudetect.cpp index 95928cf85b..bca8cb6a1f 100644 --- a/common/src/x86emitter/cpudetect.cpp +++ b/common/src/x86emitter/cpudetect.cpp @@ -133,23 +133,6 @@ void x86capabilities::CountCores() s32 regs[ 4 ]; u32 cmds; - LogicalCoresPerPhysicalCPU = 0; - PhysicalCoresPerPhysicalCPU = 1; - - // detect multicore for Intel cpu - - __cpuid( regs, 0 ); - cmds = regs[ 0 ]; - - if( cmds >= 0x00000001 ) - LogicalCoresPerPhysicalCPU = ( regs[1] >> 16 ) & 0xff; - - if ((cmds >= 0x00000004) && (VendorID == x86Vendor_Intel)) - { - __cpuid( regs, 0x00000004 ); - PhysicalCoresPerPhysicalCPU += ( regs[0] >> 26) & 0x3f; - } - __cpuid( regs, 0x80000000 ); cmds = regs[ 0 ]; @@ -157,9 +140,6 @@ void x86capabilities::CountCores() if ((cmds >= 0x80000008) && (VendorID == x86Vendor_AMD) ) { - __cpuid( regs, 0x80000008 ); - PhysicalCoresPerPhysicalCPU += ( regs[2] ) & 0xff; - // AMD note: they don't support hyperthreading, but they like to flag this true // anyway. Let's force-unflag it until we come up with a better solution. // (note: seems to affect some Phenom II's only? -- Athlon X2's and PhenomI's do @@ -167,9 +147,6 @@ void x86capabilities::CountCores() hasMultiThreading = 0; } - if( !hasMultiThreading || LogicalCoresPerPhysicalCPU == 0 ) - LogicalCoresPerPhysicalCPU = 1; - // This will assign values into LogicalCores and PhysicalCores CountLogicalCores(); } diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index eb3dd07a3a..17f7341277 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -201,30 +201,37 @@ TraceLogFilters& SetTraceConfig() // This function should be called once during program execution. void SysLogMachineCaps() { - Console.WriteLn( Color_StrongGreen, "PCSX2 %u.%u.%u.r%d %s - compiled on " __DATE__, PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, + Console.WriteLn( Color_StrongGreen, "PCSX2 %u.%u.%u.r%d %s - compiled on " __DATE__, + PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo, SVN_REV, SVN_MODS ? "(modded)" : "" ); Console.WriteLn( "Savestate version: 0x%x", g_SaveVersion); Console.Newline(); - Console.WriteLn( Color_StrongBlack, "x86-32 Init:" ); + Console.WriteLn( Color_StrongBlack, "Host Machine Init:" ); + + Console.Indent().WriteLn( + L"Operating System = %s\n" + L"Physical RAM = %u MB", + + GetOSVersionString().c_str(), + (u32)(GetPhysicalMemory() / _1mb) + ); u32 speed = x86caps.CalculateMHz(); Console.Indent().WriteLn( - L"CPU vendor name = %s\n" - L"FamilyID = %x\n" - L"x86Family = %s\n" - L"CPU speed = %d.%03d ghz\n" - L"Cores = %d physical [%d logical]\n" + L"CPU name = %s\n" + L"Vendor/Model = %s - stepping=%02X\n" + L"CPU speed = %u.%03u ghz (%u logical thread%s)\n" L"x86PType = %s\n" - L"x86Flags = %8.8x %8.8x\n" - L"x86EFlags = %8.8x", - fromUTF8( x86caps.VendorName ).c_str(), x86caps.StepID, + L"x86Flags = %08x %08x\n" + L"x86EFlags = %08x", fromUTF8( x86caps.FamilyName ).Trim().Trim(false).c_str(), + fromUTF8( x86caps.VendorName ).c_str(), x86caps.StepID, speed / 1000, speed % 1000, - x86caps.PhysicalCores, x86caps.LogicalCores, + x86caps.LogicalCores, (x86caps.LogicalCores==1) ? L"" : L"s", x86caps.GetTypeName().c_str(), x86caps.Flags, x86caps.Flags2, x86caps.EFlags