1
1
/*
2
- * Copyright © 2020-2022 Inria. All rights reserved.
2
+ * Copyright © 2020-2023 Inria. All rights reserved.
3
3
* See COPYING in top-level directory.
4
4
*/
5
5
@@ -28,7 +28,7 @@ hwloc_internal_cpukinds_destroy(struct hwloc_topology *topology)
28
28
for (i = 0 ; i < topology -> nr_cpukinds ; i ++ ) {
29
29
struct hwloc_internal_cpukind_s * kind = & topology -> cpukinds [i ];
30
30
hwloc_bitmap_free (kind -> cpuset );
31
- hwloc__free_infos (kind -> infos , kind -> nr_infos );
31
+ hwloc__free_infos (& kind -> infos );
32
32
}
33
33
free (topology -> cpukinds );
34
34
topology -> cpukinds = NULL ;
@@ -59,8 +59,8 @@ hwloc_internal_cpukinds_dup(hwloc_topology_t new, hwloc_topology_t old)
59
59
goto failed ;
60
60
}
61
61
if (hwloc__tma_dup_infos (tma ,
62
- & kinds [i ].infos , & kinds [ i ]. nr_infos ,
63
- old -> cpukinds [i ].infos , old -> cpukinds [ i ]. nr_infos ) < 0 ) {
62
+ & kinds [i ].infos ,
63
+ & old -> cpukinds [i ].infos ) < 0 ) {
64
64
assert (!tma || !tma -> dontfree ); /* this tma cannot fail to allocate */
65
65
hwloc_bitmap_free (kinds [i ].cpuset );
66
66
new -> nr_cpukinds = i ;
@@ -85,7 +85,7 @@ hwloc_internal_cpukinds_restrict(hwloc_topology_t topology)
85
85
hwloc_bitmap_and (kind -> cpuset , kind -> cpuset , hwloc_get_root_obj (topology )-> cpuset );
86
86
if (hwloc_bitmap_iszero (kind -> cpuset )) {
87
87
hwloc_bitmap_free (kind -> cpuset );
88
- hwloc__free_infos (kind -> infos , kind -> nr_infos );
88
+ hwloc__free_infos (& kind -> infos );
89
89
memmove (kind , kind + 1 , (topology -> nr_cpukinds - i - 1 )* sizeof (* kind ));
90
90
i -- ;
91
91
topology -> nr_cpukinds -- ;
@@ -106,29 +106,29 @@ hwloc__cpukind_check_duplicate_info(struct hwloc_internal_cpukind_s *kind,
106
106
const char * name , const char * value )
107
107
{
108
108
unsigned i ;
109
- for (i = 0 ; i < kind -> nr_infos ; i ++ )
110
- if (!strcmp (kind -> infos [i ].name , name )
111
- && !strcmp (kind -> infos [i ].value , value ))
109
+ for (i = 0 ; i < kind -> infos . count ; i ++ )
110
+ if (!strcmp (kind -> infos . array [i ].name , name )
111
+ && !strcmp (kind -> infos . array [i ].value , value ))
112
112
return 1 ;
113
113
return 0 ;
114
114
}
115
115
116
116
static __hwloc_inline void
117
117
hwloc__cpukind_add_infos (struct hwloc_internal_cpukind_s * kind ,
118
- const struct hwloc_info_s * infos , unsigned nr_infos )
118
+ const struct hwloc_infos_s * infos )
119
119
{
120
120
unsigned i ;
121
- for (i = 0 ; i < nr_infos ; i ++ ) {
122
- if (hwloc__cpukind_check_duplicate_info (kind , infos [i ].name , infos [i ].value ))
121
+ for (i = 0 ; i < infos -> count ; i ++ ) {
122
+ if (hwloc__cpukind_check_duplicate_info (kind , infos -> array [i ].name , infos -> array [i ].value ))
123
123
continue ;
124
- hwloc__add_info (& kind -> infos , & kind -> nr_infos , infos [i ].name , infos [i ].value );
124
+ hwloc__add_info (& kind -> infos , infos -> array [i ].name , infos -> array [i ].value );
125
125
}
126
126
}
127
127
128
128
int
129
129
hwloc_internal_cpukinds_register (hwloc_topology_t topology , hwloc_cpuset_t cpuset ,
130
130
int forced_efficiency ,
131
- const struct hwloc_info_s * infos , unsigned nr_infos ,
131
+ const struct hwloc_infos_s * infos ,
132
132
unsigned long flags )
133
133
{
134
134
struct hwloc_internal_cpukind_s * kinds ;
@@ -184,8 +184,9 @@ hwloc_internal_cpukinds_register(hwloc_topology_t topology, hwloc_cpuset_t cpuse
184
184
kinds [newnr ].efficiency = HWLOC_CPUKIND_EFFICIENCY_UNKNOWN ;
185
185
kinds [newnr ].forced_efficiency = forced_efficiency ;
186
186
hwloc_bitmap_and (kinds [newnr ].cpuset , cpuset , kinds [i ].cpuset );
187
- hwloc__cpukind_add_infos (& kinds [newnr ], kinds [i ].infos , kinds [i ].nr_infos );
188
- hwloc__cpukind_add_infos (& kinds [newnr ], infos , nr_infos );
187
+ hwloc__cpukind_add_infos (& kinds [newnr ], & kinds [i ].infos );
188
+ if (infos )
189
+ hwloc__cpukind_add_infos (& kinds [newnr ], infos );
189
190
/* remove cpuset PUs from the existing kind that we just split */
190
191
hwloc_bitmap_andnot (kinds [i ].cpuset , kinds [i ].cpuset , kinds [newnr ].cpuset );
191
192
/* clear cpuset PUs that were taken care of */
@@ -196,7 +197,8 @@ hwloc_internal_cpukinds_register(hwloc_topology_t topology, hwloc_cpuset_t cpuse
196
197
} else if (res == HWLOC_BITMAP_CONTAINS
197
198
|| res == HWLOC_BITMAP_EQUAL ) {
198
199
/* append new info to existing smaller (or equal) kind */
199
- hwloc__cpukind_add_infos (& kinds [i ], infos , nr_infos );
200
+ if (infos )
201
+ hwloc__cpukind_add_infos (& kinds [i ], infos );
200
202
if ((flags & HWLOC_CPUKINDS_REGISTER_FLAG_OVERWRITE_FORCED_EFFICIENCY )
201
203
|| kinds [i ].forced_efficiency == HWLOC_CPUKIND_EFFICIENCY_UNKNOWN )
202
204
kinds [i ].forced_efficiency = forced_efficiency ;
@@ -218,7 +220,8 @@ hwloc_internal_cpukinds_register(hwloc_topology_t topology, hwloc_cpuset_t cpuse
218
220
kinds [newnr ].cpuset = cpuset ;
219
221
kinds [newnr ].efficiency = HWLOC_CPUKIND_EFFICIENCY_UNKNOWN ;
220
222
kinds [newnr ].forced_efficiency = forced_efficiency ;
221
- hwloc__cpukind_add_infos (& kinds [newnr ], infos , nr_infos );
223
+ if (infos )
224
+ hwloc__cpukind_add_infos (& kinds [newnr ], infos );
222
225
newnr ++ ;
223
226
} else {
224
227
hwloc_bitmap_free (cpuset );
@@ -231,7 +234,7 @@ hwloc_internal_cpukinds_register(hwloc_topology_t topology, hwloc_cpuset_t cpuse
231
234
int
232
235
hwloc_cpukinds_register (hwloc_topology_t topology , hwloc_cpuset_t _cpuset ,
233
236
int forced_efficiency ,
234
- unsigned nr_infos , struct hwloc_info_s * infos ,
237
+ struct hwloc_infos_s * infos ,
235
238
unsigned long flags )
236
239
{
237
240
hwloc_bitmap_t cpuset ;
@@ -254,7 +257,7 @@ hwloc_cpukinds_register(hwloc_topology_t topology, hwloc_cpuset_t _cpuset,
254
257
if (forced_efficiency < 0 )
255
258
forced_efficiency = HWLOC_CPUKIND_EFFICIENCY_UNKNOWN ;
256
259
257
- err = hwloc_internal_cpukinds_register (topology , cpuset , forced_efficiency , infos , nr_infos , HWLOC_CPUKINDS_REGISTER_FLAG_OVERWRITE_FORCED_EFFICIENCY );
260
+ err = hwloc_internal_cpukinds_register (topology , cpuset , forced_efficiency , infos , HWLOC_CPUKINDS_REGISTER_FLAG_OVERWRITE_FORCED_EFFICIENCY );
258
261
if (err < 0 )
259
262
return err ;
260
263
@@ -317,8 +320,8 @@ hwloc__cpukinds_summarize_info(struct hwloc_topology *topology,
317
320
318
321
for (i = 0 ; i < topology -> nr_cpukinds ; i ++ ) {
319
322
struct hwloc_internal_cpukind_s * kind = & topology -> cpukinds [i ];
320
- for (j = 0 ; j < kind -> nr_infos ; j ++ ) {
321
- struct hwloc_info_s * info = & kind -> infos [j ];
323
+ for (j = 0 ; j < kind -> infos . count ; j ++ ) {
324
+ struct hwloc_info_s * info = & kind -> infos . array [j ];
322
325
if (!strcmp (info -> name , "FrequencyMaxMHz" )) {
323
326
summary -> summaries [i ].max_freq = atoi (info -> value );
324
327
} else if (!strcmp (info -> name , "FrequencyBaseMHz" )) {
@@ -598,7 +601,7 @@ hwloc_cpukinds_get_info(hwloc_topology_t topology,
598
601
unsigned id ,
599
602
hwloc_bitmap_t cpuset ,
600
603
int * efficiencyp ,
601
- unsigned * nr_infosp , struct hwloc_info_s * * infosp ,
604
+ struct hwloc_infos_s * * infosp ,
602
605
unsigned long flags )
603
606
{
604
607
struct hwloc_internal_cpukind_s * kind ;
@@ -621,10 +624,8 @@ hwloc_cpukinds_get_info(hwloc_topology_t topology,
621
624
if (efficiencyp )
622
625
* efficiencyp = kind -> efficiency ;
623
626
624
- if (nr_infosp && infosp ) {
625
- * nr_infosp = kind -> nr_infos ;
626
- * infosp = kind -> infos ;
627
- }
627
+ if (infosp )
628
+ * infosp = & kind -> infos ;
628
629
return 0 ;
629
630
}
630
631
0 commit comments