ソースを参照

move struct starpu_machine_topology from include/starpu_worker.h to src/core/workers.h and rename it to struct _starpu_machine_topology

Nathalie Furmento 12 年 前
コミット
a7047a3a4a
共有8 個のファイルを変更した121 個の追加142 個の削除を含む
  1. 0 73
      doc/chapters/api.texi
  2. 0 48
      include/starpu_worker.h
  3. 2 2
      src/core/detect_combined_workers.c
  4. 1 1
      src/core/perfmodel/perfmodel_bus.c
  5. 13 13
      src/core/topology.c
  6. 100 1
      src/core/workers.h
  7. 3 3
      src/drivers/cpu/driver_cpu.c
  8. 2 1
      src/drivers/mic/driver_mic_source.c

+ 0 - 73
doc/chapters/api.texi

@@ -3990,79 +3990,6 @@ Initialise the barrier for the parallel task, and dispatch the task
 between the different combined workers
 @end deftypefun
 
-@deftp {Data Type} {struct starpu_machine_topology}
-@table @asis
-@item @code{unsigned nworkers}
-Total number of workers.
-
-@item @code{unsigned ncombinedworkers}
-Total number of combined workers.
-
-@item @code{hwloc_topology_t hwtopology}
-Topology as detected by hwloc.
-
-To maintain ABI compatibility when hwloc is not available, the field
-is replaced with @code{void *dummy}
-
-@item @code{unsigned nhwcpus}
-Total number of CPUs, as detected by the topology code. May be different from
-the actual number of CPU workers.
-
-@item @code{unsigned nhwcudagpus}
-Total number of CUDA devices, as detected. May be different from the actual
-number of CUDA workers.
-
-@item @code{unsigned nhwopenclgpus}
-Total number of OpenCL devices, as detected. May be different from the actual
-number of OpenCL workers.
-
-@item @code{unsigned nhscc}
-Total number of SCC cores, as detected. May be different from the actual
-number of core workers.
-
-@item @code{unsigned ncpus}
-Actual number of CPU workers used by StarPU.
-
-@item @code{unsigned ncudagpus}
-Actual number of CUDA workers used by StarPU.
-
-@item @code{unsigned nopenclgpus}
-Actual number of OpenCL workers used by StarPU.
-
-@item @code{unsigned nsccdevices}
-Actual number of SCC workers used by StarPU.
-
-@item @code{unsigned workers_bindid[STARPU_NMAXWORKERS]}
-Indicates the successive cpu identifier that should be used to bind the
-workers. It is either filled according to the user's explicit
-parameters (from starpu_conf) or according to the STARPU_WORKERS_CPUID env.
-variable. Otherwise, a round-robin policy is used to distributed the workers
-over the cpus.
-
-@item @code{unsigned workers_cuda_gpuid[STARPU_NMAXWORKERS]}
-Indicates the successive CUDA identifier that should be used by the CUDA
-driver.  It is either filled according to the user's explicit parameters (from
-starpu_conf) or according to the STARPU_WORKERS_CUDAID env. variable. Otherwise,
-they are taken in ID order.
-
-@item @code{unsigned workers_opencl_gpuid[STARPU_NMAXWORKERS]}
-Indicates the successive OpenCL identifier that should be used by the OpenCL
-driver.  It is either filled according to the user's explicit parameters (from
-starpu_conf) or according to the STARPU_WORKERS_OPENCLID env. variable. Otherwise,
-they are taken in ID order.
-
-@item @code{unsigned workers_mic_deviceid[STARPU_NMAXWORKERS]}
-Indicates the successive MIC devices that should be used by the MIC
-driver.  It is either filled according to the user's explicit parameters (from
-starpu_conf) or according to the STARPU_WORKERS_MICID env. variable. Otherwise,
-they are taken in ID order.
-
-@item @code{unsigned workers_scc_deviceid[STARPU_NMAXWORKERS]}
-Indicates the successive SCC devices that should be used by the SCC
-driver.  It is either filled according to the user's explicit parameters (from
-starpu_conf) or according to the STARPU_WORKERS_SCCID env. variable. Otherwise,
-they are taken in ID order.
-
 @end table
 @end deftp
 

+ 0 - 48
include/starpu_worker.h

@@ -54,54 +54,6 @@ struct starpu_sched_ctx_iterator
 	int cursor;
 };
 
