Skip to content

Commit f216569

Browse files
Never use --map-by core when multiple threads are used. (#102)
* Never used `--map-by core` when multiple threads are used. * Added comments for the map-by core/slot fix. * Updated mpirun distribution handling. * Made pylint happy.
1 parent b73c2bb commit f216569

2 files changed

Lines changed: 21 additions & 18 deletions

File tree

ifsbench/launch/mpirunlauncher.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MpirunLauncher(Launcher):
3434
}
3535

3636
_distribution_options_map = {
37-
CpuDistribution.DISTRIBUTE_BLOCK: 'core',
37+
CpuDistribution.DISTRIBUTE_BLOCK: 'slot',
3838
CpuDistribution.DISTRIBUTE_CYCLIC: 'numa',
3939
}
4040

@@ -45,27 +45,22 @@ def _get_distribution_options(self, job: Job) -> List[str]:
4545
CpuDistribution.DISTRIBUTE_USER,
4646
None,
4747
]
48-
if hasattr(job, 'distribute_remote') and job.distribute_remote not in do_nothing:
49-
warning('Specified remote distribution option ignored in MpirunLauncher')
5048

51-
# By default use core mapping. At least that's the default in the
52-
# OpenMPI implementation
53-
# (https://docs.open-mpi.org/en/main/man-openmpi/man1/mpirun.1.html#label-schizo-ompi-map-by).
54-
map_by = 'core'
49+
# Ignore remote distribution options. Mpirun doesn't distinguish
50+
# between local/remote distribution as far as I know.
51+
if job.distribute_remote is not None:
52+
warning('Distribute_remote options is ignored in MpirunLauncher')
5553

5654
if job.distribute_local and job.distribute_local not in do_nothing:
57-
map_by = self._distribution_options_map[job.distribute_local]
58-
elif job.cpus_per_task is None:
59-
# If no local distribution must be set and the number of threads
60-
# isn't specified, we don't have to add any flags.
61-
return []
55+
# Use map-by to control the distribution. If threads are used, we
56+
# also have to set the PE:number-of-threads option.
6257

63-
# If multithreading is used, we have to specify the number of threads
64-
# per process in the map_by statement.
65-
if job.cpus_per_task:
66-
return ['--map-by', f'{map_by}:PE={job.cpus_per_task}']
58+
map_by = self._distribution_options_map[job.distribute_local]
59+
if job.cpus_per_task:
60+
return ['--map-by', f'{map_by}:PE={job.cpus_per_task}']
61+
return ['--map-by', f'{map_by}']
6762

68-
return ['--map-by', f'{map_by}']
63+
return []
6964

7065
def prepare(
7166
self,

ifsbench/launch/tests/test_mpirunlauncher.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,15 @@ def test_mpirunLauncher_prepare_run_dir(
123123
[],
124124
'test_env_none',
125125
[],
126-
['mpirun', '-n', '64', '--map-by', 'core:PE=4', 'ls', '-l'],
126+
['mpirun', '-n', '64', 'ls', '-l'],
127+
),
128+
(
129+
['ls', '-l'],
130+
{'tasks': 64, 'cpus_per_task': 4, 'distribute_local': CpuDistribution.DISTRIBUTE_BLOCK},
131+
[],
132+
'test_env_none',
133+
[],
134+
['mpirun', '-n', '64', '--map-by', 'slot:PE=4', 'ls', '-l'],
127135
),
128136
(
129137
['something'],

0 commit comments

Comments
 (0)