From 086d45a5b718ae84adb5b777828f871d1ff7bccb Mon Sep 17 00:00:00 2001 From: Brice Goglin Date: Thu, 13 Feb 2014 12:34:51 +0100 Subject: [PATCH] plugins: cleanup hwloc_setup_pu_level() and export it to plugins Xen will need it. --- NEWS | 3 ++- include/hwloc/plugins.h | 6 ++++++ include/hwloc/rename.h | 2 +- include/private/private.h | 1 - src/topology.c | 17 ++++++++--------- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index 6697a767..2c04446a 100644 --- a/NEWS +++ b/NEWS @@ -32,7 +32,8 @@ Version 1.9.0 + The synthetic backend now accepts extended types such as L2Cache, L1i or Group3. lstopo also exports synthetic strings using these extended types. * Plugins - + Add the new hwloc_alloc_root_sets() function for plugins that discover CPUs. + + Add hwloc_alloc_root_sets() and hwloc_setup_pu_level() functions for + plugins that discover CPUs. * Tools + Add -e or --get-last-cpu-location to hwloc-ps to report where processes/threads run instead of where they are bound. diff --git a/include/hwloc/plugins.h b/include/hwloc/plugins.h index 9bdc3cb5..656a74c9 100644 --- a/include/hwloc/plugins.h +++ b/include/hwloc/plugins.h @@ -311,6 +311,12 @@ HWLOC_DECLSPEC int hwloc_fill_object_sets(hwloc_obj_t obj); */ HWLOC_DECLSPEC int hwloc_alloc_root_sets(struct hwloc_topology *topology); +/** \brief Create a level of \p nb PU objects starting from index 0. + * + * Used for creating PU objects when there are no holes in the index list. + */ +HWLOC_DECLSPEC int hwloc_setup_pu_level(struct hwloc_topology *topology, unsigned nb); + /** \brief Make sure that plugins can lookup core symbols. * * This is a sanity check to avoid lazy-lookup failures when libhwloc diff --git a/include/hwloc/rename.h b/include/hwloc/rename.h index 300c3693..f383a557 100644 --- a/include/hwloc/rename.h +++ b/include/hwloc/rename.h @@ -486,6 +486,7 @@ extern "C" { #define hwloc_alloc_setup_object HWLOC_NAME(alloc_setup_object) #define hwloc_fill_object_sets HWLOC_NAME(fill_object_sets) #define hwloc_alloc_root_sets HWLOC_NAME(alloc_root_sets) +#define hwloc_setup_pu_level HWLOC_NAME(setup_pu_level) #define hwloc_insert_pci_device_list HWLOC_NAME(insert_pci_device_list) #define hwloc_pci_find_cap HWLOC_NAME(pci_find_cap) @@ -565,7 +566,6 @@ extern "C" { #define hwloc_xml_imported_distances_s HWLOC_NAME(xml_imported_distances_s) -#define hwloc_setup_pu_level HWLOC_NAME(setup_pu_level) #define hwloc_get_sysctlbyname HWLOC_NAME(get_sysctlbyname) #define hwloc_get_sysctl HWLOC_NAME(get_sysctl) #define hwloc_fallback_nbprocessors HWLOC_NAME(fallback_nbprocessors) diff --git a/include/private/private.h b/include/private/private.h index f037c5a9..939b6e0c 100644 --- a/include/private/private.h +++ b/include/private/private.h @@ -128,7 +128,6 @@ struct hwloc_topology { struct hwloc_backend * backends; }; -extern void hwloc_setup_pu_level(struct hwloc_topology *topology, unsigned nb_pus); extern int hwloc_get_sysctlbyname(const char *name, int64_t *n); extern int hwloc_get_sysctl(int name[], unsigned namelen, int *n); extern unsigned hwloc_fallback_nbprocessors(struct hwloc_topology *topology); diff --git a/src/topology.c b/src/topology.c index 5f45e36a..c505d93e 100644 --- a/src/topology.c +++ b/src/topology.c @@ -174,29 +174,28 @@ hwloc_fallback_nbprocessors(struct hwloc_topology *topology) { } /* - * Use the given number of processors and the optional online cpuset if given - * to set a PU level. + * Use the given number of processors to set a PU level. */ -void +int hwloc_setup_pu_level(struct hwloc_topology *topology, unsigned nb_pus) { struct hwloc_obj *obj; - unsigned oscpu,cpu; + unsigned oscpu; hwloc_debug("%s", "\n\n * CPU cpusets *\n\n"); - for (cpu=0,oscpu=0; cpucpuset = hwloc_bitmap_alloc(); hwloc_bitmap_only(obj->cpuset, oscpu); - hwloc_debug_2args_bitmap("cpu %u (os %u) has cpuset %s\n", - cpu, oscpu, obj->cpuset); + hwloc_debug_1arg_bitmap("OS cpu %u has cpuset %s\n", + oscpu, obj->cpuset); hwloc_insert_object_by_cpuset(topology, obj); - - cpu++; } + + return 0; } static void -- 2.39.5