Open3
NUMA をざっくりキャッチアップ
前提知識: SMP vs. AMP
- 1つのシステムに複数の CPU or 複数の CPU core を持つ場合に処理方法
- SMP (Symmetric Multiprocessing)
- 各 processor / core に、特別な役割や主従関係などがなく、対等/対称な関係になっている。
- タイプ: 負荷分散型 => 同じ処理を分散
- 用途: Windows や Linux などの汎用 OS、データセンター
- AMP (Asymmetric Multiprocessing)
- 複数の processor / core 間で、役割分担 (OS 用 CPU とアプリケーション用 CPU など) などが存在し、対等/対称な関係になっていない。
- タイプ: 機能分散型 => processor / core ごとに別の機能を選任
- 用途: RTOS、組み込みシステム
NUMA (Non-Uniform Memory Access)
- SMP のアーキテクチャの1つで、複数の processor が共有する memory へのアクセスコストが、アクセスする memory 領域と processor に依存して均一ではないアーキテクチャのこと。
背景
- 小規模の SMP システムでは、単一の bus 上に全ての processor と memory が同居しているが、bus の特性として複数の processor から memory に同時にアクセスすることができない。
- この現象は、同一 bus 上に接続される processor 数が増えるほど(大規模な SMP システムほど)、顕著になる。
NUMA の登場
- processor と memory の対(node と呼ばれる)を複数作成し、それぞれの node に bus が用意されることで、それぞれの node で並列して memory へアクセスすることができ、bus の競合を回避できる。
- しかし、SMP では全ての processor が対称である必要があり、全ての memory 領域にアクセスできる必要があるため、node 間を接続する必要がある (interconnect と呼ばれる) 。
- ある processor が、自身の node 以外の node の memory にアクセス (remote access と呼ばれる) する場合 、その interconnect を経由する必要があるため、自身の node 内の memory へのアクセス (local access と呼ばれる) よりも時間がかかる。
- この memory アクセス時間の不均一性 (non-uniformity) から、NUMA (Non-Uniform Memory Access) と呼ばれる。
numactl
Amazon EC2 の m6i.metal インスタンスで numactl
コマンドを使って、NUMA を確認してみる。
$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 128
On-line CPU(s) list: 0-127
Thread(s) per core: 2
Core(s) per socket: 32
Socket(s): 2
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 106
Model name: Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz
Stepping: 6
CPU MHz: 1290.420
CPU max MHz: 3500.0000
CPU min MHz: 800.0000
BogoMIPS: 5800.00
Virtualization: VT-x
L1d cache: 48K
L1i cache: 32K
L2 cache: 1280K
L3 cache: 55296K
NUMA node0 CPU(s): 0-31,64-95
NUMA node1 CPU(s): 32-63,96-127
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 invpcid_single intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect wbnoinvd dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid fsrm md_clear pconfig flush_l1d arch_capabilities
--hardware, -H
--hardware, -H
Show inventory of available nodes on the system.
システムの利用可能なノード情報が表示できる。
$ numactl --hardware
available: 2 nodes (0-1)
node 0 cpus: 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
node 0 size: 257802 MB
node 0 free: 248086 MB
node 1 cpus: 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
node 1 size: 257982 MB
node 1 free: 255661 MB
node distances:
node 0 1
0: 10 20
1: 20 10
- 2 つのノードで構成されている。
- node 0: cpu 0-31, 64-95
- node 1: cpu 32-63, 96-127
- node で memory size が微妙に違っている。
- node 0: 257802 MB
- node 1: 257982 MB
--show, -s
--show, -s
Show NUMA policy settings of the current process.
現在のプロセスに設定されている NUMA ポリシーを表示できる。
$ numactl --show
policy: default
preferred node: current
physcpubind: 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
cpubind: 0 1
nodebind: 0 1
membind: 0 1