1

I have access to a HPC with 40 cores on each node. I have a batch file to run a total of 35 codes which are in separate folders. Each code is an open mp code which requires 4 cores each. so how do I allocate resources such that each code gets 4 core. please tell me how to use $SLURM_JOB_NODELIST this env as I know this gives the list of nodes assigned in the queue. basically, my idea is to make nodefile in each folder and then use that in mpirun.

I'm a physics student don't know much about bash scripts.

#!/bin/bash 
#SBATCH --error=job.err 
#SBATCH --output=job.out 
#SBATCH --time=24:00:00 
#SBATCH --job-name=a20
#SBATCH --partition=cpu                               
#SBATCH --nodes=4                   
#SBATCH --ntasks-per-node=10 
#SBATCH --cpus-per-task=4

let tasks_per_job=1
let threads_per_task=4
export OMP_NUM_THREADS=$threads_per_task
module load intel/2018.0.1.163


cd $SLURM_SUBMIT_DIR

cd a20

k=1
for j in */*
do
cd $j
sed -n $k,$k'p' < $SLURM_JOB_NODELIST >nodefile$k
mpirun  -np $tasks_per_job  --hostfile nodefile$k ./chk  >& job$k.out &
sleep 2
let k=$k+1
cd ../..
done

wait
                                                                                                                               
Dave M
  • 13,138
  • 25
  • 36
  • 47

0 Answers0