Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace costly call to 'scontrol show config' with pmix env vars #204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions conf/hooks/extra/50-slurm-pmi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ done
if [[ -z "${SLURM_MPI_TYPE-}" || "${SLURM_MPI_TYPE}" == pmix* ]] && compgen -e "PMIX_" > /dev/null; then
source "${ENROOT_LIBRARY_PATH}/common.sh"

common::checkcmd scontrol awk

scontrol show config | awk '/^SlurmdSpoolDir|^TmpFS/ {print $3}' \
| { read -r slurm_spool; read -r slurm_tmpfs; } || :

if [ -z "${slurm_spool}" ] || [ -z "${slurm_tmpfs}" ]; then
common::err "Could not read SLURM configuration"
fi
# Precedence of vars documented at https://docs.openpmix.org/en/latest/how-things-work/session_dirs.html
default_tmpdir=${TMPDIR:-${TEMP:-${TMP:-/tmp}}}
system_tmpdir=${PMIX_SYSTEM_TMPDIR:-${default_tmpdir}}
server_tmpdir=${PMIX_SERVER_TMPDIR:-${default_tmpdir}}

for var in $(compgen -e "PMIX_"); do
printf "%s=%s\n" "${var}" "${!var}" >> "${ENROOT_ENVIRON}"
Expand All @@ -51,12 +47,12 @@ if [[ -z "${SLURM_MPI_TYPE-}" || "${SLURM_MPI_TYPE}" == pmix* ]] && compgen -e "
printf "PMIX_MCA_gds=%s\n" ${PMIX_GDS_MODULE} >> "${ENROOT_ENVIRON}"
fi

if [ -e "${slurm_tmpfs}/spmix_appdir_${SLURM_JOB_UID}_${SLURM_JOB_ID}.${SLURM_STEP_ID}" ]; then
printf "%s x-create=dir,bind,rw,nosuid,noexec,nodev,private,nofail\n" "${slurm_tmpfs}/spmix_appdir_${SLURM_JOB_UID}_${SLURM_JOB_ID}.${SLURM_STEP_ID}" >> "${ENROOT_MOUNTS}"
if [ -e "${system_tmpdir}/spmix_appdir_${SLURM_JOB_UID}_${SLURM_JOB_ID}.${SLURM_STEP_ID}" ]; then
printf "%s x-create=dir,bind,rw,nosuid,noexec,nodev,private,nofail\n" "${system_tmpdir}/spmix_appdir_${SLURM_JOB_UID}_${SLURM_JOB_ID}.${SLURM_STEP_ID}" >> "${ENROOT_MOUNTS}"
else
printf "%s x-create=dir,bind,rw,nosuid,noexec,nodev,private,nofail\n" "${slurm_tmpfs}/spmix_appdir_${SLURM_JOB_ID}.${SLURM_STEP_ID}" >> "${ENROOT_MOUNTS}"
printf "%s x-create=dir,bind,rw,nosuid,noexec,nodev,private,nofail\n" "${system_tmpdir}/spmix_appdir_${SLURM_JOB_ID}.${SLURM_STEP_ID}" >> "${ENROOT_MOUNTS}"
fi
printf "%s x-create=dir,bind,rw,nosuid,noexec,nodev,private\n" "${slurm_spool}/pmix.${SLURM_JOB_ID}.${SLURM_STEP_ID}" >> "${ENROOT_MOUNTS}"
printf "%s x-create=dir,bind,rw,nosuid,noexec,nodev,private\n" "${server_tmpdir}" >> "${ENROOT_MOUNTS}"
fi

# Check for PMI/PMI2 support.
Expand Down