-struct starpu_machine_topology
-{
-	unsigned nworkers;
-
-	unsigned ncombinedworkers;
-
-	unsigned nsched_ctxs;
-#ifdef STARPU_HAVE_HWLOC
-	hwloc_topology_t hwtopology;
-#else
-	/* We maintain ABI compatibility with and without hwloc */
-	void *dummy;
-#endif
-
-	unsigned nhwcpus;
-	unsigned nhwcudagpus;
-	unsigned nhwopenclgpus;
-	unsigned nhwscc;
-
-	unsigned ncpus;
-	unsigned ncudagpus;
-	unsigned nopenclgpus;
-	unsigned nsccdevices;
-
-	/* Topology of MP nodes (mainly MIC and SCC) as well as necessary
-	 * objects to communicate with them. */
-	unsigned nhwmicdevices;
-	unsigned nmicdevices;
-
-	unsigned nhwmiccores[STARPU_MAXMICDEVS]; // Each MIC node has its set of cores.
-	unsigned nmiccores[STARPU_MAXMICDEVS];
-
-	/* Where to bind workers ? */
-	unsigned workers_bindid[STARPU_NMAXWORKERS];
-
-	/* Which GPU(s) do we use for CUDA ? */
-	unsigned workers_cuda_gpuid[STARPU_NMAXWORKERS];
-
-	/* Which GPU(s) do we use for OpenCL ? */
-	unsigned workers_opencl_gpuid[STARPU_NMAXWORKERS];
-
-	/* Which MIC core(s) do we use ? */
-	/* unsigned workers_mic_deviceid[STARPU_NMAXWORKERS]; */
-
-	/* Which SCC(s) do we use ? */
-	unsigned workers_scc_deviceid[STARPU_NMAXWORKERS];
-};
-
 /* types of structures the worker collection can implement */
 enum starpu_worker_collection_type
 {

+ 2 - 2
src/core/detect_combined_workers.c

@@ -109,7 +109,7 @@ static void find_and_assign_combinations(hwloc_obj_t obj, unsigned min, unsigned
 	int cpu_workers[STARPU_NMAXWORKERS];
 
 	struct _starpu_machine_config *config = _starpu_get_machine_config();
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 
 	hwloc_obj_snprintf(name, sizeof(name), topology->hwtopology, obj, "#", 0);
 	_STARPU_DEBUG("Looking at %s\n", name);
@@ -156,7 +156,7 @@ static void find_and_assign_combinations(hwloc_obj_t obj, unsigned min, unsigned
 static void find_and_assign_combinations_with_hwloc(int *workerids, int nworkers)
 {
 	struct _starpu_machine_config *config = _starpu_get_machine_config();
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 	int synthesize_arity = starpu_get_env_number("STARPU_SYNTHESIZE_ARITY_COMBINED_WORKER");
 
 	int min = starpu_get_env_number("STARPU_MIN_WORKERSIZE");

+ 1 - 1
src/core/perfmodel/perfmodel_bus.c

@@ -1882,7 +1882,7 @@ double _starpu_predict_transfer_time(unsigned src_node, unsigned dst_node, size_
 {
 	double bandwidth = bandwidth_matrix[src_node][dst_node];
 	double latency = latency_matrix[src_node][dst_node];
-	struct starpu_machine_topology *topology = &_starpu_get_machine_config()->topology;
+	struct _starpu_machine_topology *topology = &_starpu_get_machine_config()->topology;
 
 	return latency + (size/bandwidth)*2*(topology->ncudagpus+topology->nopenclgpus);
 }

+ 13 - 13
src/core/topology.c

@@ -158,7 +158,7 @@ _starpu_initialize_workers_deviceid (int *explicit_workers_gpuid,
 static void
 _starpu_initialize_workers_cuda_gpuid (struct _starpu_machine_config *config)
 {
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 	struct starpu_conf *uconf = config->conf;
 
         _starpu_initialize_workers_deviceid (
@@ -185,7 +185,7 @@ _starpu_get_next_cuda_gpuid (struct _starpu_machine_config *config)
 static void
 _starpu_initialize_workers_opencl_gpuid (struct _starpu_machine_config*config)
 {
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 	struct starpu_conf *uconf = config->conf;
 
         _starpu_initialize_workers_deviceid(
@@ -266,7 +266,7 @@ _starpu_get_next_opencl_gpuid (struct _starpu_machine_config *config)
 #if defined(STARPU_USE_MIC) || defined(STARPU_SIMGRID)
 static void _starpu_initialize_workers_mic_deviceid(struct _starpu_machine_config *config)
 {
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 	struct starpu_conf *uconf = config->conf;
 
 	_starpu_initialize_workers_deviceid(
@@ -284,7 +284,7 @@ static void _starpu_initialize_workers_mic_deviceid(struct _starpu_machine_confi
 #ifdef STARPU_USE_SCC
 static void _starpu_initialize_workers_scc_deviceid(struct _starpu_machine_config *config)
 {
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 	struct starpu_conf *uconf = config->conf;
 
 	_starpu_initialize_workers_deviceid(
@@ -327,7 +327,7 @@ _starpu_init_mic_topology (struct _starpu_machine_config *config, long mic_idx)
 	 * on this MIC device. Update the `nhwmiccores' topology field
 	 * accordingly. */
 
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 
 	int nbcores;
 	_starpu_src_common_sink_nbcores (mic_nodes[mic_idx], &nbcores);
@@ -412,7 +412,7 @@ _starpu_init_topology (struct _starpu_machine_config *config)
 	   before calling this function. The discovered topology is filled in
 	   CONFIG. */
 
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 
 	if (topology_is_initialized)
 		return;
@@ -445,7 +445,7 @@ _starpu_initialize_workers_bindid (struct _starpu_machine_config *config)
 	char *strval;
 	unsigned i;
 
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 
 	config->current_bindid = 0;
 
@@ -526,7 +526,7 @@ static inline int
 _starpu_get_next_bindid (struct _starpu_machine_config *config,
 			 int *preferred_binding, int npreferred)
 {
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 
 	unsigned found = 0;
 	int current_preferred;
@@ -590,7 +590,7 @@ _starpu_init_mic_config (struct _starpu_machine_config *config,
 {
 	// Configure the MIC device of index MIC_IDX.
 
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 
 	topology->nhwmiccores[mic_idx] = 0;
 
@@ -664,7 +664,7 @@ _starpu_init_mp_config (struct _starpu_machine_config *config,
 	 * - configure the workers accordingly.
 	 */
 
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 
 	// We currently only support MIC at this level.
 #ifdef STARPU_USE_MIC
@@ -702,7 +702,7 @@ _starpu_deinit_mic_node (unsigned mic_idx)
 static void
 _starpu_deinit_mp_config (struct _starpu_machine_config *config)
 {
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 	unsigned i;
 
 	for (i = 0; i < topology->nmicdevices; i++)
@@ -718,7 +718,7 @@ _starpu_init_machine_config (struct _starpu_machine_config *config, int no_mp_co
 	for (i = 0; i < STARPU_NMAXWORKERS; i++)
 		config->workers[i].workerid = i;
 
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 
 	topology->nworkers = 0;
 	topology->ncombinedworkers = 0;
@@ -1368,7 +1368,7 @@ void
 starpu_topology_print (FILE *output)
 {
 	struct _starpu_machine_config *config = _starpu_get_machine_config();
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 	unsigned core;
 	unsigned worker;
 	unsigned nworkers = starpu_worker_get_count();

+ 100 - 1
src/core/workers.h

@@ -145,9 +145,108 @@ struct _starpu_worker_set
 	unsigned set_is_initialized;
 };
 
+struct _starpu_machine_topology
+{
+	/* Total number of workers. */
+	unsigned nworkers;
+
+	/* Total number of combined workers. */
+	unsigned ncombinedworkers;
+
+	unsigned nsched_ctxs;
+#ifdef STARPU_HAVE_HWLOC
+	/* Topology as detected by hwloc. */
+	hwloc_topology_t hwtopology;
+#else
+	/* We maintain ABI compatibility with and without hwloc */
+	void *dummy;
+#endif
+
+	/* Total number of CPUs, as detected by the topology code. May
+	 * be different from the actual number of CPU workers.
+	 */
+	unsigned nhwcpus;
+
+	/* Total number of CUDA devices, as detected. May be different
+	 * from the actual number of CUDA workers.
+	 */
+	unsigned nhwcudagpus;
+
+	/* Total number of OpenCL devices, as detected. May be
+	 * different from the actual number of OpenCL workers.
+	 */
+	unsigned nhwopenclgpus;
+
+	/* Total number of SCC cores, as detected. May be different
+	 * from the actual number of core workers.
+	 */
+	unsigned nhwscc;
+
+	/* Actual number of CPU workers used by StarPU. */
+	unsigned ncpus;
+
+	/* Actual number of CUDA workers used by StarPU. */
+	unsigned ncudagpus;
+
+	/* Actual number of OpenCL workers used by StarPU. */
+	unsigned nopenclgpus;
+
+	/* Actual number of SCC workers used by StarPU. */
+	unsigned nsccdevices;
+
+	/* Topology of MP nodes (mainly MIC and SCC) as well as necessary
+	 * objects to communicate with them. */
+	unsigned nhwmicdevices;
+	unsigned nmicdevices;
+
+	unsigned nhwmiccores[STARPU_MAXMICDEVS]; // Each MIC node has its set of cores.
+	unsigned nmiccores[STARPU_MAXMICDEVS];
+
+	/* Indicates the successive cpu identifier that should be used
+	 * to bind the workers. It is either filled according to the
+	 * user's explicit parameters (from starpu_conf) or according
+	 * to the STARPU_WORKERS_CPUID env. variable. Otherwise, a
+	 * round-robin policy is used to distributed the workers over
+	 * the cpus.
+	 */
+	unsigned workers_bindid[STARPU_NMAXWORKERS];
+
+	/* Indicates the successive CUDA identifier that should be
+	 * used by the CUDA driver.  It is either filled according to
+	 * the user's explicit parameters (from starpu_conf) or
+	 * according to the STARPU_WORKERS_CUDAID env. variable.
+	 * Otherwise, they are taken in ID order.
+	 */
+	unsigned workers_cuda_gpuid[STARPU_NMAXWORKERS];
+
+	/* Indicates the successive OpenCL identifier that should be
+	 * used by the OpenCL driver.  It is either filled according
+	 * to the user's explicit parameters (from starpu_conf) or
+	 * according to the STARPU_WORKERS_OPENCLID env. variable.
+	 * Otherwise, they are taken in ID order.
+	 */
+	unsigned workers_opencl_gpuid[STARPU_NMAXWORKERS];
+
+	/** Indicates the successive MIC devices that should be used
+	 * by the MIC driver.  It is either filled according to the
+	 * user's explicit parameters (from starpu_conf) or according
+	 * to the STARPU_WORKERS_MICID env. variable. Otherwise, they
+	 * are taken in ID order. */
+	/* unsigned workers_mic_deviceid[STARPU_NMAXWORKERS]; */
+
+	/* Which SCC(s) do we use ? */
+	/* Indicates the successive SCC devices that should be used by
+	 * the SCC driver.  It is either filled according to the
+	 * user's explicit parameters (from starpu_conf) or according
+	 * to the STARPU_WORKERS_SCCID env. variable. Otherwise, they
+	 * are taken in ID order.
+	 */
+	unsigned workers_scc_deviceid[STARPU_NMAXWORKERS];
+};
+
 struct _starpu_machine_config
 {
-	struct starpu_machine_topology topology;
+	struct _starpu_machine_topology topology;
 
 #ifdef STARPU_HAVE_HWLOC
 	int cpu_depth;

+ 3 - 3
src/drivers/cpu/driver_cpu.c

@@ -21,11 +21,11 @@
 
 #include <math.h>
 #include <starpu.h>
-#include <starpu_scheduler.h> /* XXX For starpu_machine_topology */
 #include <starpu_profiling.h>
 #include <drivers/driver_common/driver_common.h>
 #include <common/utils.h>
 #include <core/debug.h>
+#include <core/workers.h>
 #include "driver_cpu.h"
 #include <core/sched_policy.h>
 #include <datawizard/memory_manager.h>
@@ -58,7 +58,7 @@ _starpu_cpu_discover_devices(struct _starpu_machine_config *config)
 	/* Discover the CPUs relying on the hwloc interface and fills CONFIG
 	 * accordingly. */
 
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
 
 	config->cpu_depth = hwloc_get_type_depth (topology->hwtopology,
 						  HWLOC_OBJ_CORE);
@@ -201,7 +201,7 @@ static size_t _starpu_cpu_get_global_mem_size(int devid, struct _starpu_machine_
 
 #if defined(STARPU_HAVE_HWLOC)
         int depth_node;
-	struct starpu_machine_topology *topology = &config->topology;
+	struct _starpu_machine_topology *topology = &config->topology;
         depth_node = hwloc_get_type_depth(topology->hwtopology, HWLOC_OBJ_NODE);
 
 	if (depth_node == HWLOC_TYPE_DEPTH_UNKNOWN)

+ 2 - 1
src/drivers/mic/driver_mic_source.c

@@ -21,6 +21,7 @@
 #include <starpu.h>
 #include <starpu_profiling.h>
 #include <core/sched_policy.h>
+#include <core/workers.h>
 #include <common/uthash.h>
 
 #include <drivers/driver_common/driver_common.h>
@@ -326,7 +327,7 @@ unsigned starpu_mic_device_get_count(void)
 {
     // Return the number of configured MIC devices.
     struct _starpu_machine_config *config = _starpu_get_machine_config ();
-    struct starpu_machine_topology *topology = &config->topology;
+    struct _starpu_machine_topology *topology = &config->topology;
 
     return topology->nmicdevices;
 }