source: trunk/LMDZ.MARS/deftank/adastra/adastra_cpu_binding.sh @ 3817

Last change on this file since 3817 was 3817, checked in by emillour, 2 days ago

Mars PCM:
Move adastra_cpu_binding.sh to "adastra" subforlder of deftank.
And adapt scripts and README there.
EM

  • Property svn:executable set to *
File size: 4.2 KB
Line 
1#!/bin/bash
2
3### To manage cpu binding on Adastra, add this binding script to the run directory
4### In your job script, adapt srun including the following arguments:
5### srun --ntasks-per-node=${SLURM_NTASKS_PER_NODE} --cpu-bind=none --mem-bind=none --label -- ./adastra_cpu_binding.sh ./gcm_64x48x54_phymars_para.e > gcm.out 2>&1
6
7set -eu
8
9LOCAL_RANK_INDEX="${SLURM_LOCALID}"
10LOCAL_RANK_COUNT="${SLURM_NTASKS_PER_NODE}"
11LOCAL_NODE_COUNT="${SLURM_NNODES}"
12LOCAL_OMP_NUM_THREADS="${SLURM_CPUS_PER_TASK}"
13
14echo "Adjust binding to ${LOCAL_NODE_COUNT} * ${LOCAL_RANK_COUNT} MPI tasks and ${LOCAL_OMP_NUM_THREADS} OpenMP threads"
15
16function Adastra_MI250_8TasksWith8ThreadsAnd1GPU() {
17    AFFINITY_NUMACTL=('48-55' '56-63' '16-23' '24-31' '0-7' '8-15' '32-39' '40-47')
18    AFFINITY_GPU=('0' '1' '2' '3' '4' '5' '6' '7')
19    export MPICH_OFI_NIC_POLICY=NUMA
20}
21
22function Adastra_GENOA_24TasksWith1Threads() {
23    AFFINITY_NUMACTL=('0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '20' '21' '22' '23')
24}
25
26function Adastra_GENOA_24TasksWith2Threads() {
27    AFFINITY_NUMACTL=('0-1' '2-3' '4-5' '6-7' '8-9' '10-11' '12-13' '14-15' '16-17' '18-19' '20-21' '22-23' '24-25' '26-27' '28-29' '30-31' '32-33' '34-35' '36-37' '38-39' '40-41' '42-43' '44-45' '46-47')
28}
29
30function Adastra_GENOA_24TasksWith4Threads() {
31    AFFINITY_NUMACTL=('0-3' '4-7' '8-11' '12-15' '16-19' '20-23' '24-27' '28-31' '32-35' '36-39' '40-43' '44-47' '48-51' '52-55' '56-59' '60-63' '64-67' '68-71' '72-75' '76-79' '80-83' '84-87' '88-91' '92-95')
32}
33
34function Adastra_GENOA_24TasksWith8Threads() {
35    AFFINITY_NUMACTL=('0-7' '8-15' '16-23' '24-31' '32-39' '40-47' '48-55' '56-63' '64-71' '72-79' '80-87' '88-95' '96-103' '104-111' '112-119' '120-127' '128-135' '136-143' '144-151' '152-159' '160-167' '168-175' '176-183' '184-191')
36}
37
38function Adastra_GENOA_48TasksWith4Threads() {
39    AFFINITY_NUMACTL=('0-3' '4-7' '8-11' '12-15' '16-19' '20-23' '24-27' '28-31' '32-35' '36-39' '40-43' '44-47' '48-51' '52-55' '56-59' '60-63' '64-67' '68-71' '72-75' '76-79' '80-83' '84-87' '88-91' '92-95' '96-99' '100-103' '104-107' '108-111' '112-115' '116-119' '120-123' '124-127' '128-131' '132-135' '136-139' '140-143' '144-147' '148-151' '152-155' '156-159' '160-163' '164-167' '168-171' '172-175' '176-179' '180-183' '184-187' '188-191')
40}
41
42function Adastra_GENOA_24TasksWith16Threads() {
43    # Requires SMT to be enabled.
44    AFFINITY_NUMACTL=('0-15' '16-31' '32-47' '48-63' '64-79' '80-95' '96-111' '112-127' '128-143' '144-159' '160-175' '176-191' '192-207' '208-223' '224-239' '240-255' '256-271' '272-287' '288-303' '304-319' '320-335' '336-351' '352-367' '368-383')
45}
46
47function Adastra_GENOA_12TasksWith16Threads() {
48    AFFINITY_NUMACTL=('0-15' '16-31' '32-47' '48-63' '64-79' '80-95' '96-111' '112-127' '128-143' '144-159' '160-175' '176-191')
49}
50
51if [ "${LOCAL_RANK_COUNT}" -eq 12 ]; then
52        if [ "${LOCAL_OMP_NUM_THREADS}" -eq 16 ]; then
53                Adastra_GENOA_12TasksWith16Threads
54        else
55                echo "Could not find a function for the given MPI/OMP combination"
56                exit 1
57        fi
58elif [ "${LOCAL_RANK_COUNT}" -eq 24 ]; then
59        if [ "${LOCAL_OMP_NUM_THREADS}" -eq 1 ]; then
60                Adastra_GENOA_24TasksWith1Threads
61        elif [ "${LOCAL_OMP_NUM_THREADS}" -eq 2 ]; then
62                Adastra_GENOA_24TasksWith2Threads
63        elif [ "${LOCAL_OMP_NUM_THREADS}" -eq 4 ]; then
64                Adastra_GENOA_24TasksWith4Threads
65        elif [ "${LOCAL_OMP_NUM_THREADS}" -eq 8 ]; then
66                Adastra_GENOA_24TasksWith8Threads
67        elif [ "${LOCAL_OMP_NUM_THREADS}" -eq 16 ]; then
68                Adastra_GENOA_24TasksWith16Threads
69        else
70                echo "Could not find a function for the given MPI/OMP combination"
71                exit 1
72        fi 
73elif [ "${LOCAL_RANK_COUNT}" -eq 48 ]; then
74        if [ "${LOCAL_OMP_NUM_THREADS}" -eq 4 ]; then
75                Adastra_GENOA_48TasksWith4Threads
76        else
77                echo "Could not find a function for the given MPI/OMP combination"
78                exit 1
79        fi
80else
81        echo "Could not find a binding function for the given MPI/OMP combination"
82        exit 1
83fi
84
85CPU_SET="${AFFINITY_NUMACTL[$((${LOCAL_RANK_INDEX} % ${#AFFINITY_NUMACTL[@]}))]}"
86if [ ! -z ${AFFINITY_GPU+x} ]; then
87    GPU_SET="${AFFINITY_GPU[$((${LOCAL_RANK_INDEX} % ${#AFFINITY_GPU[@]}))]}"
88    export ROCR_VISIBLE_DEVICES="${GPU_SET}"
89fi
90exec numactl --localalloc --physcpubind="${CPU_SET}" -- "${@}"
Note: See TracBrowser for help on using the repository browser.