浏览代码

schange node->is_homogeneous by a member that can hold more informations

Simon Archipoff 11 年之前
父节点
当前提交
3e7c994892

+ 19 - 2
doc/doxygen/chapters/api/modularized_scheduler.doxy

@@ -25,8 +25,8 @@ This structure represent a scheduler module.
 \var starpu_sched_node::workers_in_ctx
 	this member contain the subset of starpu_sched_node::workers that is currently available in the context
 	The push method should take this member into account.
-\var starpu_sched_node::is_homogeneous
-	this is set to true iff all underlying workers are the same starpu_worker_archtype.
+\var starpu_sched_node::properties
+	flags starpu_sched_node_properties for things
 \var starpu_sched_node::data
 	data used by the scheduler module
 \var starpu_sched_node::add_child
@@ -44,6 +44,23 @@ This structure represent a scheduler module.
 \var starpu_sched_node::obj
 	the hwloc object associated to scheduler module
 
+\enum starpu_sched_node_properties
+\ingroup API_Modularized_Scheduler
+flags for starpu_sched_node::properties
+\var STARPU_SCHED_NODE_HOMOGENEOUS
+     indicate that all workers have the same starpu_worker_archtype
+\var STARPU_SCHED_NODE_SINGLE_MEMORY_NODE
+     indicate that all workers have the same memory node
+
+\def STARPU_SCHED_NODE_IS_HOMOGENEOUS
+\ingroup API_Modularized_Scheduler
+\def STARPU_SCHED_NODE_HOMOGENEOUS
+     indicate if node is homogeneous
+\def STARPU_SCHED_NODE_IS_SINGLE_MEMORY_NODE
+\ingroup API_Modularized_Scheduler
+     indicate if all workers have the same memory node
+
+
 \struct starpu_sched_tree
 \ingroup API_Modularized_Scheduler
 The actual scheduler

+ 12 - 4
include/starpu_sched_node.h

@@ -63,10 +63,6 @@ struct starpu_sched_node
 	 */
 	struct starpu_bitmap * workers_in_ctx;
 	
-	/* is_homogeneous is 0 iff workers in the node's subtree are heterogeneous,
-	 * this field is set and updated automaticaly, you shouldn't write on it
-	 */
-	int is_homogeneous;
 	/* node's private data, no restriction on use
 	 */
 	void * data;
@@ -81,6 +77,11 @@ struct starpu_sched_node
 	/* this function is called by starpu_sched_node_destroy just before freeing node
 	 */
 	void (*deinit_data)(struct starpu_sched_node * node);
