Browse Source

Add function starpu_get_hwloc_topology()

Philippe SWARTVAGHER 4 years ago
parent
commit
d4aa592d07
3 changed files with 21 additions and 0 deletions
  1. 2 0
      ChangeLog
  2. 10 0
      include/starpu_helper.h
  3. 9 0
      src/core/topology.c

+ 2 - 0
ChangeLog

@@ -37,6 +37,8 @@ New features:
     thread.
   * New function starpu_get_pu_os_index() to convert logical index of a PU to
     its OS index.
+  * New function starpu_get_hwloc_topology() to get a copy of the hwloc
+    topology used by StarPU.
 
 Small changes:
   * Use the S4U interface of Simgrid instead of xbt and MSG.

+ 10 - 0
include/starpu_helper.h

@@ -20,6 +20,10 @@
 #include <stdio.h>
 #include <starpu.h>
 
+#ifdef STARPU_HAVE_HWLOC
+#include <hwloc.h>
+#endif
+
 #ifdef __cplusplus
 extern "C"
 {
@@ -196,6 +200,12 @@ void starpu_display_bindings(void);
 */
 int starpu_get_pu_os_index(unsigned logical_index);
 
+#ifdef STARPU_HAVE_HWLOC
+/**
+   Get a copy of the hwloc topology used by StarPU.
+*/
+int starpu_get_hwloc_topology(hwloc_topology_t* topology);
+#endif
 /** @} */
 
 #ifdef __cplusplus

+ 9 - 0
src/core/topology.c

@@ -3070,3 +3070,12 @@ int starpu_get_pu_os_index(unsigned logical_index)
 	return logical_index;
 #endif
 }
+
+#ifdef STARPU_HAVE_HWLOC
+int starpu_get_hwloc_topology(hwloc_topology_t* topology)
+{
+	struct _starpu_machine_config *config = _starpu_get_machine_config();
+
+	return hwloc_topology_dup(topology, config->topology.hwtopology);
+}
+#endif