5
5
* See COPYING in top-level directory.
6
6
****************************************************************************/
7
7
8
+ #include <time.h>
9
+ #include <stdlib.h>
8
10
#include "private/autogen/config.h"
9
11
#include "hwloc.h"
10
12
11
- #ifdef HWLOC_WIN_SYS
12
- #include <windows.h>
13
- #endif
14
-
15
13
struct hwloc_distrib_level {
16
14
hwloc_obj_type_t type ; // level type.
17
15
unsigned depth ; // level depth.
18
- size_t user_index ; // Index of this level as provided by user order.
19
- size_t arity ; // Number of children of this level below parent.
20
- size_t coord ; // The current level object index [0..arity[.
16
+ unsigned user_index ; // Index of this level as provided by user order.
17
+ unsigned arity ; // Number of children of this level below parent.
18
+ unsigned coord ; // The current level object index [0..arity[.
21
19
// Iteration order of this level objects. index[coord] give logical_index below parent.
22
- size_t * index ;
20
+ unsigned * index ;
23
21
};
24
22
25
23
struct hwloc_distrib_iterator {
26
24
hwloc_obj_t * roots ;
27
- size_t n_roots ;
28
- size_t root_coord ;
25
+ unsigned n_roots ;
26
+ unsigned root_coord ;
29
27
struct hwloc_distrib_level * * levels ; // n_roots * n_levels
30
- size_t n_levels ;
28
+ unsigned n_levels ;
31
29
};
32
30
33
- static size_t * range (const size_t n ){
34
- size_t i ,* r = malloc (n * sizeof (* r ));
31
+ static unsigned * range (const unsigned n ){
32
+ unsigned i ,* r = malloc (n * sizeof (* r ));
35
33
36
34
if (r == NULL )
37
35
return NULL ;
@@ -40,17 +38,17 @@ static size_t* range(const size_t n){
40
38
return r ;
41
39
}
42
40
43
- static size_t * reversed_range (const size_t n ){
44
- size_t i ,* r = malloc (n * sizeof (* r ));
41
+ static unsigned * reversed_range (const unsigned n ){
42
+ unsigned i ,* r = malloc (n * sizeof (* r ));
45
43
46
44
if (r == NULL )
47
45
return NULL ;
48
46
for (i = 0 ; i < n ; i ++ ){ r [i ] = n - i - 1 ; }
49
47
return r ;
50
48
}
51
49
52
- static size_t * shuffled_range (const size_t n ){
53
- size_t i , * index , * ret , val ;
50
+ static unsigned * shuffled_range (const unsigned n ){
51
+ unsigned i , * index , * ret , val ;
54
52
55
53
if ((index = range (n )) == NULL )
56
54
return NULL ;
@@ -95,10 +93,10 @@ static struct hwloc_distrib_level *
95
93
hwloc_distrib_root_levels (hwloc_topology_t topology ,
96
94
const hwloc_obj_t root ,
97
95
const hwloc_obj_type_t * types ,
98
- const size_t n_types ,
96
+ const unsigned n_types ,
99
97
const unsigned long flags )
100
98
{
101
- size_t i ;
99
+ unsigned i ;
102
100
struct hwloc_distrib_level * levels = malloc (n_types * sizeof (* levels ));
103
101
if (levels == NULL )
104
102
return NULL ;
@@ -124,7 +122,7 @@ hwloc_distrib_root_levels(hwloc_topology_t topology,
124
122
hwloc_distrib_level_cmp_depth );
125
123
126
124
// Walk from top to bottom and set arity to the maximum arity below root field.
127
- size_t arity ;
125
+ unsigned arity ;
128
126
hwloc_obj_t parent = root ;
129
127
130
128
for (i = 0 ; i < n_types ; i ++ ){
@@ -184,11 +182,11 @@ static void hwloc_distrib_destroy_level(struct hwloc_distrib_level *levels){
184
182
struct hwloc_distrib_iterator *
185
183
hwloc_distrib_build_iterator (hwloc_topology_t topology ,
186
184
hwloc_obj_t * roots ,
187
- const size_t n_roots ,
185
+ const unsigned n_roots ,
188
186
const hwloc_obj_type_t * levels ,
189
- const size_t n_levels ,
187
+ const unsigned n_levels ,
190
188
const unsigned long flags ){
191
- size_t i ;
189
+ unsigned i ;
192
190
struct hwloc_distrib_iterator * it = malloc (sizeof (* it ) +
193
191
sizeof (* it -> levels ) * n_roots );
194
192
if (it == NULL )
@@ -245,7 +243,7 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
245
243
const hwloc_obj_type_t type ,
246
244
const unsigned long flags ){
247
245
248
- size_t i = 0 , n = 0 ;
246
+ unsigned i = 0 , n = 0 ;
249
247
hwloc_obj_t obj , root = hwloc_get_obj_by_depth (topology , 0 , 0 );
250
248
251
249
// Count depths with a non empty cpuset.
@@ -297,7 +295,7 @@ hwloc_distrib_iterator_scatter(hwloc_topology_t topology,
297
295
}
298
296
299
297
void hwloc_distrib_destroy_iterator (struct hwloc_distrib_iterator * it ){
300
- size_t i ;
298
+ unsigned i ;
301
299
302
300
for (i = 0 ; i < it -> n_roots ; i ++ )
303
301
hwloc_distrib_destroy_level (it -> levels [i ]);
@@ -340,10 +338,10 @@ int
340
338
hwloc_distrib_iterator_next (hwloc_topology_t topology ,
341
339
struct hwloc_distrib_iterator * it ,
342
340
hwloc_obj_t * next ){
343
- size_t i ;
341
+ unsigned i ;
344
342
struct hwloc_distrib_level * levels = it -> levels [it -> root_coord ];
345
343
hwloc_obj_t obj = it -> roots [it -> root_coord ];
346
- size_t coord ;
344
+ unsigned coord ;
347
345
348
346
// Sort by depth to walk objects at set coordinates.
349
347
qsort (levels ,
0 commit comments