From 02cb04b914b090a27ecc611a50156486084aa463 Mon Sep 17 00:00:00 2001 From: anindex Date: Fri, 31 Jan 2020 14:54:05 +0100 Subject: [PATCH 1/4] Add sockets (packages) number query using hwloc, fix likwid compiling issue --- dart-if/include/dash/dart/if/dart_types.h | 2 + dart-impl/base/src/hwinfo.c | 67 +++++++++++++---------- 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/dart-if/include/dash/dart/if/dart_types.h b/dart-if/include/dash/dart/if/dart_types.h index 0887edae1..6c32d098d 100644 --- a/dart-if/include/dash/dart/if/dart_types.h +++ b/dart-if/include/dash/dart/if/dart_types.h @@ -376,6 +376,8 @@ typedef struct int numa_id; + int num_sockets; + /** The unit's affine core, unique identifier within a processing * module. */ int core_id; diff --git a/dart-impl/base/src/hwinfo.c b/dart-impl/base/src/hwinfo.c index 73f543d1e..95402c1b8 100644 --- a/dart-impl/base/src/hwinfo.c +++ b/dart-impl/base/src/hwinfo.c @@ -91,6 +91,7 @@ static const int BYTES_PER_MB = (1024 * 1024); dart_ret_t dart_hwinfo_init( dart_hwinfo_t * hw) { + hw->num_sockets = -1; hw->num_numa = -1; hw->numa_id = -1; hw->num_cores = -1; @@ -150,36 +151,6 @@ dart_ret_t dart_hwinfo( hw.host[DART_LOCALITY_HOST_MAX_SIZE-1] = '\0'; } -#ifdef DART_ENABLE_LIKWID - DART_LOG_TRACE("dart_hwinfo: using likwid"); - /* - * see likwid API documentation: - * https://rrze-hpc.github.io/likwid/Doxygen/C-likwidAPI-code.html - */ - int likwid_ret = topology_init(); - if (likwid_ret < 0) { - DART_LOG_ERROR("dart_hwinfo: " - "likwid: topology_init failed, returned %d", likwid_ret); - } else { - CpuInfo_t info = get_cpuInfo(); - CpuTopology_t topo = get_cpuTopology(); - if (hw.min_cpu_mhz < 0 || hw.max_cpu_mhz < 0) { - hw.min_cpu_mhz = info->clock; - hw.max_cpu_mhz = info->clock; - } - if (hw.num_numa < 0) { - hw.num_numa = hw.num_sockets; - } - if (hw.num_cores < 0) { - hw.num_cores = topo->numCoresPerSocket * hw.num_sockets; - } - topology_finalize(); - DART_LOG_TRACE("dart_hwinfo: likwid: " - "num_sockets: %d num_numa: %d num_cores: %d", - hw.num_sockets, hw.num_numa, hw.num_cores); - } -#endif /* DART_ENABLE_LIKWID */ - #ifdef DART_ENABLE_HWLOC DART_LOG_TRACE("dart_hwinfo: using hwloc"); @@ -317,6 +288,12 @@ dart_ret_t dart_hwinfo( hw.num_numa = n_numa_nodes; } } + if (hw.num_sockets < 0) { + int n_sockets = hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_PACKAGE); + if (n_sockets > 0) { + hw.num_sockets = n_sockets; + } + } if (hw.num_cores < 0) { int n_cores = hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_CORE); if (n_cores > 0) { @@ -354,6 +331,36 @@ dart_ret_t dart_hwinfo( hw.num_cores, hw.core_id, hw.cpu_id); #endif /* DART_ENABLE_HWLOC */ +#ifdef DART_ENABLE_LIKWID + DART_LOG_TRACE("dart_hwinfo: using likwid"); + /* + * see likwid API documentation: + * https://rrze-hpc.github.io/likwid/Doxygen/C-likwidAPI-code.html + */ + int likwid_ret = topology_init(); + if (likwid_ret < 0) { + DART_LOG_ERROR("dart_hwinfo: " + "likwid: topology_init failed, returned %d", likwid_ret); + } else { + CpuInfo_t info = get_cpuInfo(); + CpuTopology_t topo = get_cpuTopology(); + if (hw.min_cpu_mhz < 0 || hw.max_cpu_mhz < 0) { + hw.min_cpu_mhz = info->clock; + hw.max_cpu_mhz = info->clock; + } + if (hw.num_numa < 0) { + hw.num_numa = hw.num_sockets; + } + if (hw.num_cores < 0) { + hw.num_cores = topo->numCoresPerSocket * hw.num_sockets; + } + topology_finalize(); + DART_LOG_TRACE("dart_hwinfo: likwid: " + "num_sockets: %d num_numa: %d num_cores: %d", + hw.num_sockets, hw.num_numa, hw.num_cores); + } +#endif /* DART_ENABLE_LIKWID */ + #ifdef DART_ENABLE_PAPI DART_LOG_TRACE("dart_hwinfo: using PAPI"); From 8926c9a46dafd1f6a93198d55441eda743cff5d5 Mon Sep 17 00:00:00 2001 From: anindex Date: Fri, 31 Jan 2020 15:06:39 +0100 Subject: [PATCH 2/4] Add version dependency for hwloc socket number query --- dart-impl/base/src/hwinfo.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dart-impl/base/src/hwinfo.c b/dart-impl/base/src/hwinfo.c index 95402c1b8..4724bb7bf 100644 --- a/dart-impl/base/src/hwinfo.c +++ b/dart-impl/base/src/hwinfo.c @@ -289,7 +289,13 @@ dart_ret_t dart_hwinfo( } } if (hw.num_sockets < 0) { - int n_sockets = hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_PACKAGE); + int n_sockets = hwloc_get_nbobjs_by_type(topology, +#if HWLOC_API_VERSION > 0x00011000 + HWLOC_OBJ_PACKAGE +#else + HWLOC_OBJ_SOCKET +#endif + ); if (n_sockets > 0) { hw.num_sockets = n_sockets; } From be3988ac52a58a149a896b525224df255a1d5cfb Mon Sep 17 00:00:00 2001 From: anindex Date: Fri, 31 Jan 2020 15:22:12 +0100 Subject: [PATCH 3/4] Fix compile issue with hwloc 2.x --- dart-impl/base/src/hwinfo.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dart-impl/base/src/hwinfo.c b/dart-impl/base/src/hwinfo.c index 4724bb7bf..c1f229729 100644 --- a/dart-impl/base/src/hwinfo.c +++ b/dart-impl/base/src/hwinfo.c @@ -316,13 +316,21 @@ dart_ret_t dart_hwinfo( if(hw.system_memory_bytes < 0) { hwloc_obj_t obj; obj = hwloc_get_obj_by_type(topology, HWLOC_OBJ_MACHINE, 0); +#if HWLOC_API_VERSION < 0x00020000 hw.system_memory_bytes = obj->memory.total_memory / BYTES_PER_MB; +#else + hw.system_memory_bytes = obj->total_memory / BYTES_PER_MB; +#endif } if(hw.numa_memory_bytes < 0) { hwloc_obj_t obj; obj = hwloc_get_obj_by_type(topology, DART__HWLOC_OBJ_NUMANODE, 0); if(obj != NULL) { +#if HWLOC_API_VERSION < 0x00020000 hw.numa_memory_bytes = obj->memory.total_memory / BYTES_PER_MB; +#else + hw.numa_memory_bytes = obj->total_memory / BYTES_PER_MB; +#endif } else { /* No NUMA domain: */ hw.numa_memory_bytes = hw.system_memory_bytes; From 2dcdb999d14b030cfdbb79ecdee73d78d7c1b68f Mon Sep 17 00:00:00 2001 From: anindex Date: Fri, 31 Jan 2020 16:46:10 +0100 Subject: [PATCH 4/4] get numma node number and socket number in likwid --- dart-impl/base/src/hwinfo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dart-impl/base/src/hwinfo.c b/dart-impl/base/src/hwinfo.c index c1f229729..e1b573b0b 100644 --- a/dart-impl/base/src/hwinfo.c +++ b/dart-impl/base/src/hwinfo.c @@ -363,7 +363,10 @@ dart_ret_t dart_hwinfo( hw.max_cpu_mhz = info->clock; } if (hw.num_numa < 0) { - hw.num_numa = hw.num_sockets; + hw.num_numa = likwid_getNumberOfNodes(); + } + if (hw.num_sockets < 0) { + hw.num_sockets = topo->numSockets; } if (hw.num_cores < 0) { hw.num_cores = topo->numCoresPerSocket * hw.num_sockets;