-
Notifications
You must be signed in to change notification settings - Fork 165
/
test-hwloc-calc.sh.in
282 lines (258 loc) · 10.5 KB
/
test-hwloc-calc.sh.in
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#!/bin/sh
#-*-sh-*-
#
# Copyright © 2009 CNRS
# Copyright © 2009-2023 Inria. All rights reserved.
# Copyright © 2009, 2011 Université Bordeaux
# Copyright © 2014 Cisco Systems, Inc. All rights reserved.
# See COPYING in top-level directory.
#
HWLOC_top_srcdir="@HWLOC_top_srcdir@"
HWLOC_top_builddir="@HWLOC_top_builddir@"
srcdir="$HWLOC_top_srcdir/utils/hwloc"
builddir="$HWLOC_top_builddir/utils/hwloc"
calc="$builddir/hwloc-calc"
xmldir="$HWLOC_top_srcdir/tests/hwloc/xml"
linuxdir="$HWLOC_top_srcdir/tests/hwloc/linux"
HWLOC_PLUGINS_PATH=${HWLOC_top_builddir}/hwloc/.libs
export HWLOC_PLUGINS_PATH
HWLOC_DEBUG_CHECK=1
export HWLOC_DEBUG_CHECK
: ${TMPDIR=/tmp}
{
tmp=`
(umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
` &&
test -n "$tmp" && test -d "$tmp"
} || {
tmp=$TMPDIR/foo$$-$RANDOM
(umask 077 && mkdir "$tmp")
} || exit $?
file="$tmp/test-hwloc-calc.output"
set -e
(
echo "# root"
$calc --if synthetic --input "node:4 core:4 pu:4" root
echo
echo "# all --taskset"
$calc --if synthetic --input "node:4 core:4 pu:4" all --taskset
echo
echo "# hex"
$calc --if synthetic --input "node:4 core:4 pu:4" 0xf
echo
echo "# hex combination"
$calc --if synthetic --input "node:4 core:4 pu:4" 0xf ~0x3 0xff0 '^0xf0'
echo
echo "# object combination"
$calc --if synthetic --input "node:4 core:4 pu:4" core:0 pu:15 ~pu:0 '^pu:2'
echo
echo "# --no-smt NUMA Node range"
$calc --if synthetic --input "node:4 core:4 pu:4" --no-smt node:2-3
echo
echo "# --no-smt hex"
$calc --if synthetic --input "node:4 core:4 pu:4" --no-smt 0x1fe
echo
echo "# --no-smt=1 hex"
$calc --if synthetic --input "node:4 core:4 pu:4" --no-smt=1 0x1fe
echo
echo "# --no-smt=2 hex"
$calc --if synthetic --input "node:4 core:4 pu:4" --no-smt=2 0x1fe
echo
echo "# --no-smt=3 hex"
$calc --if synthetic --input "node:4 core:4 pu:4" --no-smt=3 0x1fe
echo
echo "# --no-smt=4 hex"
$calc --if synthetic --input "node:4 core:4 pu:4" --no-smt=4 0x1fe
echo
echo "# --no-smt=-1 hex"
$calc --if synthetic --input "node:4 core:4 pu:4" --no-smt=-1 0x1fe
echo
echo "# even PUs"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:even
echo
echo "# NUMA Nodes 2+"
$calc --if synthetic --input "node:4 core:4 pu:4" node:2-
echo
echo "# cores 12+"
$calc --if synthetic --input "node:4 core:4 pu:4" core:12-
echo
echo "# PU wrapping range"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:62:10
echo
echo "# some PUs in all Cores"
$calc --if synthetic --input "node:4 core:4 pu:4" core:all.pu:1:2
echo
echo "# one PU in odd Cores"
$calc --if synthetic --input "node:4 core:4 pu:4" core:odd.pu:0
echo
echo "# combination of different ranges, hierarchical or not"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:6:2 core:3-4.pu:1-3 node:2.pu:14:2 node:3.core:3.pu:3
echo
echo "# number of Group0 when there are 3 group levels"
$calc --if synthetic --input "group:2 node:2 group:2 pu:2" -N group0 all
echo
echo "# list of Group1 near one Group0 when there are 3 group levels"
$calc --if synthetic --input "group:2 node:2 group:2 pu:2" -I group1 group0:0
echo
echo "# hierarchical list of Group0.Group2 near one NUMA when there are 3 group levels"
$calc --if synthetic --input "group:2 node:2 group:2 pu:2" -H group0.group2 numa:3
echo
echo "# number of Group2 when there are 3 group levels"
$calc --if synthetic --input "group:2 node:2 group:2 pu:2" -N group2 all
echo
echo "# Number of NUMA Nodes"
$calc --if synthetic --input "node:4 core:4 pu:4" root --number-of node
echo
echo "# Number of Cores in a NUMA Node"
$calc --if synthetic --input "node:4 core:4 pu:4" node:2 -N core
echo
echo "# Number of objects at depth 3 in a NUMA Node"
$calc --if synthetic --input "node:4 core:4 pu:4" node:2 -N 3
echo
echo "# List of Machine objects"
$calc --if synthetic --input "node:4 core:4 pu:4" root --intersect Machine
echo
echo "# List of NUMA Nodes in a range of Cores"
$calc --if synthetic --input "node:4 core:4 pu:4" core:4-7 -I NUMANode
echo
echo "# List of NUMA Nodes in a range of Cores (again)"
$calc --if synthetic --input "node:4 core:4 pu:4" core:10-15 -I NUMANode --oo
echo
echo "# Hierarchical spec for a range of PUs"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:2-3 --hierarchical group.pu
echo
echo "# Hierarchical spec for a range of PUs, with different separator"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:3-6 -H group.core --sep foo
echo
echo "# Hierarchical spec for a range of PUs (again)"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:3-6 -H core.pu
echo
echo "# List of PUs from another invocation with hierarchical output"
$calc --if synthetic --input "node:4 core:4 pu:4" -I pu `$calc --if synthetic --input "node:4 core:4 pu:4" pu:3-6 -H core.pu`
echo
echo "# Hierarchical spec for a range of PUs (3 levels)"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:11:4 -H group.core.pu
echo
echo "# List of PUs from another invocation with hierarchical output (again)"
$calc --if synthetic --input "node:4 core:4 pu:4" -I pu `$calc --if synthetic --input "node:4 core:4 pu:4" pu:11:4 -H group.core.pu`
echo
echo "# --largest"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:12-37 --largest
echo
echo "# --largest, with different separator"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:22-47 --largest --sep "_"
echo
echo "# Singlified output"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:22-47 --single
echo
echo "# Singlified PU list"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:22-47 --single -I pu
echo
echo "# PU list with physical output"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:33-37 -I pu --po
echo
echo "# NUMA Node list of physical output and different separator"
$calc --if synthetic --input "node:4 core:4 pu:4" pu:30-37 -I node --po --sep foo
echo
echo "# Manipulating NUMA Nodes with nodesets"
$calc --if synthetic --input "node:4 core:4 pu:4" -n node:1-2
echo
echo "# Nodeset output of PUs"
$calc --if synthetic --input "node:4 core:4 pu:4" --no pu:63
echo
echo "# Converting NUMA Nodes from logical to physical"
$calc --if synthetic --input "node:4 core:4 pu:4" --ni 0x5 -I node --po
echo
echo "# Search cores within single NUMA when they have multiple local NUMA nodes"
$calc --if synthetic --input "pack:2 [numa] [numa] core:4 pu:1" sock:1.numa:1.core:1-2
echo
echo "# Search NUMA node within single Group when they have multiple local Groups"
$calc --if synthetic --input "pack:2 [numa] group:2 core:4 1" --nodeset-output pack:1.group:1.numa:0
echo
echo "# Physical output of NUMA Nodes when out-of-order in the topology"
$calc --if synthetic --input "node:4(indexes=3,2,1,0) pu:2" node:1-2 --po -I node
echo
echo "# Converting physical to logical PU indexes when complexly ordered in the topology"
$calc --if synthetic --input "node:4 core:4 pu:4(indexes=node:core)" --pi pu:2-5 -I pu
echo
echo "# 4 local nodes near a Package (node:3-4@Die + node:5@Package + node:6@Machine)"
$calc --if synthetic --input "[numa] pack:2 [numa] die:2 [numa] pu:2" --local-memory package:1
echo
echo "# 2 local nodes larger or equal to a Package (node:2@Package + node:6@Machine), with space separator"
$calc --if synthetic --input "[numa] pack:2 [numa] die:2 [numa] pu:2" --local-memory-flags 1 --sep " " pack:0 --oo
echo
echo "# Best-locality local node near a PU (node:1@Die)"
$calc --if synthetic --input "[numa] pack:2 [numa] die:2 [numa] pu:2" --best-memattr locality pu:3 --oo
echo
echo "# Best-capacity local node near a PU (node:6@Machine)"
$calc --if synthetic --input "[numa(memory=1000000)] pack:2 [numa(memory=100000)] die:2 [numa(memory=1000)] pu:2" --best-memattr capacity pu:4
echo
echo "# CPU kind by index"
$calc --if xml --input $linuxdir/fakeheterocpunuma.xml --cpukind 1 all
echo
echo "# CPU kind by wrong index"
$calc --if xml --input $linuxdir/fakeheterocpunuma.xml --cpukind 3 all
echo
echo "# CPU kind by info attr"
$calc --if xml --input $linuxdir/fakeheterocpunuma.xml --cpukind FrequencyMaxMHz=3000 all
echo
echo "# Caches with attributes"
$calc --if synthetic --input "numa:2 l3:2 pu:1" numa:0 l3u:3
echo
echo "# Groups with attributes"
$calc --if synthetic --input "group:2 numa:2 l2:2 l1d:2 pu:1" Group0:1 NUMA:0
echo
echo "# Caches without attributes"
$calc --if synthetic --input "group:2 numa:2 l2:2 l1d:2 pu:1" l2:0-2 L1cache:13:3
echo
echo "# OS devices by name"
$calc --if xml --input $xmldir/96em64t-4n4d3ca2co-pci.xml os=eth6 os=eth4
echo
echo "# OS devices by name (again)"
$calc --if xml --input $xmldir/96em64t-4n4d3ca2co-pci.xml os=sdc os=sr0 ~os=sda
echo
echo "# OS devices by range"
$calc --if xml --input $xmldir/96em64t-4n4d3ca2co-pci.xml os:7-8
echo
echo "# PCI devices by range"
$calc --if xml --input $xmldir/96em64t-4n4d3ca2co-pci.xml pci:10-11
echo
echo "# PCI devices by vendors/device IDs and range wrapping around"
$calc --if xml --input $xmldir/96em64t-4n4d3ca2co-pci.xml pci'[1000:0062]':3:2
echo
echo "# PCI devices by vendors/device IDs and index"
$calc --if xml --input $xmldir/96em64t-4n4d3ca2co-pci.xml pci'[14e4:1639]':1
echo
echo "# PCI devices by vendors/device IDs and range"
$calc --if xml --input $xmldir/96em64t-4n4d3ca2co-pci.xml pci'[14e4:1639]':2-5
echo
echo "# PCI devices added"
$calc --if xml --input $xmldir/96em64t-4n4d3ca2co-pci.xml pci=0000:62:00.1 pci=0000:02:00.1
echo
echo "# PCI devices intersection"
$calc --if xml --input $xmldir/96em64t-4n4d3ca2co-pci.xml pci=0000:62:00.1 xpci=0000:02:00.0
echo
echo "# PCI devices intersection (again)"
$calc --if xml --input $xmldir/96em64t-4n4d3ca2co-pci.xml pci=0000:02:00.0 xpci=0000:02:00.1
echo
echo "# Restrict"
$calc -i "node:4 pu:4" --restrict 0xf0 --restrict-flags cpuless all -N pu
$calc -i "node:4 pu:4" --restrict 0xf0 --restrict-flags cpuless all -N numa
$calc -i "node:4 pu:4" --restrict-flags bynode,memless --restrict 0x3 all -N pu
$calc -i "node:4 pu:4" --restrict 0xff0 --restrict-flags none all -N pu
$calc -i "node:4 pu:4" --restrict-flags cpuless --restrict 0xff0 all -I numa --po
echo
echo "# Reading from stdin"
cat << EOF | $calc --if synthetic --input "node:4 core:4 pu:4"
pu:0
core:0 core:15
node:0 node:3
0x0001 0x00002 0x000004 0x000000000008
0x0000000000000000000000000000000000000000000000000000000000000000000000000000001
0x1,0x0,0x0
root
EOF
echo
) > "$file"
@DIFF@ @HWLOC_DIFF_U@ @HWLOC_DIFF_W@ $srcdir/test-hwloc-calc.output "$file"
rm -rf "$tmp"