#!/bin/bash # Adapted A. Barral 07/2024 from https://dci.dci-gitlab.cines.fr/webextranet/porting_optimization/detailed_binding_script.html#porting-optimization-detailed-binding-script # Used within exclusive nodes as srun --cpu-bind=none --mem-bind=none -- ./set_binding.sh # Note: On Adastra, OMP_PLACES & OMP_PROC_BIND seems to have no effect (probably the default assignment is the same), but I left it there just in case for other configurations. set -eu function create_affinity_numactl() { local num_tasks=$1 # Number of MPI tasks local num_threads=$2 # Number of OMP threads per task AFFINITY_NUMACTL=() OMP_PLACES_ARR=() local start_cpu=0 local total_strands thread_per_core total_strands=392 # "$(lscpu | grep "^CPU(s):" | awk '{print $2}')" # Total physical threads in the system thread_per_core="$(lscpu | grep "^Thread(s) per core:" | awk '{print $4}')" local total_cpus=$(( total_strands / thread_per_core )) # Total physical cores in the system num_smt_used=$(( (num_tasks*num_threads+total_cpus-1)/total_cpus )) # ceil(total_threads_required/total_cpus) # Parameter range check if [[ $(( num_tasks * num_threads )) -gt $(( total_strands )) ]]; then echo "STOP: requesting more CPUs than available on the system!"; exit 1 fi if [[ $(( num_threads % num_smt_used )) -ne 0 ]]; then echo "STOP: OMP threads number ($num_threads) must be a multiple of $num_smt_used (using $num_smt_used out of $thread_per_core SMT threads per core)."; exit 1 fi for (( task=0; task