본문 바로가기

HPC

NUMA Pinning of AMD ThreadRipper 7995WX Pro

대부분의 CPU들이 Core의 NUMA Node 배분시 Core Number를 순차적으로 증가시키는데 반하여,

7995WX Pro는 괴상한 방법으로 배분을 시킨다.

 

1. AMD Ryzen Threadripper PRO 5995WX 64-Cores
numactl --hardware
available: 4 nodes (0-3)
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
node 1 cpus: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
node 2 cpus: 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
node 3 cpus: 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
node   0   1   2   3
  0:  10  12  12  12
  1:  12  10  12  12
  2:  12  12  10  12
  3:  12  12  12  10

 

2. AMD Ryzen Threadripper PRO 7995WX 96-Cores
numactl --hardware
available: 4 nodes (0-3)
node 0 cpus: 0 1 2 3 4 5 6 7 32 33 34 35 36 37 38 39 64 65 66 67 68 69 70 71
node 1 cpus: 16 17 18 19 20 21 22 23 48 49 50 51 52 53 54 55 80 81 82 83 84 85 86 87
node 2 cpus: 24 25 26 27 28 29 30 31 56 57 58 59 60 61 62 63 88 89 90 91 92 93 94 95
node 3 cpus: 8 9 10 11 12 13 14 15 40 41 42 43 44 45 46 47 72 73 74 75 76 77 78 79
node   0   1   2   3
  0:  10  12  12  12
  1:  12  10  12  12
  2:  12  12  10  12
  3:  12  12  12  10

 

변태스러운 코어 배분이다. 이 때문에 lammps를 NUMA를 이용하여 실행시키면 골때리는 상황이 펼쳐지는데,

원래는 아래와 같아야 되나,

numastat
                           node0           node1           node2           node3
numa_hit                 1404141         1306935         1154680         1058982
numa_miss                      0               0               0               0
numa_foreign                   0               0               0               0
interleave_hit            485466          487649          487055          486947
local_node               1365680          797402          663169          560786
other_node                 38461          509533          491511          498196

 

이런 상황이 발생하게 된다.

mpirun -np 96 \
  --map-by ppr:24:numa \
  --bind-to core \
  ./lmp -in in.ST1.MSCDSS


numastat
                           node0           node1           node2           node3
numa_hit                83527508         3809750         7603958         4080391
numa_miss                      0        41438864         8779004               0
numa_foreign            50168662           49206               0               0
interleave_hit               558             561             560             560
local_node              83521077         3771634         7586512         4069386
other_node                  6431        41476980         8796450           11005

 

따라서, 7995WX 같은경우 강제로 mpi rank와 코어를 매칭시켜 주어야 하는데,

Openmpi에서는 rankfile 옵션이란걸 사용할 수 있다.

 

실행은 아래와 같이 한다.

mpirun -np 96 \
  --map-by rankfile:file=rankfile.txt \
  --bind-to core \
  --report-bindings \
  ./lmp -in in.ST1.MSCDSS

 

rankfile은 아래와 같이 생겨 먹었으며,

rank 0=localhost slot=0
rank 1=localhost slot=1
rank 2=localhost slot=2
rank 3=localhost slot=3
rank 4=localhost slot=4
rank 5=localhost slot=5
rank 6=localhost slot=6
rank 7=localhost slot=7
rank 8=localhost slot=32
rank 9=localhost slot=33
rank 10=localhost slot=34
rank 11=localhost slot=35
rank 12=localhost slot=36
rank 13=localhost slot=37
rank 14=localhost slot=38
rank 15=localhost slot=39
rank 16=localhost slot=64
rank 17=localhost slot=65
rank 18=localhost slot=66
rank 19=localhost slot=67
rank 20=localhost slot=68
rank 21=localhost slot=69
rank 22=localhost slot=70
rank 23=localhost slot=71
rank 24=localhost slot=16
rank 25=localhost slot=17
rank 26=localhost slot=18
rank 27=localhost slot=19
...

 

일일이 수작업으로 만들어 주는건 개노가다 일 수 있으니까, 쉘 스크립트를 쓰자

 

generate_rankfile.sh

#!/bin/bash

# Output rankfile
RANKFILE="rankfile.txt"
echo -n > $RANKFILE

# Parse core lists per NUMA node
declare -a cores

while IFS= read -r line; do
  if [[ "$line" =~ ^node\ ([0-9]+)\ cpus:\ (.+)$ ]]; then
    node_id="${BASH_REMATCH[1]}"
    core_list="${BASH_REMATCH[2]}"
    for core in $core_list; do
      cores+=("$core")
    done
  fi
done < <(numactl --hardware)

# Write rankfile
for i in "${!cores[@]}"; do
  echo "rank $i=localhost slot=${cores[$i]}" >> $RANKFILE
done

echo "Generated $RANKFILE with ${#cores[@]} ranks."

 

권한설정해주고 실행하면, rankfile.txt가 생겨서 이걸로 코어 바인딩을 시키면 된다.

chmod +x generate_rankfile.sh
./generate_rankfile.sh

'HPC' 카테고리의 다른 글

Command line option for MPIRUN  (0) 2025.04.22
pkg-config in NURION  (0) 2025.04.15
생각해 볼 것  (0) 2025.04.14
Ncurses  (0) 2025.04.14
디렉토리 관리 in NURION  (0) 2025.04.13