Skip to content

Commit 4d1d25a

Browse files
author
ndenoyelle
committed
Various fixes
Signed-off-by: ndenoyelle <[email protected]>
1 parent e02c5ae commit 4d1d25a

File tree

4 files changed

+96
-114
lines changed

4 files changed

+96
-114
lines changed

hwloc/distrib.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ static size_t* shuffled_range(const size_t n){
4949
if ((ret = malloc(n*sizeof(*ret))) == NULL) { free(index); return NULL; }
5050

5151
srand(time(NULL));
52-
for(i=n-1;i>=0;i--){
53-
val = rand()%(i+1);
54-
ret[i] = index[val];
55-
index[val] = index[i];
52+
for(i=n;i>0;i--){
53+
val = rand()%(i);
54+
ret[i-1] = index[val];
55+
index[val] = index[i-1];
5656
}
5757
free(index);
5858
return ret;
@@ -233,6 +233,8 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
233233
if ((obj->cpuset != NULL && !hwloc_bitmap_iszero(obj->cpuset)) &&
234234
hwloc_get_type_depth(topology, obj->type) >= 0)
235235
n++;
236+
if (obj->type == type)
237+
break;
236238
obj = obj->first_child;
237239
}
238240

@@ -245,6 +247,8 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
245247
levels[n-1-i] = obj->type;
246248
i++;
247249
}
250+
if (obj->type == type)
251+
break;
248252
obj = obj->first_child;
249253
}
250254

@@ -257,7 +261,7 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
257261
*it->roots = root;
258262
it->n_roots = 1;
259263
it->root_coord = 0;
260-
it->n_levels = 1;
264+
it->n_levels = n;
261265
it->levels = (struct hwloc_distrib_level **)((char*)it +
262266
sizeof(*it) +
263267
sizeof(hwloc_obj_t));

tests/hwloc/hwloc_distrib.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static void test_scatter(hwloc_topology_t topology)
138138
if ( !is_tleaf(topology) )
139139
return;
140140

141-
ssize_t i=0, j, r, n=0, c, val, nleaves=1;
141+
ssize_t i=0, j, r, n_levels=0, n=0, c, val, nleaves=1;
142142
hwloc_obj_t item, obj, root = hwloc_get_obj_by_depth(topology, 0, 0);
143143
struct hwloc_distrib_iterator *it;
144144

