Workaround a problem with thread affinities.

Should fix some slowness issues, mainly on AMD cpus.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1614 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
ramapcsx2 2009-08-09 18:38:10 +00:00
parent c0a0cd6bed
commit 62cc3cfbf3
1 changed files with 17 additions and 0 deletions

View File

@ -216,6 +216,19 @@ static void SetSingleAffinity()
#endif
}
static void UnSetSingleAffinity()
{
#ifdef _WINDOWS_
HANDLE s_threadId = GetCurrentThread();
s_oldmask = SetThreadAffinityMask( s_threadId, 0xFFFFFFFF );
if( s_oldmask == ERROR_INVALID_PARAMETER )
{
Console::Notice("CpuDetect: UnSetThreadAffinityMask failed...");
}
#endif
}
//////////////////////////////////////////////////////////////////////////////////////////
//
s64 CPUSpeedHz( u64 time )
@ -489,5 +502,9 @@ void cpudetectInit()
// This will assign values into cpuinfo.LogicalCores and PhysicalCores
Threading::CountLogicalCores( LogicalCoresPerPhysicalCPU, PhysicalCoresPerPhysicalCPU );
// Undo previous SetSingleAffinity() here, so the host OS can handle load distribution
// (up to 25% faster on athlonx2, about 5% faster on core2)
UnSetSingleAffinity();
}