You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Set OMP_NUM_THREADS explicitly to 1 in pure MPI runs such as OSU #321
Distilling down my thoughts further, this only happens with OSU because num_cpus_per_task is required to request a full node if run at a scale of 1_node or 2_nodes because full nodes are requested and these requests are valid for a systems where partial requests are allowed and one wants to allocate full nodes to avoid "noise" due to other running jobs.
def set_compact_process_binding(test: rfm.RegressionTest):
"""
This hook sets a binding policy for process binding.
More specifically, it will bind each process to subsequent domains of test.num_cpus_per_task cores.
Arguments:
- test: the ReFrame test to which this hook should apply
A few examples:
- Pure MPI (test.num_cpus_per_task = 1) will result in binding 1 process to each core.
this will happen in a compact way, i.e. rank 0 to core 0, rank 1 to core 1, etc
- Hybrid MPI-OpenMP, e.g. test.num_cpus_per_task = 4 will result in binding 1 process to subsequent sets of 4 cores.
I.e. rank 0 to core 0-3, rank 1 to core 4-7, rank 2 to core 8-11, etc
It is hard to do this in a portable way. Currently supported for process binding are:
- Intel MPI (through I_MPI_PIN_DOMAIN)
- OpenMPI (through cmdline option --map-by slot:PE=x)
- srun (LIMITED SUPPORT: through SLURM_CPU_BIND, but only effective if task/affinity plugin is enabled)
"""
# Check if hyperthreading is enabled. If so, divide the number of cpus per task by the number
# of hw threads per core to get a physical core count
# TODO: check if this also leads to sensible binding when using COMPUTE_UNITS.HWTHREAD
check_proc_attribute_defined(test, 'num_cpus_per_core')
num_cpus_per_core = test.current_partition.processor.num_cpus_per_core
physical_cpus_per_task = int(test.num_cpus_per_task / num_cpus_per_core)
if test.current_partition.launcher_type().registered_name == 'mpirun':
# Do binding for intel and OpenMPI's mpirun, and srun
env_vars = {
'I_MPI_PIN_CELL': 'core', # Don't bind to hyperthreads, only to physcial cores
'I_MPI_PIN_DOMAIN': f'{physical_cpus_per_task}:compact',
'I_MPI_DEBUG': '4',
}
ompi_patterns = [
r'.+/.+-gompi-', r'^gompi/',
r'.+/.+-foss-', r'^foss/',
r'.+/.+-gomkl-', r'^gomkl/',
r'.+/.+-iomkl-', r'^iomkl/',
r'.+/.+-lompi-', r'^lompi/',
r'.+/.+-lfoss-', r'^lfoss/',
r'^OpenMPI/']
pattern = "|".join(ompi_patterns)
if any(re.search(pattern, x) for x in test.modules):
test.job.launcher.options.append(f'--map-by slot:PE={physical_cpus_per_task} --report-bindings')
log(f'Set launcher command to {test.job.launcher.run_command(test.job)}')
num_cpus_per_task gets calculated and assigned here (see the code block below) which is needed for the full node to be assigned since this is a pure MPI run, it does not need to use these CPUs.
def _assign_num_tasks_per_node(test: rfm.RegressionTest, num_per: int = 1):
"""
Sets num_tasks_per_node and num_cpus_per_task such that it will run
'num_per' tasks per node, unless specified with:
--setvar num_tasks_per_node=<x>
--setvar num_cpus_per_task=<y>.
In those cases, those take precedence, and the remaining variable, if any
(num_cpus_per task or num_tasks_per_node respectively), is calculated based
on the equality test.num_tasks_per_node * test.num_cpus_per_task ==
test.default_num_cpus_per_node.
Default resources requested:
- num_tasks_per_node = num_per
- num_cpus_per_task = test.default_num_cpus_per_node / num_tasks_per_node
"""
# neither num_tasks_per_node nor num_cpus_per_task are set
if not test.num_tasks_per_node and not test.num_cpus_per_task:
test.num_tasks_per_node = num_per
test.num_cpus_per_task = int(test.default_num_cpus_per_node / test.num_tasks_per_node)
Therefore, to resolve this issue, there should be an override variable (just like num_per above) which gets defined in the test for number of threads being used in the job, defined by OMP_NUM_THREADS and also gets assigned to slot:PE= because these two represent the actual threads being used per task. If not defined in the test, then the default should be used.
Therefore, to resolve this issue, there should be an override variable (just like num_per above) which gets defined in the test for number of threads being used in the job, defined by OMP_NUM_THREADS and also gets assigned to slot:PE= because these two represent the actual threads being used per task. If not defined in the test, then the default should be used.
yes, we can add support for this, can also be useful for other tests in the future.
EDIT: i solved in #322 by introducing used_cpus_per_task parameter.
Activity
satishskamath commentedon Feb 12, 2026
Distilling down my thoughts further, this only happens with OSU because
num_cpus_per_taskis required to request a full node if run at a scale of1_nodeor2_nodesbecause full nodes are requested and these requests are valid for a systems where partial requests are allowed and one wants to allocate full nodes to avoid "noise" due to other running jobs.num_cpus_per_taskgets calculated and assigned here (see the code block below) which is needed for the full node to be assigned since this is a pure MPI run, it does not need to use these CPUs.Therefore, to resolve this issue, there should be an override variable (just like
num_perabove) which gets defined in the test for number of threads being used in the job, defined by OMP_NUM_THREADS and also gets assigned toslot:PE=because these two represent the actual threads being used per task. If not defined in the test, then the default should be used.satishskamath commentedon Feb 12, 2026
Any thoughts @smoors @casparvl @laraPPr ?
smoors commentedon Feb 13, 2026
yes, we can add support for this, can also be useful for other tests in the future.
EDIT: i solved in #322 by introducing
used_cpus_per_taskparameter.