ソースを参照

Add function starpu_get_pu_os_index()

Philippe SWARTVAGHER 5 年 前
コミット
d86c6fcf51
共有3 個のファイルを変更した23 個の追加1 個の削除を含む
  1. 3 1
      ChangeLog
  2. 6 0
      include/starpu_helper.h
  3. 14 0
      src/core/topology.c

+ 3 - 1
ChangeLog

@@ -34,7 +34,9 @@ New features:
   * Add energy accounting in the simgrid mode: starpu_energy_use() and
     starpu_energy_used().
   * New function starpu_mpi_get_thread_cpuid() to know where is bound the MPI
-    thread
+    thread.
+  * New function starpu_get_pu_os_index() to convert logical index of a PU to
+    its OS index.
 
 Small changes:
   * Use the S4U interface of Simgrid instead of xbt and MSG.

+ 6 - 0
include/starpu_helper.h

@@ -190,6 +190,12 @@ int starpu_data_cpy(starpu_data_handle_t dst_handle, starpu_data_handle_t src_ha
 */
 void starpu_display_bindings(void);
 
+/**
+   If \c hwloc is used, convert the given \p logical_index of a PU to the OS
+   index of this PU. If \c hwloc is not used, return \p logical_index.
+*/
+int starpu_get_pu_os_index(unsigned logical_index);
+
 /** @} */
 
 #ifdef __cplusplus

+ 14 - 0
src/core/topology.c

@@ -3056,3 +3056,17 @@ void starpu_topology_print(FILE *output)
 		fprintf(output, "\n");
 	}
 }
+
+int starpu_get_pu_os_index(unsigned logical_index)
+{
+#ifdef STARPU_HAVE_HWLOC
+	struct _starpu_machine_config *config = _starpu_get_machine_config();
+	struct _starpu_machine_topology *topology = &config->topology;
+
+	hwloc_topology_t topo = topology->hwtopology;
+
+	return hwloc_get_obj_by_type(topo, HWLOC_OBJ_PU, logical_index)->os_index;
+#else
+	return logical_index;
+#endif
+}