Skip to content

Commit 08b684f

Browse files
authored
Merge pull request #291 from intel/develop
Add checks when applying NUMA MPI pinning.
2 parents cb75540 + fa94f75 commit 08b684f

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

src/common/common_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace yask {
4747
// https://semver.org/.
4848

4949
// Format: "major.minor.patch[-alpha|-beta]".
50-
const string version = "4.05.01";
50+
const string version = "4.05.02";
5151

5252
string yask_get_version_string() {
5353
return version;

src/kernel/yask.sh

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ arch_is_def_cpu=1 # arch has been set for CPU default only.
5858

5959
# Default nodes.
6060
nnodes=1
61-
if [[ ! -z ${SLURM_NNODES:+x} ]]; then
61+
if [[ -n "$SLURM_NNODES" ]]; then
6262
nnodes=$SLURM_NNODES
6363
fi
6464

@@ -74,25 +74,24 @@ elif command -v nvidia-smi >/dev/null; then
7474
fi
7575
is_offload=0
7676

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.
8079
# (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.
8188
nranks=$nnodes
8289
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
8491
nranks=$SLURM_NTASKS
8592
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 ))
9695
fi
9796
nranks_offload=$nnodes
9897
if [[ $ngpus > 0 ]]; then
@@ -368,7 +367,7 @@ done # parsing options.
368367
echo $invo
369368

370369
# Check required opt (yes, it's an oxymoron).
371-
if [[ -z ${stencil:+x} ]]; then
370+
if [[ -z "$stencil" ]]; then
372371
echo "error: missing required option: -stencil <name>"
373372
show_stencils
374373
fi
@@ -394,7 +393,12 @@ if [[ $nranks > 1 || $force_mpi == 1 ]]; then
394393

395394
# Add default Intel MPI settings.
396395
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
398402

399403
# Check whether HBM policy setting is allowed.
400404
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
532536
if command -v nvidia-smi >/dev/null; then
533537
config_cmds+="; nvidia-smi";
534538
fi
535-
if [[ ! -z "$mpi_cmd" ]]; then
539+
if [[ -n "$mpi_cmd" ]]; then
536540
envs+=" I_MPI_OFFLOAD=2"
537541
fi
538542
fi

0 commit comments

Comments
 (0)