Kaynağa Gözat

old bugs fixed
new bugs added

new bit to say if we want mix differents workers

Simon Archipoff 12 yıl önce
ebeveyn
işleme
24c5f03fc9

+ 1 - 1
src/sched_policies/hierarchical_heft.c

@@ -6,7 +6,7 @@ static struct  _starpu_composed_sched_node_recipe *  recipe_for_worker(enum star
 {
 	struct _starpu_composed_sched_node_recipe * r = _starpu_sched_node_create_recipe();
 	_starpu_sched_recipe_add_node(r, _starpu_sched_node_fifo_create, NULL);
-	return r;
+	return NULL; r;
 }
 
 static void initialize_heft_center_policy(unsigned sched_ctx_id)

+ 15 - 3
src/sched_policies/node_fifo.c

@@ -13,19 +13,31 @@ struct _starpu_fifo_data
 static struct _starpu_task_execute_preds estimated_execute_preds(struct _starpu_sched_node * node,
 								 struct starpu_task * task)
 {
+	struct _starpu_fifo_data * data = node->data;
+	struct _starpu_prio_deque * fifo = &data->fifo;
+	starpu_pthread_mutex_t * mutex = &data->mutex;
 	if(node->nchilds == 0)
 	{
 		struct _starpu_task_execute_preds p = { CANNOT_EXECUTE };
 		return p;
 	}
 	
+	if(!node->is_homogeneous)
+	{
+		struct _starpu_task_execute_preds preds = _starpu_sched_node_average_estimated_execute_preds(node, task);
+		STARPU_PTHREAD_MUTEX_LOCK(mutex);
+		preds.expected_finish_time = _starpu_compute_expected_time(fifo->exp_start,
+									   preds.expected_finish_time + fifo->exp_end,
+									   preds.state == PERF_MODEL ? preds.expected_length + fifo->exp_len : fifo->exp_len,
+									   preds.expected_transfer_length);
+		STARPU_PTHREAD_MUTEX_UNLOCK(mutex);
+		return preds;
+	}
+	
 	struct _starpu_task_execute_preds preds = node->childs[0]->estimated_execute_preds(node->childs[0],task);
 
 	if(preds.state == PERF_MODEL)
 	{
-		struct _starpu_fifo_data * data = node->data;
-		struct _starpu_prio_deque * fifo = &data->fifo;
-		starpu_pthread_mutex_t * mutex = &data->mutex;
 		STARPU_PTHREAD_MUTEX_LOCK(mutex);
 		preds.expected_finish_time = _starpu_compute_expected_time(fifo->exp_start,
 									   preds.expected_finish_time + fifo->exp_end,

+ 2 - 2
src/sched_policies/node_sched.c

@@ -226,7 +226,7 @@ static double estimated_load(struct _starpu_sched_node * node)
 }
 
 
-static struct _starpu_task_execute_preds estimated_execute_preds(struct _starpu_sched_node * node, struct starpu_task * task)
+struct _starpu_task_execute_preds _starpu_sched_node_average_estimated_execute_preds(struct _starpu_sched_node * node, struct starpu_task * task)
 {
 	if(node->is_homogeneous)
 		return node->childs[0]->estimated_execute_preds(node->childs[0], task);
@@ -338,7 +338,7 @@ struct _starpu_sched_node * _starpu_sched_node_create(void)
 	node->deinit_data = take_node_and_does_nothing;
 	node->pop_task = pop_task_node;
 	node->estimated_load = estimated_load;
-	node->estimated_execute_preds = estimated_execute_preds;
+	node->estimated_execute_preds = _starpu_sched_node_average_estimated_execute_preds;
 
 	return node;
 }

+ 1 - 0
src/sched_policies/node_sched.h

@@ -94,6 +94,7 @@ void _starpu_sched_node_set_father(struct _starpu_sched_node *node, struct _star
 void _starpu_sched_node_add_child(struct _starpu_sched_node* node, struct _starpu_sched_node * child);
 void _starpu_sched_node_remove_child(struct _starpu_sched_node * node, struct _starpu_sched_node * child);
 
+struct _starpu_task_execute_preds _starpu_sched_node_average_estimated_execute_preds(struct _starpu_sched_node * node, struct starpu_task * task);
 
 int _starpu_sched_node_can_execute_task(struct _starpu_sched_node * node, struct starpu_task * task);
 int _starpu_sched_node_can_execute_task_with_impl(struct _starpu_sched_node * node, struct starpu_task * task, unsigned nimpl);

+ 67 - 50
src/sched_policies/scheduler_maker.c

@@ -101,60 +101,88 @@ struct _starpu_sched_node * _find_sched_node_with_obj(struct _starpu_sched_node
 }
 
 
-static void set_cpu_worker_leaf(struct _starpu_sched_node * root, struct _starpu_sched_node * worker, unsigned sched_ctx_id,
-				struct _starpu_composed_sched_node_recipe * cpu_composed_sched_node)
+static int is_same_kind_of_all(struct _starpu_sched_node * root, struct _starpu_worker * w)
 {
-	hwloc_obj_t obj = worker->obj;
-	STARPU_ASSERT(!_find_sched_node_with_obj(root, obj));
-	while(obj)
+	if(_starpu_sched_node_is_worker(root))
 	{
-		obj = obj->parent;
-		struct _starpu_sched_node * tmp = _find_sched_node_with_obj(root, obj);
-		if(tmp)
+		struct _starpu_worker * w_ = root->data;
+		return w_->perf_arch == w->perf_arch;
+	}
+	
+	int i;
+	for(i = 0;i < root->nchilds; i++)
+		if(!is_same_kind_of_all(root->childs[i], w))
+			return 0;
+	return 0;
+}
+
+struct _starpu_sched_node * find_mem_node(struct _starpu_sched_node * root, struct _starpu_sched_node * worker_node, unsigned sched_ctx_id)
+{
+	struct _starpu_sched_node * node = worker_node;
+	while(node->obj->type != HWLOC_OBJ_NODE
+	      && node->obj->type != HWLOC_OBJ_MACHINE)
+	{
+		hwloc_obj_t tmp = node->obj;
+		do
 		{
-			struct _starpu_sched_node * node = _starpu_sched_node_composed_node_create(cpu_composed_sched_node);
-			node->obj = worker->obj;
-			_starpu_sched_node_set_father(node, tmp, sched_ctx_id);
-			_starpu_sched_node_add_child(tmp, node);
-
-			_starpu_sched_node_set_father(worker, node, sched_ctx_id);
-			_starpu_sched_node_add_child(node, worker);
-			return;
+			node = _find_sched_node_with_obj(root,tmp);
+			tmp = tmp->parent;
 		}
+		while(!node);
+		
 	}
-	STARPU_ABORT();
+	return node;
 }
 
-static void set_other_worker_leaf(struct _starpu_sched_node * root, struct _starpu_sched_node * worker, unsigned sched_ctx_id,
-				  struct _starpu_composed_sched_node_recipe * device_composed_sched_node, int sched_have_numa_node)
+static struct _starpu_sched_node * where_should_we_plug_this(struct _starpu_sched_node *root, struct _starpu_sched_node * worker_node, struct _starpu_sched_specs specs, unsigned sched_ctx_id)
 {
-	hwloc_obj_t obj = worker->obj;
-	while(obj)
-		if((sched_have_numa_node && obj->type == HWLOC_OBJ_NODE) || obj->type == HWLOC_OBJ_MACHINE)
-			break;
-		else
-			obj = obj->parent;
-	STARPU_ASSERT(obj != NULL);
-
-	struct _starpu_sched_node * tmp = _find_sched_node_with_obj(root, obj);
-	if(tmp)
+	struct _starpu_sched_node * mem = find_mem_node(root ,worker_node, sched_ctx_id);
+	if(specs.mix_heterogeneous_workers || mem->fathers[sched_ctx_id] == NULL)
+		return mem;
+	hwloc_obj_t obj = mem->obj;
+	struct _starpu_sched_node * father = mem->fathers[sched_ctx_id];
+	int i;
+	for(i = 0; i < father->nchilds; i++)
 	{
+		if(father->childs[i]->obj == obj
+		   && is_same_kind_of_all(father->childs[i], worker_node->data))
+			return father->childs[i];
+	}
+	if(obj->type == HWLOC_OBJ_NODE)
+	{	
+		struct _starpu_sched_node * node = _starpu_sched_node_composed_node_create(specs.hwloc_node_composed_sched_node);
+		_starpu_sched_node_add_child(father, node);
+		_starpu_sched_node_set_father(node, father, sched_ctx_id);
+		return node;
+	}
+	return father;
+}
+
+static void set_worker_leaf(struct _starpu_sched_node * root, struct _starpu_sched_node * worker_node, unsigned sched_ctx_id,
+			    struct _starpu_sched_specs specs)
+{
+	struct _starpu_worker * worker = worker_node->data;
+	struct _starpu_sched_node * node = where_should_we_plug_this(root,worker_node,specs, sched_ctx_id);
+	struct _starpu_composed_sched_node_recipe * recipe = specs.worker_composed_sched_node ?
+		specs.worker_composed_sched_node(worker->arch):NULL;
+	STARPU_ASSERT(node);
+	if(recipe)
+	{
+		struct _starpu_sched_node * tmp = _starpu_sched_node_composed_node_create(recipe);
 #ifdef STARPU_DEVEL
-#warning FIXME node->obj is set to worker->obj even for accelerators workers
+#warning FIXME node->obj is set to worker_node->obj even for accelerators workers
 #endif
-		struct _starpu_sched_node * node = _starpu_sched_node_composed_node_create(device_composed_sched_node);
-		node->obj = worker->obj;
+		tmp->obj = worker_node->obj;
 		_starpu_sched_node_set_father(node, tmp, sched_ctx_id);
 		_starpu_sched_node_add_child(tmp, node);
-		
-		_starpu_sched_node_set_father(worker, node, sched_ctx_id);
-		_starpu_sched_node_add_child(node, worker);
-		return;
+		node = tmp;
 	}
-	STARPU_ABORT();
+	_starpu_destroy_composed_sched_node_recipe(recipe);
+	_starpu_sched_node_set_father(worker_node, node, sched_ctx_id);
+	_starpu_sched_node_add_child(node, worker_node);
+	_starpu_destroy_composed_sched_node_recipe(recipe);
 }
 
-
 #ifdef STARPU_DEVEL
 static const char * name_hwloc_node(struct _starpu_sched_node * node)
 {
@@ -191,7 +219,6 @@ static void helper_display_scheduler(FILE* out, unsigned depth, struct _starpu_s
 		helper_display_scheduler(out, depth + 1, node->childs[i]);
 }
 #endif //STARPU_DEVEL
-
 struct _starpu_sched_tree * _starpu_make_scheduler(unsigned sched_ctx_id, struct _starpu_sched_specs specs)
 {
 	struct _starpu_sched_tree * tree = malloc(sizeof(*tree));
@@ -213,17 +240,7 @@ struct _starpu_sched_tree * _starpu_make_scheduler(unsigned sched_ctx_id, struct
 		struct _starpu_worker * worker = _starpu_get_worker_struct(i);
 		struct _starpu_sched_node * worker_node = _starpu_sched_node_worker_get(i);
 		STARPU_ASSERT(worker);
-		struct _starpu_composed_sched_node_recipe * recipe = specs.worker_composed_sched_node(worker->arch);
-		switch(worker->arch)
-		{
-		case STARPU_CPU_WORKER:
-			set_cpu_worker_leaf(tree->root, worker_node, sched_ctx_id, recipe);
-			break;
-		default:
-			set_other_worker_leaf(tree->root, worker_node, sched_ctx_id, recipe, NULL != specs.hwloc_node_composed_sched_node);
-			break;
-		}
-		_starpu_destroy_composed_sched_node_recipe(recipe);
+		set_worker_leaf(tree->root,worker_node, sched_ctx_id, specs);
 	}
 
 	_starpu_set_workers_bitmaps();

+ 5 - 1
src/sched_policies/scheduler_maker.h

@@ -17,11 +17,15 @@ struct _starpu_sched_specs
 	struct _starpu_composed_sched_node_recipe * hwloc_socket_composed_sched_node;
 	struct _starpu_composed_sched_node_recipe * hwloc_cache_composed_sched_node;
 
-
 	/* this member should return a new allocated _starpu_composed_sched_node_recipe_t or NULL
 	 * the _starpu_composed_sched_node_recipe_t must not include the worker node
 	 */
 	struct _starpu_composed_sched_node_recipe * (*worker_composed_sched_node)(enum starpu_worker_archtype);
+
+	/* this flag indicate if heterogenous workers should be brothers or cousins,
+	 * as exemple, if a gpu and a cpu should share or not there numa node
+	 */
+	int mix_heterogeneous_workers;
 };
 
 struct _starpu_sched_tree * _starpu_make_scheduler(unsigned sched_ctx_id, struct _starpu_sched_specs);