def testHyperThread(self): prof = SystemProfiler() prof.physicalCpus = 8 prof.logicalCpus = 16 # hyperthreading enabled but not max procs prof.hyperthread_factor = 2 _, opts = prof.getSubprocessOpts([], cpus=range(3)) env = opts['env'] self.assertEqual(env['PLOW_CORES'], '3') if IS_LINUX: self.assertEqual(env['PLOW_THREADS'], '6', 'on Linux, HT should be enabled here') else: self.assertEqual(env['PLOW_THREADS'], '3', 'on non-Linux, HT should be disabled here') # pretend we want to run with 2 cores w/o HT prof.hyperthread_factor = 1 _, opts = prof.getSubprocessOpts([], cpus=range(2)) env = opts['env'] self.assertEqual(env['PLOW_CORES'], '2') self.assertEqual(env['PLOW_THREADS'], '2') # hyperthreading enabled and max procs prof.hyperthread_factor = 2 _, opts = prof.getSubprocessOpts([], cpus=range(prof.physicalCpus)) env = opts['env'] self.assertEqual(env['PLOW_CORES'], '8') self.assertEqual(env['PLOW_THREADS'], '16')