Browse Source

combined workers: there can be several workers bound on the same cpu, stores a list of workers in hwloc instead of a unique worker

Nathalie Furmento 11 years ago
parent
commit
5d4a2b9027
3 changed files with 28 additions and 18 deletions
  1. 10 7
      src/core/detect_combined_workers.c
  2. 16 8
      src/core/topology.c
  3. 2 3
      src/core/workers.h

+ 10 - 7
src/core/detect_combined_workers.c

@@ -39,13 +39,17 @@ static void find_workers(hwloc_obj_t obj, int cpu_workers[STARPU_NMAXWORKERS], u
 	}
 
 	/* Got to a PU leaf */
-	struct _starpu_worker *worker = obj->userdata;
-	/* is it a CPU worker? */
-	if (worker->perf_arch.type == STARPU_CPU_WORKER && worker->perf_arch.ncore == 0)
+	struct _starpu_worker_list *workers = obj->userdata;
+	struct _starpu_worker *worker;
+	for(worker = _starpu_worker_list_begin(workers); worker != _starpu_worker_list_end(workers); worker = _starpu_worker_list_next(worker))
 	{
-		_STARPU_DEBUG("worker %d is part of it\n", worker->workerid);
-		/* Add it to the combined worker */
-		cpu_workers[(*n)++] = worker->workerid;
+		/* is it a CPU worker? */
+		if (worker->perf_arch.type == STARPU_CPU_WORKER && worker->perf_arch.ncore == 0)
+		{
+			_STARPU_DEBUG("worker %d is part of it\n", worker->workerid);
+			/* Add it to the combined worker */
+			cpu_workers[(*n)++] = worker->workerid;
+		}
 	}
 }
 
@@ -177,7 +181,6 @@ static void find_and_assign_combinations_with_hwloc(int *workerids, int nworkers
 		if (worker->perf_arch.type == STARPU_CPU_WORKER && worker->perf_arch.ncore == 0)
 		{
 			hwloc_obj_t obj = hwloc_get_obj_by_depth(topology->hwtopology, config->cpu_depth, worker->bindid);
-			STARPU_ASSERT(obj->userdata == worker);
 			obj = obj->parent;
 			while (obj)
 			{

+ 16 - 8
src/core/topology.c

@@ -1291,16 +1291,17 @@ _starpu_init_workers_binding (struct _starpu_machine_config *config, int no_mp_c
 #ifdef STARPU_HAVE_HWLOC
 		/* Put the worker descriptor in the userdata field of the
 		 * hwloc object describing the CPU */
-		hwloc_obj_t worker_obj;
-		worker_obj =
-			hwloc_get_obj_by_depth (config->topology.hwtopology,
-						config->cpu_depth,
-						workerarg->bindid);
-		worker_obj->userdata = &config->workers[worker];
+		hwloc_obj_t worker_obj = hwloc_get_obj_by_depth(config->topology.hwtopology,
+								config->cpu_depth,
+								workerarg->bindid);
+		if (worker_obj->userdata == NULL)
+		{
+			worker_obj->userdata = _starpu_worker_list_new();
+		}
+		_starpu_worker_list_push_front(worker_obj->userdata, workerarg);
 
 		/* Clear the cpu set and set the cpu */
-		workerarg->hwloc_cpu_set =
-			hwloc_bitmap_dup (worker_obj->cpuset);
+		workerarg->hwloc_cpu_set = hwloc_bitmap_dup (worker_obj->cpuset);
 #endif
 	}
 #ifdef STARPU_SIMGRID
@@ -1388,6 +1389,13 @@ _starpu_destroy_topology (
 #ifdef STARPU_HAVE_HWLOC
 		struct _starpu_worker *workerarg = &config->workers[worker];
 		hwloc_bitmap_free(workerarg->hwloc_cpu_set);
+		hwloc_obj_t worker_obj = hwloc_get_obj_by_depth(config->topology.hwtopology,
+								config->cpu_depth,
+								workerarg->bindid);
+		if (worker_obj->userdata)
+		{
+			_starpu_worker_list_delete(worker_obj->userdata);
+		}
 #endif
 	}
 

+ 2 - 3
src/core/workers.h

@@ -53,8 +53,7 @@
 #include <starpu_parameters.h>
 
 /* This is initialized from in _starpu_worker_init */
-struct _starpu_worker
-{
+LIST_TYPE(_starpu_worker,
 	struct _starpu_machine_config *config;
         starpu_pthread_mutex_t mutex;
 	enum starpu_worker_archtype arch; /* what is the type of worker ? */
@@ -113,7 +112,7 @@ struct _starpu_worker
 #ifdef STARPU_HAVE_HWLOC
 	hwloc_bitmap_t hwloc_cpu_set;
 #endif
-};
+);
 
 struct _starpu_combined_worker
 {