@@ -172,12 +172,13 @@ static void test_scatter(hwloc_topology_t topology)
172172
item = obj;
173173
goto next_level;
174174
}
175-
175+
176+
n_levels=n;
176177
for (i = 0; hwloc_distrib_iterator_next(topology, it, &item); i++) {
177178
c = i;
178179
n = nleaves;
179180
val = 0;
180-
for (j = (n-2); j >= 0; j--) {
181+
for (j = (n_levels-1); j > 0; j--) {
181182
r = c % arities[j];
182183
n = n / arities[j];
183184
c = c / arities[j];

utils/hwloc/test-hwloc-distrib.output

+71-83
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
0x0000000f
2-
0x000000f0
3-
4-
0x00000003
5-
0x0000000c
6-
0x00000030
7-
0x000000c0
8-
91
0x00000001
102
0x00000002
113
0x00000004
@@ -16,112 +8,108 @@
168
0x00000080
179

1810
0x00000001
19-
0x00000001
20-
0x00000002
2111
0x00000002
2212
0x00000004
23-
0x00000004
2413
0x00000008
2514
0x00000010
26-
0x00000010
2715
0x00000020
2816
0x00000040
29-
0x00000040
3017
0x00000080
31-
32-
0x00000001
3318
0x00000001
3419
0x00000002
35-
0x00000002
3620
0x00000004
37-
0x00000004
38-
0x00000008
3921
0x00000008
4022
0x00000010
41-
0x00000010
42-
0x00000020
4323
0x00000020
4424
0x00000040
25+
0x00000080
26+
0x00000001
27+
0x00000002
28+
0x00000004
29+
0x00000008
30+
0x00000010
31+
0x00000020
4532
0x00000040
4633
0x00000080
34+
0x00000001
35+
0x00000002
36+
0x00000004
37+
0x00000008
38+
0x00000010
39+
0x00000020
40+
0x00000040
4741
0x00000080
4842

49-
0x00000007
50-
0x000001f8
51-
0x0003fe00
52-
0x07fc0000
53-
5443
0x00000001
44+
0x00000002
45+
0x00000004
5546
0x00000008
56-
0x00000200
57-
0x00040000
58-
59-
0x07000000
60-
0x00fc0000
61-
0x0003fe00
62-
0x000001ff
6347

6448
0x04000000
49+
0x02000000
50+
0x01000000
6551
0x00800000
66-
0x00020000
67-
0x00000100
6852

69-
0x000000ff
70-
0x0000ff00
53+
0
54+
1
55+
2
56+
3
7157

72-
0x00000001
73-
0x00000100
58+
0
59+
1
60+
2
61+
3
7462

75-
0x00008000
76-
0x00000080
63+
0x00000001
64+
0x00000002
65+
0x00000004
66+
0x00000008
7767

78-
0x000000ff
79-
0x0000ff00
80-
0xffff0000
81-
0x0000ffff,0x0
82-
0xffff0000,0x0
83-
0x000000ff,,0x0
84-
0x0000ff00,,0x0
85-
0xffff0000,,0x0
86-
0x0000ffff,,,0x0
87-
0xffff0000,,,0x0
88-
0x000000ff,,,,0x0
89-
0x0000ff00,,,,0x0
90-
0xffff0000,,,,0x0
91-
0x0000ffff,,,,,0x0
92-
0xffff0000,,,,,0x0
93-
0x0000ffff,,,,,,0x0
94-
0xffff0000,,,,,,0x0
95-
0x0000ffff,,,,,,,0x0
96-
0xffff0000,,,,,,,0x0
68+
0x00000001
69+
0x00000001,,0x0
70+
0x00000001,,,,0x0
71+
0x00000001,,,,,,0x0
72+
0x00000010
73+
0x00000010,,0x0
74+
0x00000010,,,,0x0
75+
0x00000010,,,,,,0x0
9776

9877
0x00000001
99-
0x00000002
100-
0x0000000c
101-
0x00000030
102-
0x000000c0
103-
0x00000300
104-
0x00000c00
105-
0x00003000
106-
0x0000c000
78+
0x00000001,,0x0
79+
0x00000001,,,,0x0
80+
0x00000001,,,,,,0x0
81+
0x00010000
82+
0x00010000,,0x0
83+
0x00010000,,,,0x0
84+
0x00010000,,,,,,0x0
85+
0x00000001,0x0
86+
0x00000001,,,0x0
87+
0x00000001,,,,,0x0
88+
0x00000001,,,,,,,0x0
89+
0x00010000,0x0
90+
0x00010000,,,0x0
91+
0x00010000,,,,,0x0
92+
0x00010000,,,,,,,0x0
93+
0x00000010
94+
0x00000010,,0x0
95+
0x00000010,,,,0x0
10796

10897
0x00000001
109-
0x00000006
110-
0x00000018
111-
0x00000060
98+
0x00000002
99+
0x00000004
100+
0x00000008
101+
0x00000010
102+
0x00000020
103+
0x00000040
112104
0x00000080
113-
0x00000300
114-
0x00000c00
115-
0x00003000
116-
0x0000c000
105+
0x00000100
117106

118-
0x00000003
119-
0x00000003
120-
0x0000000c
121-
0x00000030
122-
0x000000c0
123-
0x00000300
124-
0x00000c00
125-
0x00003000
126-
0x0000c000
107+
8
108+
196
109+
132
110+
68
111+
4
112+
192
113+
128
114+
64
127115

utils/hwloc/test-hwloc-distrib.sh.in

+12-23
Original file line numberDiff line numberDiff line change
@@ -35,38 +35,27 @@ file="$tmp/test-hwloc-distrib.output"
3535

3636
set -e
3737
(
38-
$distrib --if synthetic --input "2 2 2" 2
38+
$distrib pu --if synthetic --input "4 4 4 4" -n 8
3939
echo
40-
$distrib --if synthetic --input "2 2 2" 4
40+
$distrib pu --if synthetic --input "1 2 2 2" -n 32
4141
echo
42-
$distrib --if synthetic --input "2 2 2" 8
42+
$distrib pu --if synthetic --input "3 3 3" -n 4 --single
4343
echo
44-
$distrib --if synthetic --input "2 2 2" 13
44+
$distrib pu --if synthetic --input "3 3 3" -n 4 --reverse
4545
echo
46-
$distrib --if synthetic --input "2 2 2" 16
46+
$distrib pu --if synthetic --input "3 3 3" -n 4 --logical-index
4747
echo
48-
$distrib --if synthetic --input "3 3 3" 4
48+
$distrib pu --if synthetic --input "3 3 3" -n 4 --physical-index
4949
echo
50-
$distrib --if synthetic --input "3 3 3" 4 --single
50+
$distrib pu --if synthetic --input "3 3 3" -n 4 --from 0
5151
echo
52-
$distrib --if synthetic --input "3 3 3" 4 --reverse
52+
$distrib pu:core:package --if synthetic --input "4 4 4 4" -n 8
53+
echo
54+
$distrib scatter pu --if synthetic --input "4 4 4 4" -n 19
5355
echo
54-
$distrib --if synthetic --input "3 3 3" 4 --reverse --single
56+
$distrib round-robin pu --if synthetic --input "2 2 2 2" -n 9
5557
echo
56-
$distrib --if synthetic --input "4 4" 2
57-
echo
58-
$distrib --if synthetic --input "4 4" 2 --single
59-
echo
60-
$distrib --if synthetic --input "4 4" 2 --reverse --single
61-
echo
62-
$distrib --if synthetic --input "4 4 4 4" 19
63-
echo
64-
65-
$distrib --if synthetic --input "2 2 2 2" 9
66-
echo
67-
$distrib --if synthetic --input "2 2 2 2" --from pu 9
68-
echo
69-
$distrib --if synthetic --input "2 2 2 2" --to core 9
58+
$distrib pu:core:package --if synthetic --input "4 4 4 4" -n 8 --logical-index --single --reverse --from 8
7059
echo
7160
) > "$file"
7261
@DIFF@ @HWLOC_DIFF_U@ @HWLOC_DIFF_W@ $srcdir/test-hwloc-distrib.output "$file"

0 commit comments

Comments
 (0)