File tree Expand file tree Collapse file tree 5 files changed +37
-0
lines changed Expand file tree Collapse file tree 5 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -466,6 +466,7 @@ man3_tinker_DATA = \
466
466
$(DOX_MAN_DIR ) /man3/hwloc_topology_allow.3 \
467
467
$(DOX_MAN_DIR ) /man3/hwloc_topology_insert_misc_object.3 \
468
468
$(DOX_MAN_DIR ) /man3/hwloc_topology_alloc_group_object.3 \
469
+ $(DOX_MAN_DIR ) /man3/hwloc_topology_free_group_object.3 \
469
470
$(DOX_MAN_DIR ) /man3/hwloc_topology_insert_group_object.3 \
470
471
$(DOX_MAN_DIR ) /man3/hwloc_obj_add_other_obj_sets.3 \
471
472
$(DOX_MAN_DIR ) /man3/hwloc_topology_refresh.3
Original file line number Diff line number Diff line change @@ -2031,6 +2031,22 @@ hwloc_topology_alloc_group_object(struct hwloc_topology *topology)
2031
2031
return hwloc_alloc_setup_object (topology , HWLOC_OBJ_GROUP , HWLOC_UNKNOWN_INDEX );
2032
2032
}
2033
2033
2034
+ int
2035
+ hwloc_topology_free_group_object (struct hwloc_topology * topology , hwloc_obj_t obj )
2036
+ {
2037
+ if (!(topology -> state & HWLOC_TOPOLOGY_STATE_IS_LOADED )) {
2038
+ /* this could actually work when IS_LOADING, see insert() below */
2039
+ errno = EINVAL ;
2040
+ return -1 ;
2041
+ }
2042
+ if (topology -> adopted_shmem_addr ) {
2043
+ errno = EPERM ;
2044
+ return -1 ;
2045
+ }
2046
+ hwloc_free_unlinked_object (obj );
2047
+ return 0 ;
2048
+ }
2049
+
2034
2050
static void hwloc_propagate_symmetric_subtree (hwloc_topology_t topology , hwloc_obj_t root );
2035
2051
static void propagate_total_memory (hwloc_obj_t obj );
2036
2052
static void hwloc_set_group_depth (hwloc_topology_t topology );
Original file line number Diff line number Diff line change @@ -2801,6 +2801,19 @@ HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_insert_misc_object(hwloc_topology_t to
2801
2801
*/
2802
2802
HWLOC_DECLSPEC hwloc_obj_t hwloc_topology_alloc_group_object (hwloc_topology_t topology );
2803
2803
2804
+ /** \brief Free a group object allocated with hwloc_topology_alloc_group_object().
2805
+ *
2806
+ * This function is only useful if the group object was not given
2807
+ * to hwloc_topology_insert_group_object() as planned.
2808
+ *
2809
+ * \note \p topology must be the same as the one previously passed
2810
+ * to hwloc_topology_alloc_group_object().
2811
+ *
2812
+ * \return \c 0 on success.
2813
+ * \return \c -1 on error, for instance if an invalid topology is given.
2814
+ */
2815
+ HWLOC_DECLSPEC int hwloc_topology_free_group_object (hwloc_topology_t topology , hwloc_obj_t group );
2816
+
2804
2817
/** \brief Add more structure to the topology by adding an intermediate Group
2805
2818
*
2806
2819
* The caller should first allocate a new Group object with hwloc_topology_alloc_group_object().
Original file line number Diff line number Diff line change @@ -178,6 +178,7 @@ extern "C" {
178
178
179
179
#define hwloc_topology_insert_misc_object HWLOC_NAME(topology_insert_misc_object)
180
180
#define hwloc_topology_alloc_group_object HWLOC_NAME(topology_alloc_group_object)
181
+ #define hwloc_topology_free_group_object HWLOC_NAME(topology_free_group_object)
181
182
#define hwloc_topology_insert_group_object HWLOC_NAME(topology_insert_group_object)
182
183
#define hwloc_obj_add_other_obj_sets HWLOC_NAME(obj_add_other_obj_sets)
183
184
#define hwloc_topology_refresh HWLOC_NAME(topology_refresh)
Original file line number Diff line number Diff line change @@ -31,6 +31,12 @@ int main(void)
31
31
hwloc_topology_load (topology );
32
32
root = hwloc_get_root_obj (topology );
33
33
assert (hwloc_topology_get_depth (topology ) == 3 );
34
+ /* free instead of inserting */
35
+ group = hwloc_topology_alloc_group_object (topology );
36
+ assert (group );
37
+ group -> cpuset = hwloc_bitmap_dup (root -> cpuset );
38
+ err = hwloc_topology_free_group_object (topology , group );
39
+ assert (err == 0 );
34
40
/* insert without sets, fails */
35
41
group = hwloc_topology_alloc_group_object (topology );
36
42
assert (group );
You can’t perform that action at this time.
0 commit comments