Skip to content

Commit

Permalink
Rely on Slurm job-scheduler to determine number of nodes and node nam…
Browse files Browse the repository at this point in the history
…es. Made mynodes.sh script fully optional.
  • Loading branch information
hfp committed Jul 19, 2024
1 parent e19e648 commit 94760f0
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions config/cp2k/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,22 @@ else
NRANKS=${NC}
fi

if [ -e "${ROOT}/mynodes.sh" ]; then
HOSTS=$("${ROOT}/mynodes.sh" 2>/dev/null | tr -s '\n ' ',' | sed 's/^\(..*[^,]\),*$/\1/')
else
HOSTS=${HOSTS:-localhost}
fi

if [ "$1" ]; then
HOSTS=$(cut -d, -f"1-$1" <<<"${HOSTS}")
NUMNODES=$1
shift
elif [ "${SLURM_JOB_NUM_NODES}" ]; then
NUMNODES=${SLURM_JOB_NUM_NODES}
else
NUMNODES=1
fi

if [ -e "${ROOT}/mynodes.sh" ] && [ "0" != "${MYNODES}" ]; then
HOSTS=$("${ROOT}/mynodes.sh" 2>/dev/null | tr -s '\n ' ',' | sed 's/^\(..*[^,]\),*$/\1/')
NUMCOMMA=$(tr -cd ',' <<<"${HOSTS}" | wc -c)
NUMNODES=$((NUMCOMMA+1))
fi
HOSTS=$(cut -d, -f1-${NUMNODES} <<<"${HOSTS}")
HOSTS=${HOSTS:-localhost}

#HPCWL_COMMAND_PREFIX="aps -c mpi,omp"
#MPIRUNPREFX="perf stat -e tlb:tlb_flush,irq_vectors:call_function_entry,syscalls:sys_enter_munmap,syscalls:sys_enter_madvise,syscalls:sys_enter_brk"
Expand Down Expand Up @@ -166,12 +170,11 @@ if [ "${I_MPI_ROOT}" ]; then
#export I_MPI_PIN_ORDER=${I_MPI_PIN_ORDER:-bunch}
#export I_MPI_FABRICS=shm:tcp
else
HOSTS=$(sed 's/^\(..*[^,]\),*$/\1/' <<<"${HOSTS}" | sed -e "s/,/:${NC},/g" -e "s/$/:${NC}/")
MPIRUNFLAGS="${MPIRUNFLAGS} --report-bindings"
MPIRUNFLAGS="${MPIRUNFLAGS} --map-by ppr:$(((NRANKS+NS-1)/NS)):package:PE=$((NC/NRANKS))"
fi

if [ "0" != "${MYNODES}" ]; then
if [ -e "${ROOT}/mynodes.sh" ]; then
HST="-host ${HOSTS}"
fi

Expand Down

0 comments on commit 94760f0

Please sign in to comment.