I tried setting the config variable but that didn’t seem to work. And searching the code for ‘affinity’ didn’t seem to indicate it was being used. But that did point me to the TrueClock class which I was able to use to set the affinity manually.
So adding the following after my panda imports appears to have fixed my problem.
from panda3d.core import TrueClock
TrueClock.getGlobalPtr().setCpuAffinity(0xFFFFFFFF)
Note that setCpuAffinity gets called for every process I start up.
These values should be -1, false, -1, and false, respectively, to avoid setting any initial affinity mask. If they are not these values, where are they coming from? If they are these values, I don’t understand where the initial affinity mask is being set.
lock-to-one-cpu is True for me. Setting that to false in the prc file fixes the issue and now I don’t have to set the affinity manually anymore. Thanks!
Could this be the culprit, in trueClock.cxx:169?
ConfigVariableBool lock_to_one_cpu
("lock-to-one-cpu", false,
PRC_DESC("Set this to true if you want the entire process to use one "
"CPU, even on multi-core and multi-CPU workstations. This is "
"mainly a hack to solve a bug in which QueryPerformanceCounter "
"returns inconsistent results on multi-core machines. "));
if (lock_to_one_cpu) {
set_cpu_affinity(0x01);
}
My c++ is rusty so I’m not sure if the compiler will use some sort of operator overload to cast ‘lock_to_one_cpu’ to an int or bool. If not maybe a get member needs to be called?
No, that’s the way bool config variables work in C++. It must be explicitly set True in some config file. It should tell you which file this is when you print the config variable using:
print ConfigVariableBool('lock-to-one-cpu')
What does it say? Maybe we’re leaving this set in the default Config.prc that ships with Panda.