mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-18 13:21:40 +00:00
Changed: Allow to specify CPUMask in client.cfg to force the use of some cores
This commit is contained in:
parent
5babd2a315
commit
2e09265c55
2 changed files with 82 additions and 59 deletions
|
@ -254,6 +254,43 @@ extern NL3D::UDriver *Driver;
|
||||||
extern CRyzomTime RT;
|
extern CRyzomTime RT;
|
||||||
extern string Cookie;
|
extern string Cookie;
|
||||||
extern string FSAddr;
|
extern string FSAddr;
|
||||||
|
|
||||||
|
extern uint64 Debug_OldCPUMask;
|
||||||
|
extern uint64 Debug_NewCPUMask;
|
||||||
|
|
||||||
|
// For multi cpu, active only one CPU for the main thread
|
||||||
|
void setCPUMask(uint64 userCPUMask)
|
||||||
|
{
|
||||||
|
uint64 cpuMask = IProcess::getCurrentProcess()->getCPUMask();
|
||||||
|
Debug_OldCPUMask = cpuMask;
|
||||||
|
|
||||||
|
// if user CPU mask is valid
|
||||||
|
if (cpuMask & userCPUMask)
|
||||||
|
{
|
||||||
|
// use it
|
||||||
|
IProcess::getCurrentProcess ()->setCPUMask(cpuMask & userCPUMask);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// else get first available CPU
|
||||||
|
|
||||||
|
// get the processor to allow process
|
||||||
|
uint i = 0;
|
||||||
|
while ((i < 64) && ((cpuMask & (UINT64_CONSTANT(1) << i)) == 0))
|
||||||
|
i++;
|
||||||
|
|
||||||
|
// Set the CPU mask
|
||||||
|
if (i < 64)
|
||||||
|
{
|
||||||
|
IProcess::getCurrentProcess ()->setCPUMask(UINT64_CONSTANT(1) << i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check
|
||||||
|
cpuMask = IProcess::getCurrentProcess ()->getCPUMask();
|
||||||
|
Debug_NewCPUMask = cpuMask;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
|
@ -1673,6 +1710,22 @@ void CClientConfig::setValues()
|
||||||
SetPriorityClass (GetCurrentProcess(), priority[index]);
|
SetPriorityClass (GetCurrentProcess(), priority[index]);
|
||||||
#endif // NL_OS_WINDOWS
|
#endif // NL_OS_WINDOWS
|
||||||
|
|
||||||
|
sint cpuMask;
|
||||||
|
|
||||||
|
if (ClientCfg.CPUMask < 1)
|
||||||
|
{
|
||||||
|
CTime::CTimerInfo timerInfo;
|
||||||
|
NLMISC::CTime::probeTimerInfo(timerInfo);
|
||||||
|
|
||||||
|
cpuMask = timerInfo.RequiresSingleCore ? 1:0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cpuMask = ClientCfg.CPUMask;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cpuMask) setCPUMask(cpuMask);
|
||||||
|
|
||||||
// Init Verbose Modes (at the beginning to be able to display them as soon as possible).
|
// Init Verbose Modes (at the beginning to be able to display them as soon as possible).
|
||||||
::VerboseVP = ClientCfg.VerboseVP;
|
::VerboseVP = ClientCfg.VerboseVP;
|
||||||
::VerboseAnimUser = ClientCfg.VerboseAnimUser;
|
::VerboseAnimUser = ClientCfg.VerboseAnimUser;
|
||||||
|
|
|
@ -374,30 +374,8 @@ void outOfMemory()
|
||||||
nlstopex (("OUT OF MEMORY"));
|
nlstopex (("OUT OF MEMORY"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For multi cpu, active only one CPU for the main thread
|
uint64 Debug_OldCPUMask = 0;
|
||||||
uint64 Debug_OldCPUMask= 0;
|
uint64 Debug_NewCPUMask = 0;
|
||||||
uint64 Debug_NewCPUMask= 0;
|
|
||||||
void setCPUMask ()
|
|
||||||
{
|
|
||||||
uint64 cpuMask = IProcess::getCurrentProcess ()->getCPUMask();
|
|
||||||
Debug_OldCPUMask= cpuMask;
|
|
||||||
|
|
||||||
// get the processor to allow process
|
|
||||||
uint i = 0;
|
|
||||||
while ((i<64) && ((cpuMask&(SINT64_CONSTANT(1)<<i)) == 0))
|
|
||||||
i++;
|
|
||||||
|
|
||||||
// Set the CPU mask
|
|
||||||
if (i<64)
|
|
||||||
{
|
|
||||||
IProcess::getCurrentProcess ()->setCPUMask(1<<i);
|
|
||||||
//IThread::getCurrentThread ()->setCPUMask (1<<i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check
|
|
||||||
cpuMask = IProcess::getCurrentProcess ()->getCPUMask();
|
|
||||||
Debug_NewCPUMask= cpuMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
void displayCPUInfo()
|
void displayCPUInfo()
|
||||||
{
|
{
|
||||||
|
@ -791,14 +769,25 @@ void prelogInit()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
H_AUTO ( RZ_Client_Init );
|
||||||
|
|
||||||
// Assert if no more memory
|
// Assert if no more memory
|
||||||
// NLMEMORY::SetOutOfMemoryHook(outOfMemory);
|
set_new_handler(outOfMemory);
|
||||||
|
|
||||||
|
NLMISC_REGISTER_CLASS(CStage);
|
||||||
|
NLMISC_REGISTER_CLASS(CStageSet);
|
||||||
|
NLMISC_REGISTER_CLASS(CEntityManager);
|
||||||
|
NLMISC_REGISTER_CLASS(CCharacterCL);
|
||||||
|
NLMISC_REGISTER_CLASS(CPlayerCL);
|
||||||
|
NLMISC_REGISTER_CLASS(CUserEntity);
|
||||||
|
NLMISC_REGISTER_CLASS(CFxCL);
|
||||||
|
NLMISC_REGISTER_CLASS(CItemCL);
|
||||||
|
NLMISC_REGISTER_CLASS(CNamedEntityPositionState);
|
||||||
|
NLMISC_REGISTER_CLASS(CAnimalPositionState);
|
||||||
|
|
||||||
// Progress bar for init() and connection()
|
// Progress bar for init() and connection()
|
||||||
ProgressBar.reset (BAR_STEP_INIT_CONNECTION);
|
ProgressBar.reset (BAR_STEP_INIT_CONNECTION);
|
||||||
|
|
||||||
set_new_handler(outOfMemory);
|
|
||||||
|
|
||||||
// save screen saver state and disable it
|
// save screen saver state and disable it
|
||||||
LastScreenSaverEnabled = CSystemUtils::isScreensaverEnabled();
|
LastScreenSaverEnabled = CSystemUtils::isScreensaverEnabled();
|
||||||
|
|
||||||
|
@ -813,37 +802,16 @@ void prelogInit()
|
||||||
_control87 (_EM_INVALID|_EM_DENORMAL/*|_EM_ZERODIVIDE|_EM_OVERFLOW*/|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM);
|
_control87 (_EM_INVALID|_EM_DENORMAL/*|_EM_ZERODIVIDE|_EM_OVERFLOW*/|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM);
|
||||||
#endif // NL_OS_WINDOWS
|
#endif // NL_OS_WINDOWS
|
||||||
|
|
||||||
CTime::CTimerInfo timerInfo;
|
|
||||||
NLMISC::CTime::probeTimerInfo(timerInfo);
|
|
||||||
if (timerInfo.RequiresSingleCore) // TODO: Also have a FV configuration value to force single core.
|
|
||||||
setCPUMask();
|
|
||||||
|
|
||||||
FPU_CHECKER_ONCE
|
FPU_CHECKER_ONCE
|
||||||
|
|
||||||
NLMISC::TTime initStart = ryzomGetLocalTime ();
|
NLMISC::TTime initStart = ryzomGetLocalTime ();
|
||||||
|
|
||||||
H_AUTO ( RZ_Client_Init );
|
|
||||||
|
|
||||||
NLMISC_REGISTER_CLASS(CStage);
|
|
||||||
NLMISC_REGISTER_CLASS(CStageSet);
|
|
||||||
NLMISC_REGISTER_CLASS(CEntityManager);
|
|
||||||
NLMISC_REGISTER_CLASS(CCharacterCL);
|
|
||||||
NLMISC_REGISTER_CLASS(CPlayerCL);
|
|
||||||
NLMISC_REGISTER_CLASS(CUserEntity);
|
|
||||||
NLMISC_REGISTER_CLASS(CFxCL);
|
|
||||||
NLMISC_REGISTER_CLASS(CItemCL);
|
|
||||||
NLMISC_REGISTER_CLASS(CNamedEntityPositionState);
|
|
||||||
NLMISC_REGISTER_CLASS(CAnimalPositionState);
|
|
||||||
|
|
||||||
// _CrtSetDbgFlag( _CRTDBG_CHECK_CRT_DF );
|
// _CrtSetDbgFlag( _CRTDBG_CHECK_CRT_DF );
|
||||||
|
|
||||||
// Init XML Lib allocator
|
// Init XML Lib allocator
|
||||||
// Due to Bug #906, we disable the stl xml allocation
|
// Due to Bug #906, we disable the stl xml allocation
|
||||||
// nlverify (xmlMemSetup (XmlFree4NeL, XmlMalloc4NeL, XmlRealloc4NeL, XmlStrdup4NeL) == 0);
|
// nlverify (xmlMemSetup (XmlFree4NeL, XmlMalloc4NeL, XmlRealloc4NeL, XmlStrdup4NeL) == 0);
|
||||||
|
|
||||||
// Init the debug memory
|
|
||||||
initDebugMemory();
|
|
||||||
|
|
||||||
// Add a displayer for Debug Infos.
|
// Add a displayer for Debug Infos.
|
||||||
createDebug();
|
createDebug();
|
||||||
|
|
||||||
|
@ -856,14 +824,24 @@ void prelogInit()
|
||||||
ErrorLog->addDisplayer (ClientLogDisplayer);
|
ErrorLog->addDisplayer (ClientLogDisplayer);
|
||||||
AssertLog->addDisplayer (ClientLogDisplayer);
|
AssertLog->addDisplayer (ClientLogDisplayer);
|
||||||
|
|
||||||
|
// Display the client version.
|
||||||
|
nlinfo("RYZOM VERSION : %s", getDebugVersion().c_str());
|
||||||
|
|
||||||
|
// Init the debug memory
|
||||||
|
initDebugMemory();
|
||||||
|
|
||||||
|
// Load the application configuration.
|
||||||
|
ucstring nmsg("Loading config file...");
|
||||||
|
ProgressBar.newMessage (nmsg);
|
||||||
|
|
||||||
|
ClientCfg.init(ConfigFileName);
|
||||||
|
CLoginProgressPostThread::getInstance().init(ClientCfg.ConfigFile);
|
||||||
|
|
||||||
setCrashCallback(crashCallback);
|
setCrashCallback(crashCallback);
|
||||||
|
|
||||||
// Display Some Info On CPU
|
// Display Some Info On CPU
|
||||||
displayCPUInfo();
|
displayCPUInfo();
|
||||||
|
|
||||||
// Display the client version.
|
|
||||||
nlinfo("RYZOM VERSION : %s", getDebugVersion().c_str());
|
|
||||||
|
|
||||||
FPU_CHECKER_ONCE
|
FPU_CHECKER_ONCE
|
||||||
|
|
||||||
// Set default email value for reporting error
|
// Set default email value for reporting error
|
||||||
|
@ -881,14 +859,6 @@ void prelogInit()
|
||||||
//ICommand::execute("iFileAccessLogStart",*NLMISC::InfoLog);
|
//ICommand::execute("iFileAccessLogStart",*NLMISC::InfoLog);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Load the application configuration.
|
|
||||||
ucstring nmsg("Loading config file...");
|
|
||||||
ProgressBar.newMessage (nmsg);
|
|
||||||
|
|
||||||
ClientCfg.init(ConfigFileName);
|
|
||||||
|
|
||||||
CLoginProgressPostThread::getInstance().init(ClientCfg.ConfigFile);
|
|
||||||
|
|
||||||
// check "BuildName" in ClientCfg
|
// check "BuildName" in ClientCfg
|
||||||
//nlassert(!ClientCfg.BuildName.empty()); // TMP comment by nico do not commit
|
//nlassert(!ClientCfg.BuildName.empty()); // TMP comment by nico do not commit
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue