Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
Signed-off-by: ndenoyelle <[email protected]>
  • Loading branch information
ndenoyelle committed Oct 22, 2019
1 parent e02c5ae commit 4d1d25a
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 114 deletions.
14 changes: 9 additions & 5 deletions hwloc/distrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ static size_t* shuffled_range(const size_t n){
if ((ret = malloc(n*sizeof(*ret))) == NULL) { free(index); return NULL; }

srand(time(NULL));
for(i=n-1;i>=0;i--){
val = rand()%(i+1);
ret[i] = index[val];
index[val] = index[i];
for(i=n;i>0;i--){
val = rand()%(i);
ret[i-1] = index[val];
index[val] = index[i-1];
}
free(index);
return ret;
Expand Down Expand Up @@ -233,6 +233,8 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
if ((obj->cpuset != NULL && !hwloc_bitmap_iszero(obj->cpuset)) &&
hwloc_get_type_depth(topology, obj->type) >= 0)
n++;
if (obj->type == type)
break;
obj = obj->first_child;
}

Expand All @@ -245,6 +247,8 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
levels[n-1-i] = obj->type;
i++;
}
if (obj->type == type)
break;
obj = obj->first_child;
}

Expand All @@ -257,7 +261,7 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
*it->roots = root;
it->n_roots = 1;
it->root_coord = 0;
it->n_levels = 1;
it->n_levels = n;
it->levels = (struct hwloc_distrib_level **)((char*)it +
sizeof(*it) +
sizeof(hwloc_obj_t));
Expand Down
7 changes: 4 additions & 3 deletions tests/hwloc/hwloc_distrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static void test_scatter(hwloc_topology_t topology)
if ( !is_tleaf(topology) )
return;

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

Expand Down Expand Up @@ -172,12 +172,13 @@ static void test_scatter(hwloc_topology_t topology)
item = obj;
goto next_level;
}


