@@ -58,7 +58,7 @@ arch_is_def_cpu=1 # arch has been set for CPU default only.
58
58
59
59
# Default nodes.
60
60
nnodes=1
61
- if [[ ! -z ${ SLURM_NNODES: +x} ]]; then
61
+ if [[ -n " $ SLURM_NNODES" ]]; then
62
62
nnodes=$SLURM_NNODES
63
63
fi
64
64
@@ -74,25 +74,24 @@ elif command -v nvidia-smi >/dev/null; then
74
74
fi
75
75
is_offload=0
76
76
77
- # Default MPI ranks.
78
- # Try Slurm var, then numactl, then lscpu.
79
- # For latter two, the goal is to count only NUMA nodes with CPUs.
77
+ # Get NUMA nodes.
78
+ # The goal is to count only NUMA nodes with CPUs.
80
79
# (Systems with HBM may have NUMA nodes without CPUs.)
80
+ if command -v numactl > /dev/null; then
81
+ nnumas=` numactl -s | awk ' /^cpubind:/ { print NF-1 }' `
82
+ elif command -v lscpu > /dev/null; then
83
+ nnumas=` lscpu | grep -c ' ^NUMA node.*CPU' `
84
+ fi
85
+
86
+ # Default MPI ranks.
87
+ # Try Slurm var, then num NUMA nodes.
81
88
nranks=$nnodes
82
89
nranks_is_def_cpu=1 # nranks has been set for CPU default only.
83
- if [[ ! -z ${ SLURM_NTASKS: +x} && $SLURM_NTASKS > $nnodes ]]; then
90
+ if [[ -n " $ SLURM_NTASKS" && $SLURM_NTASKS > $nnodes ]]; then
84
91
nranks=$SLURM_NTASKS
85
92
nranks_is_def_cpu=0
86
- elif command -v numactl > /dev/null; then
87
- ncpubinds=` numactl -s | awk ' /^cpubind:/ { print NF-1 }' `
88
- if [[ -n " $ncpubinds " ]]; then
89
- nranks=$(( $ncpubinds * $nnodes ))
90
- fi
91
- elif command -v lscpu > /dev/null; then
92
- nnumas=` lscpu | grep -c ' ^NUMA node.*CPU' `
93
- if [[ -n " $nnumas " ]]; then
94
- nranks=$(( $nnumas * $nnodes ))
95
- fi
93
+ elif [[ -n " $nnumas " ]]; then
94
+ nranks=$(( $nnumas * $nnodes ))
96
95
fi
97
96
nranks_offload=$nnodes
98
97
if [[ $ngpus > 0 ]]; then
@@ -368,7 +367,7 @@ done # parsing options.
368
367
echo $invo
369
368
370
369
# Check required opt (yes, it's an oxymoron).
371
- if [[ -z ${ stencil: +x} ]]; then
370
+ if [[ -z " $ stencil" ]]; then
372
371
echo " error: missing required option: -stencil <name>"
373
372
show_stencils
374
373
fi
@@ -394,7 +393,12 @@ if [[ $nranks > 1 || $force_mpi == 1 ]]; then
394
393
395
394
# Add default Intel MPI settings.
396
395
envs+=" I_MPI_PRINT_VERSION=1 I_MPI_DEBUG=5"
397
- envs+=" I_MPI_PIN_DOMAIN=numa"
396
+
397
+ # Add NUMA pinning if number of discovered NUMA nodes
398
+ # equals what is being used.
399
+ if [[ -n " $nnumas " && $nnumas == $ppn ]]; then
400
+ envs+=" I_MPI_PIN_DOMAIN=numa"
401
+ fi
398
402
399
403
# Check whether HBM policy setting is allowed.
400
404
if [[ ` I_MPI_HBW_POLICY=hbw_preferred,hbw_preferred mpirun -np 1 /bin/date | & grep -c ' Unknown memory policy' ` == 0 ]]; then
@@ -532,7 +536,7 @@ if [[ $is_offload == 1 ]]; then
532
536
if command -v nvidia-smi > /dev/null; then
533
537
config_cmds+=" ; nvidia-smi" ;
534
538
fi
535
- if [[ ! -z " $mpi_cmd " ]]; then
539
+ if [[ -n " $mpi_cmd " ]]; then
536
540
envs+=" I_MPI_OFFLOAD=2"
537
541
fi
538
542
fi
0 commit comments