def test_affinity_3(self): launcher = XeonAffinityLauncher(['--geopm-ctl', 'application'], 2, 1, 4) actual = launcher.affinity_list(False) expect = [{21, 20, 19, 18}, {43, 42, 41, 40}] self.assertEqual(expect, actual) actual = launcher.affinity_list(True) expect = [{1}] self.assertEqual(expect, actual)
def test_affinity_3(self): launcher = XeonAffinityLauncher(['--geopm-ctl', 'application'], 2, 1, 4) actual = launcher.affinity_list(False) expect = [{2, 3, 4, 5}, {6, 7, 8, 9}] self.assertEqual(expect, actual) actual = launcher.affinity_list(True) expect = [{1}] self.assertEqual(expect, actual)
def check_application_mode(self, geopm_cpus, app_cpus, launch_args): args = launch_args.copy() self.application_argv += args.pop('add_args', []) launcher = TestAffinityLauncher(self.application_argv, **args) actual = launcher.affinity_list(True) expect = [geopm_cpus] self.assertEqual(expect, actual) actual = launcher.affinity_list(False) expect = app_cpus self.assertEqual(expect, actual)
def test_affinity_15(self): """ When the application requests all the physical cores we would normally pin the controller to core 0's HT. Since mpibind does not support HT pinning, oversubscribe core 0. """ launcher = QuartzAffinityLauncher(['--geopm-ctl', 'application'], 1, 1, 36) actual = launcher.affinity_list(False) expect = [set(range(0, 36))] self.assertEqual(expect, actual) actual = launcher.affinity_list(True) expect = [{0}] self.assertEqual(expect, actual)
def test_affinity_16(self): """ Similar to test 14, this attempts to utilize 35 execution units (5 ranks * 7 OMP threads). Core 0 should be used for the OS and controller. """ launcher = QuartzAffinityLauncher(['--geopm-ctl', 'application'], 5, 1, 7) actual = launcher.affinity_list(False) expect = [{1, 2, 3, 4, 5, 6, 7}, {8, 9, 10, 11, 12, 13, 14}, {15, 16, 17, 18, 19, 20, 21}, {22, 23, 24, 25, 26, 27, 28}, {29, 30, 31, 32, 33, 34, 35}] self.assertEqual(expect, actual) actual = launcher.affinity_list(True) expect = [{0}] self.assertEqual(expect, actual)
def test_affinity_17(self): """ Similar to test 14, this attempts to utilize 35 execution units (7 ranks * 5 OMP threads). Core 0 should be used for the OS and controller. """ launcher = QuartzAffinityLauncher(['--geopm-ctl', 'application'], 7, 1, 5) actual = launcher.affinity_list(False) expect = [{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20}, {21, 22, 23, 24, 25}, {26, 27, 28, 29, 30}, {31, 32, 33, 34, 35}] self.assertEqual(expect, actual) actual = launcher.affinity_list(True) expect = [{0}] self.assertEqual(expect, actual)
def test_affinity_14(self): """ The mpibind plugin used on TOSS based systems does not yet support pinning to HTs. When an app requests num_sockets * num_cores - 1 OMP threads the controller should be pinned to core 0 meaning it is shared with the OS. """ launcher = QuartzAffinityLauncher(['--geopm-ctl', 'application'], 1, 1, 35) actual = launcher.affinity_list(False) expect = [set(range(1, 36))] self.assertEqual(expect, actual) actual = launcher.affinity_list(True) expect = [{0}] self.assertEqual(expect, actual)
def test_affinity_8(self): launcher = XeonAffinityLauncher(['--geopm-ctl', 'process'], 30, 1, 2) actual = launcher.affinity_list(False) expect = [{1}] expect.extend([{ii, ii + 44} for ii in range(7, 22)]) expect.extend([{ii, ii + 44} for ii in range(29, 44)]) self.assertEqual(expect, actual)
def test_affinity_8(self): launcher = XeonAffinityLauncher(['--geopm-ctl', 'process'], 30, 1, 2) actual = launcher.affinity_list(False) expect = [{1}] expect.extend([{ii, ii + 44} for ii in range(2, 17)]) expect.extend([{ii, ii + 44} for ii in range(22, 37)]) self.assertEqual(expect, actual)
def check_pthread_mode(self, geopm_cpus, app_cpus, launch_args): args = launch_args.copy() self.pthread_argv += args.pop('add_args', []) launcher = TestAffinityLauncher(self.pthread_argv, **args) actual = launcher.affinity_list(False) expect = [geopm_cpus | app_cpus[0]] + app_cpus[1:] self.assertEqual(expect, actual)
def test_affinity_tutorial_knl(self): launcher = KNLAffinityLauncher(['--geopm-ctl', 'process'], 8, 2, 63) actual = launcher.affinity_list(False) expect = [{ jj + 16 * kk for ii in range(4) for jj in range(ii * 64, ii * 64 + 16) } for kk in range(4)] expect.insert(0, {0}) self.assertEqual(expect, actual)
def test_affinity_tutorial_knl(self): launcher = KNLAffinityLauncher(['--geopm-ctl', 'process'], 8, 2, 63) actual = launcher.affinity_list(False) expect = [{jj + 16 * kk for ii in range(4) for jj in range(ii * 64, ii * 64 + 16)} for kk in range(4)] expect.insert(0, {0}) self.assertEqual(expect, actual)
def test_affinity_13(self): """ Here the app is trying to use num_sockets * num_cores - 1 OMP threads. This should result in the controller getting pinned to core 0's HT, and the app pinned to cores 1-43. Core 0 should be left for the OS. """ launcher = XeonAffinityLauncher(['--geopm-ctl', 'process'], 1, 1, 43) actual = launcher.affinity_list(False) expect = [{44}] expect.extend([set(range(1, 44))]) self.assertEqual(expect, actual)
def test_affinity_18(self): """ Tests trying to use hyperthreads when hyperthreading is disabled. """ topo = self.quartz_topo launch_args = { 'topo': topo, 'num_rank': 1, 'num_node': 1, 'cpu_per_rank': 40, } add_args = ['--geopm-hyperthreads-disable'] launcher = TestAffinityLauncher(self.process_argv + add_args, **launch_args) err_msg = 'Hyperthreads needed to satisfy ranks/threads configuration, but forbidden by'\ ' --geopm-hyperthreads-disable.' with self.assertRaisesRegexp(RuntimeError, err_msg): launcher.affinity_list(False) launcher = TestAffinityLauncher(self.pthread_argv + add_args, **launch_args) err_msg = 'Hyperthreads needed to satisfy ranks/threads configuration, but forbidden by'\ ' --geopm-hyperthreads-disable.' with self.assertRaisesRegexp(RuntimeError, err_msg): launcher.affinity_list(False) launcher = TestAffinityLauncher(self.application_argv + add_args, **launch_args) err_msg = 'Hyperthreads needed to satisfy ranks/threads configuration, but forbidden by'\ ' --geopm-hyperthreads-disable.' with self.assertRaisesRegexp(RuntimeError, err_msg): launcher.affinity_list(False)
def test_affinity_12(self): ''' Tests that an error is printed when the number of ranks is greater than the number of cores. ''' topo = self.knl_topo launch_args = { 'topo': topo, 'num_rank': 51, 'num_node': 1, 'cpu_per_rank': 5, } launcher = TestAffinityLauncher(self.process_argv, **launch_args) err_msg = 'Cores cannot be shared between MPI ranks' with self.assertRaisesRegexp(RuntimeError, err_msg): launcher.affinity_list(False) launcher = TestAffinityLauncher(self.pthread_argv, **launch_args) err_msg = 'Cores cannot be shared between MPI ranks' with self.assertRaisesRegexp(RuntimeError, err_msg): launcher.affinity_list(False) launcher = TestAffinityLauncher(self.application_argv, **launch_args) err_msg = 'Cores cannot be shared between MPI ranks' with self.assertRaisesRegexp(RuntimeError, err_msg): launcher.affinity_list(False)
def test_affinity_2(self): launcher = XeonAffinityLauncher(['--geopm-ctl', 'pthread'], 2, 1, 4) actual = launcher.affinity_list(False) expect = [{1, 21, 20, 19, 18}, {43, 42, 41, 40}] self.assertEqual(expect, actual)
def test_affinity_18(self): launcher = QuartzAffinityLauncher(['--geopm-ctl', 'process'], 1, 1, 40) err_msg = 'Hyperthreads needed to satisfy ranks/threads configuration, but forbidden by'\ ' --geopm-disable-hyperthreads.' with self.assertRaisesRegexp(RuntimeError, err_msg) as cm: launcher.affinity_list(False)
def test_affinity_1(self): launcher = XeonAffinityLauncher(['--geopm-ctl', 'process'], 2, 1, 4) actual = launcher.affinity_list(False) expect = [{1}, {2, 3, 4, 5}, {6, 7, 8, 9}] self.assertEqual(expect, actual)
def test_affinity_0(self): launcher = XeonAffinityLauncher(['--geopm-ctl', 'process'], 1, 1, 1) actual = launcher.affinity_list(False) expect = [{1}, {2}] self.assertEqual(expect, actual)
def test_affinity_12(self): launcher = KNLAffinityLauncher(['--geopm-ctl', 'process'], 51, 1, 5) err_msg = 'Cores cannot be shared between MPI ranks' with self.assertRaisesRegexp(RuntimeError, err_msg) as cm: launcher.affinity_list(False)
def test_affinity_11(self): launcher = KNLAffinityLauncher(['--geopm-ctl', 'process'], 48, 1, 3) actual = launcher.affinity_list(False) expect = [{1}] expect.extend([{ii, ii + 64, ii + 128} for ii in range(2, 50)]) self.assertEqual(expect, actual)
def test_affinity_4(self): launcher = XeonAffinityLauncher(['--geopm-ctl', 'process'], 44, 1, 1) actual = launcher.affinity_list(False) expect = [{44}] expect.extend([{ii} for ii in range(44)]) self.assertEqual(expect, actual)
def test_affinity_0(self): launcher = XeonAffinityLauncher(['--geopm-ctl', 'process'], 1, 1, 1) actual = launcher.affinity_list(False) expect = [{1}, {43}] self.assertEqual(expect, actual)
def test_affinity_11(self): launcher = KNLAffinityLauncher(['--geopm-ctl', 'process'], 48, 1, 3) actual = launcher.affinity_list(False) expect = [{1}] expect.extend([{ii, ii + 64, ii + 128} for ii in range(16, 64)]) self.assertEqual(expect, actual)
def test_affinity_9(self): launcher = KNLAffinityLauncher(['--geopm-ctl', 'process'], 64, 1, 4) actual = launcher.affinity_list(False) expect = [{0}] expect.extend([{ii, ii + 64, ii + 128, ii + 192} for ii in range(64)]) self.assertEqual(expect, actual)
def test_affinity_6(self): launcher = ToyAffinityLauncher(['--geopm-ctl', 'process'], 8, 1, 2) actual = launcher.affinity_list(False) expect = [{0}] expect.extend([{ii, ii + 8} for ii in range(8)]) self.assertEqual(expect, actual)