+	/* is_homogeneous is 0 iff workers in the node's subtree are heterogeneous,
+	 * this field is set and updated automaticaly, you shouldn't write on it
+	 */
+	int properties;
+
 #ifdef STARPU_HAVE_HWLOC
 	/* in case of a hierarchical scheduler, this is set to the part of
 	 * topology that is binded to this node, eg: a numa node for a ws
@@ -89,7 +90,14 @@ struct starpu_sched_node
 	hwloc_obj_t obj;
 #endif
 };
+enum starpu_sched_node_properties
+{
+	STARPU_SCHED_NODE_HOMOGENEOUS = (1<<0),
+	STARPU_SCHED_NODE_SINGLE_MEMORY_NODE = (1<<1)
+};
 
+#define STARPU_SCHED_NODE_IS_HOMOGENEOUS(node) ((node)->properties & STARPU_SCHED_NODE_HOMOGENEOUS)
+#define STARPU_SCHED_NODE_IS_SINGLE_MEMORY_NODE(node) ((node)->properties & STARPU_SCHED_NODE_SINGLE_MEMORY_NODE)
 
 struct starpu_sched_tree
 {

+ 0 - 1
src/sched_policies/node_best_implementation.c

@@ -67,7 +67,6 @@ static int select_best_implementation_push_task(struct starpu_sched_node * node,
 static struct starpu_task * select_best_implementation_pop_task(struct starpu_sched_node * node, unsigned sched_ctx_id)
 {
 	struct starpu_task * t;
-	STARPU_ASSERT(node->is_homogeneous);
 	if(!node->fathers[sched_ctx_id])
 		return NULL;
 	t = node->fathers[sched_ctx_id]->pop_task(node->fathers[sched_ctx_id], sched_ctx_id);

+ 1 - 2
src/sched_policies/node_composed.c

@@ -141,7 +141,6 @@ static void composed_node_notify_change_workers(struct starpu_sched_node * node)
 	struct composed_node * c = node->data;
 	struct starpu_bitmap * workers = node->workers;
 	struct starpu_bitmap * workers_in_ctx = node->workers_in_ctx;
-	int is_homogeneous = node->is_homogeneous;
 	struct starpu_sched_node * n;
 	for(n = c->top; ;n = n->childs[0])
 	{
@@ -151,7 +150,7 @@ static void composed_node_notify_change_workers(struct starpu_sched_node * node)
 		starpu_bitmap_unset_all(n->workers_in_ctx);
 		starpu_bitmap_or(n->workers_in_ctx, workers_in_ctx);
 
-		n->is_homogeneous = is_homogeneous;
+		n->properties = node->properties;
 		if(n == c->bottom)
 			break;
 	}

+ 1 - 1
src/sched_policies/node_fifo.c

@@ -43,7 +43,7 @@ static double fifo_estimated_load(struct starpu_sched_node * node)
 	starpu_pthread_mutex_t * mutex = &data->mutex;
 	double relative_speedup = 0.0;
 	double load;
-	if(node->is_homogeneous)
+	if(STARPU_SCHED_NODE_IS_HOMOGENEOUS(node))
 	{		
 		int first_worker = starpu_bitmap_first(node->workers_in_ctx);
 		relative_speedup = starpu_worker_get_relative_speedup(starpu_worker_get_perf_archtype(first_worker));

+ 2 - 2
src/sched_policies/node_heft.c

@@ -186,7 +186,7 @@ static void heft_notify_change_in_workers(struct starpu_sched_node * node)
 	starpu_bitmap_or(data->no_perf_model_node->workers_in_ctx, node->workers_in_ctx);
 	starpu_bitmap_or(data->no_perf_model_node->workers, node->workers);
 
-	data->no_perf_model_node->is_homogeneous = node->is_homogeneous;
+	data->no_perf_model_node->properties = node->properties;
 
 
 	starpu_bitmap_unset_all(data->calibrating_node->workers_in_ctx);
@@ -195,7 +195,7 @@ static void heft_notify_change_in_workers(struct starpu_sched_node * node)
 	starpu_bitmap_or(data->calibrating_node->workers_in_ctx, node->workers_in_ctx);
 	starpu_bitmap_or(data->calibrating_node->workers, node->workers);
 
-	data->calibrating_node->is_homogeneous = node->is_homogeneous;
+	data->calibrating_node->properties = node->properties;
 }
 void heft_node_deinit_data(struct starpu_sched_node * node)
 {

+ 30 - 13
src/sched_policies/node_sched.c

@@ -344,7 +344,7 @@ int STARPU_WARN_UNUSED_RESULT starpu_sched_node_execute_preds(struct starpu_sche
 				}
 			}
 		}
-		if(node->is_homogeneous)
+		if(STARPU_SCHED_NODE_IS_HOMOGENEOUS(node))
 			break;
 	}
 
@@ -381,6 +381,15 @@ double starpu_sched_node_transfer_length(struct starpu_sched_node * node, struct
 	int nworkers = starpu_bitmap_cardinal(node->workers_in_ctx);
 	double sum = 0.0;
 	int worker;
+	if(STARPU_SCHED_NODE_IS_SINGLE_MEMORY_NODE(node))
+	{
+		unsigned memory_node  = starpu_worker_get_memory_node(starpu_bitmap_first(node->workers_in_ctx));
+		if(task->bundle)
+			return starpu_task_bundle_expected_data_transfer_time(task->bundle,memory_node);
+		else
+			return starpu_task_expected_data_transfer_time(memory_node, task);
+	}
+
 	for(worker = starpu_bitmap_first(node->workers_in_ctx);
 	    worker != -1;
 	    worker = starpu_bitmap_next(node->workers_in_ctx, worker))
@@ -451,27 +460,35 @@ void starpu_sched_node_destroy(struct starpu_sched_node *node)
 	free(node);
 }
 
-/* set the node->is_homogeneous member according to node->workers_in_ctx
- */
-static void set_is_homogeneous(struct starpu_sched_node * node)
+static void set_properties(struct starpu_sched_node * node)
 {
 	STARPU_ASSERT(node);
+	node->properties = 0;
 	STARPU_ASSERT(starpu_bitmap_cardinal(node->workers_in_ctx) > 0);
-	if(starpu_bitmap_cardinal(node->workers_in_ctx) == 1)
-		node->is_homogeneous = 1;
+
 	int worker = starpu_bitmap_first(node->workers_in_ctx);
 	uint32_t first_worker = _starpu_get_worker_struct(worker)->worker_mask;
-
+	unsigned first_memory_node = _starpu_get_worker_struct(worker)->memory_node;
+	int is_homogeneous = 1;
+	int is_all_same_node = 1;
 	for(;
 	    worker != -1;
 	    worker = starpu_bitmap_next(node->workers_in_ctx, worker))		
+	{
 		if(first_worker != _starpu_get_worker_struct(worker)->worker_mask)
-		{
-			node->is_homogeneous = 0;
-			return;
-		}
-	node->is_homogeneous = 1;
+			is_homogeneous = 0;
+		if(first_memory_node != _starpu_get_worker_struct(worker)->memory_node)
+			is_all_same_node = 0;
+	}
+	
+
+	if(is_homogeneous)
+		node->properties |= STARPU_SCHED_NODE_HOMOGENEOUS;
+	if(is_all_same_node)
+		node->properties |= STARPU_SCHED_NODE_SINGLE_MEMORY_NODE;
 }
+
+
 /* recursively set the node->workers member of node's subtree
  */
 void _starpu_sched_node_update_workers(struct starpu_sched_node * node)
@@ -510,7 +527,7 @@ void _starpu_sched_node_update_workers_in_ctx(struct starpu_sched_node * node, u
 				break;
 			}
 	}
-	set_is_homogeneous(node);
+	set_properties(node);
 	node->notify_change_workers(node);
 }