n_levels=n;
for (i = 0; hwloc_distrib_iterator_next(topology, it, &item); i++) {
c = i;
n = nleaves;
val = 0;
for (j = (n-2); j >= 0; j--) {
for (j = (n_levels-1); j > 0; j--) {
r = c % arities[j];
n = n / arities[j];
c = c / arities[j];
Expand Down
154 changes: 71 additions & 83 deletions utils/hwloc/test-hwloc-distrib.output
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
0x0000000f
0x000000f0

0x00000003
0x0000000c
0x00000030
0x000000c0

0x00000001
0x00000002
0x00000004
Expand All @@ -16,112 +8,108 @@
0x00000080

0x00000001
0x00000001
0x00000002
0x00000002
0x00000004
0x00000004
0x00000008
0x00000010
0x00000010
0x00000020
0x00000040
0x00000040
0x00000080

0x00000001
0x00000001
0x00000002
0x00000002
0x00000004
0x00000004
0x00000008
0x00000008
0x00000010
0x00000010
0x00000020
0x00000020
0x00000040
0x00000080
0x00000001
0x00000002
0x00000004
0x00000008
0x00000010
0x00000020
0x00000040
0x00000080
0x00000001
0x00000002
0x00000004
0x00000008
0x00000010
0x00000020
0x00000040
0x00000080

0x00000007
0x000001f8
0x0003fe00
0x07fc0000

0x00000001
0x00000002
0x00000004
0x00000008
0x00000200
0x00040000

0x07000000
0x00fc0000
0x0003fe00
0x000001ff

0x04000000
0x02000000
0x01000000
0x00800000
0x00020000
0x00000100

0x000000ff
0x0000ff00
0
1
2
3

0x00000001
0x00000100
0
1
2
3

0x00008000
0x00000080
0x00000001
0x00000002
0x00000004
0x00000008

0x000000ff
0x0000ff00
0xffff0000
0x0000ffff,0x0
0xffff0000,0x0
0x000000ff,,0x0
0x0000ff00,,0x0
0xffff0000,,0x0
0x0000ffff,,,0x0
0xffff0000,,,0x0
0x000000ff,,,,0x0
0x0000ff00,,,,0x0
0xffff0000,,,,0x0
0x0000ffff,,,,,0x0
0xffff0000,,,,,0x0
0x0000ffff,,,,,,0x0
0xffff0000,,,,,,0x0
0x0000ffff,,,,,,,0x0
0xffff0000,,,,,,,0x0
0x00000001
0x00000001,,0x0
0x00000001,,,,0x0
0x00000001,,,,,,0x0
0x00000010
0x00000010,,0x0
0x00000010,,,,0x0
0x00000010,,,,,,0x0

0x00000001
0x00000002
0x0000000c
0x00000030
0x000000c0
0x00000300
0x00000c00
0x00003000
0x0000c000
0x00000001,,0x0
0x00000001,,,,0x0
0x00000001,,,,,,0x0
0x00010000
0x00010000,,0x0
0x00010000,,,,0x0
0x00010000,,,,,,0x0
0x00000001,0x0
0x00000001,,,0x0
0x00000001,,,,,0x0
0x00000001,,,,,,,0x0
0x00010000,0x0
0x00010000,,,0x0
0x00010000,,,,,0x0
0x00010000,,,,,,,0x0
0x00000010
0x00000010,,0x0
0x00000010,,,,0x0

0x00000001
0x00000006
0x00000018
0x00000060
0x00000002
0x00000004
0x00000008
0x00000010
0x00000020
0x00000040
0x00000080
0x00000300
0x00000c00
0x00003000
0x0000c000
0x00000100

0x00000003
0x00000003
0x0000000c
0x00000030
0x000000c0
0x00000300
0x00000c00
0x00003000
0x0000c000
8
196
132
68
4
192
128
64

35 changes: 12 additions & 23 deletions utils/hwloc/test-hwloc-distrib.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,27 @@ file="$tmp/test-hwloc-distrib.output"

set -e
(
$distrib --if synthetic --input "2 2 2" 2
$distrib pu --if synthetic --input "4 4 4 4" -n 8
echo
$distrib --if synthetic --input "2 2 2" 4
$distrib pu --if synthetic --input "1 2 2 2" -n 32
echo
$distrib --if synthetic --input "2 2 2" 8
$distrib pu --if synthetic --input "3 3 3" -n 4 --single
echo
$distrib --if synthetic --input "2 2 2" 13
$distrib pu --if synthetic --input "3 3 3" -n 4 --reverse
echo
$distrib --if synthetic --input "2 2 2" 16
$distrib pu --if synthetic --input "3 3 3" -n 4 --logical-index
echo
$distrib --if synthetic --input "3 3 3" 4
$distrib pu --if synthetic --input "3 3 3" -n 4 --physical-index
echo
$distrib --if synthetic --input "3 3 3" 4 --single
$distrib pu --if synthetic --input "3 3 3" -n 4 --from 0
echo
$distrib --if synthetic --input "3 3 3" 4 --reverse
$distrib pu:core:package --if synthetic --input "4 4 4 4" -n 8
echo
$distrib scatter pu --if synthetic --input "4 4 4 4" -n 19
echo
$distrib --if synthetic --input "3 3 3" 4 --reverse --single
$distrib round-robin pu --if synthetic --input "2 2 2 2" -n 9
echo
$distrib --if synthetic --input "4 4" 2
echo
$distrib --if synthetic --input "4 4" 2 --single
echo
$distrib --if synthetic --input "4 4" 2 --reverse --single
echo
$distrib --if synthetic --input "4 4 4 4" 19
echo

$distrib --if synthetic --input "2 2 2 2" 9
echo
$distrib --if synthetic --input "2 2 2 2" --from pu 9
echo
$distrib --if synthetic --input "2 2 2 2" --to core 9
$distrib pu:core:package --if synthetic --input "4 4 4 4" -n 8 --logical-index --single --reverse --from 8
echo
) > "$file"
@DIFF@ @HWLOC_DIFF_U@ @HWLOC_DIFF_W@ $srcdir/test-hwloc-distrib.output "$file"
Expand Down

0 comments on commit 4d1d25a

Please sign in to comment.