Browse Source

From Lionel: modular sched: factorize send_can_push_to_parents mechanism

Samuel Thibault 8 years ago
parent
commit
6aedd5d9a5

+ 1 - 0
include/starpu_sched_component.h

@@ -93,6 +93,7 @@ int starpu_sched_component_push_task(struct starpu_sched_component *from, struct
 struct starpu_task *starpu_sched_tree_pop_task(unsigned sched_ctx);
 struct starpu_task *starpu_sched_component_pull_task(struct starpu_sched_component *from, struct starpu_sched_component *to);
 struct starpu_task* starpu_sched_component_pump_downstream(struct starpu_sched_component *component, int* success);
+void starpu_sched_component_send_can_push_to_parents(struct starpu_sched_component * component);
 
 void starpu_sched_tree_add_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers);
 void starpu_sched_tree_remove_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers);

+ 2 - 12
src/sched_policies/component_fifo.c

@@ -173,18 +173,8 @@ static struct starpu_task * fifo_pull_task(struct starpu_sched_component * compo
 
 	// When a pop is called, a can_push is called for pushing tasks onto
 	// the empty place of the queue left by the popped task.
-	int i,ret;
-	for(i=0; i < component->nparents; i++)
-	{
-		if(component->parents[i] == NULL)
-			continue;
-		else
-		{
-			ret = component->parents[i]->can_push(component->parents[i]);
-			if(ret)
-				break;
-		}
-	}
+
+	starpu_sched_component_send_can_push_to_parents(component); 
 
 	if(task)
 		return task;

+ 2 - 12
src/sched_policies/component_prio.c

@@ -209,18 +209,8 @@ static struct starpu_task * prio_pull_task(struct starpu_sched_component * compo
 
 	// When a pop is called, a can_push is called for pushing tasks onto
 	// the empty place of the queue left by the popped task.
-	int i,ret;
-	for(i=0; i < component->nparents; i++)
-	{
-		if(component->parents[i] == NULL)
-			continue;
-		else
-		{
-			ret = component->parents[i]->can_push(component->parents[i]);
-			if(ret)
-				break;
-		}
-	}
+
+	starpu_sched_component_send_can_push_to_parents(component); 
 	
 	if(task)
 		return task;

+ 26 - 0
src/sched_policies/component_sched.c

@@ -587,6 +587,32 @@ static void starpu_sched_component_can_pull(struct starpu_sched_component * comp
 		component->children[i]->can_pull(component->children[i]);
 }
 
+
+/* Alternative can_pull which says that this component does not want
+   to pull but prefers that you push. It can be used by decision
+   components, in which decisions are usually taken in their push()
+   functions */
+void starpu_sched_component_send_can_push_to_parents(struct starpu_sched_component * component)
+{
+	STARPU_ASSERT(component);
+	STARPU_ASSERT(!starpu_sched_component_is_worker(component));
+	
+	int i,ret;
+	for(i=0; i < component->nparents; i++)
+	{
+		if(component->parents[i] == NULL)
+			continue;
+		else
+		{
+			ret = component->parents[i]->can_push(component->parents[i]);
+			if(ret)
+				break;
+		}
+	}
+	
+}
+
+
 double starpu_sched_component_estimated_load(struct starpu_sched_component * component)
 {
 	double sum = 0.0;