소스 검색

from Lionel: modular sched: factorize and explicit the pump mechanism

Samuel Thibault 8 년 전
부모
커밋
7f623b6344
5개의 변경된 파일39개의 추가작업 그리고 31개의 파일을 삭제
  1. 1 0
      AUTHORS
  2. 2 0
      include/starpu_sched_component.h
  3. 3 15
      src/sched_policies/component_fifo.c
  4. 4 16
      src/sched_policies/component_prio.c
  5. 29 0
      src/sched_policies/component_sched.c

+ 1 - 0
AUTHORS

@@ -10,6 +10,7 @@ Nicolas Collin <nicolas.collin@inria.fr>
 Ludovic Courtès <ludovic.courtes@inria.fr>
 Yann Courtois <yann.courtois33@gmail.com>
 Jean-Marie Couteyen <jm.couteyen@gmail.com>
+Lionel Eyraud-Dubois <lionel.eyraud-dubois@inria.fr>
 Nathalie Furmento <nathalie.furmento@labri.fr>
 David Gómez <david_gomez1380@yahoo.com.mx>
 Sylvain Henry <sylvain.henry@inria.fr>

+ 2 - 0
include/starpu_sched_component.h

@@ -92,6 +92,8 @@ int starpu_sched_tree_push_task(struct starpu_task *task);
 int starpu_sched_component_push_task(struct starpu_sched_component *from, struct starpu_sched_component *to, struct starpu_task *task);
 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_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);
 

+ 3 - 15
src/sched_policies/component_fifo.c

@@ -200,24 +200,12 @@ static struct starpu_task * fifo_pull_task(struct starpu_sched_component * compo
 static int fifo_can_push(struct starpu_sched_component * component)
 {
 	STARPU_ASSERT(component && starpu_sched_component_is_fifo(component));
-	int ret = 0;
 	int res = 0;
+	struct starpu_task * task;
 
-	STARPU_ASSERT(component->nchildren == 1);
-	struct starpu_sched_component * child = component->children[0];
-	struct starpu_task * task = NULL;
+	task = starpu_sched_component_pump_downstream(component, &res); 
 
-	while (1)
-	{
-		task = starpu_sched_component_pull_task(component,component);
-		if (!task)
-			break;
-		ret = starpu_sched_component_push_task(component,child,task);
-		if (ret)
-			break;
-		res = 1;
-	}
-	if(task && ret)
+	if(task)
 		fifo_push_local_task(component,task,1);
 
 	return res;

+ 4 - 16
src/sched_policies/component_prio.c

@@ -221,25 +221,13 @@ static struct starpu_task * prio_pull_task(struct starpu_sched_component * compo
 static int prio_can_push(struct starpu_sched_component * component)
 {
 	STARPU_ASSERT(component && starpu_sched_component_is_prio(component));
-	int ret = 0;
 	int res = 0;
-
-	STARPU_ASSERT(component->nchildren == 1);
-	struct starpu_sched_component * child = component->children[0];
 	struct starpu_task * task;
 
-	while (1)
-	{
-		task = starpu_sched_component_pull_task(component,component);
-		if (!task)
-			break;
-		ret = starpu_sched_component_push_task(component,child,task);	
-		if (ret)
-			break;
-		res = 1;
-	}
-	if(task && ret)
-		prio_push_local_task(component,task,1);
+	task = starpu_sched_component_pump_downstream(component, &res); 
+
+	if(task)
+		STARPU_ASSERT(!prio_push_local_task(component,task,1));
 
 	return res;
 }

+ 29 - 0
src/sched_policies/component_sched.c

@@ -369,6 +369,35 @@ struct starpu_task * starpu_sched_component_pull_task(struct starpu_sched_compon
 	return task;
 }
 
+
+/* Pump mechanic to get the task flow rolling. Takes tasks from component and send them to the child.
+   To be used by components with only one child */
+struct starpu_task* starpu_sched_component_pump_downstream(struct starpu_sched_component *component, int* success) 
+{
+	int ret = 0;
+	
+	STARPU_ASSERT(component->nchildren == 1);
+	struct starpu_sched_component * child = component->children[0];
+	struct starpu_task * task;
+
+	while (1)
+	{
+		task = starpu_sched_component_pull_task(component,component);
+		if (!task)
+			break;
+		ret = starpu_sched_component_push_task(component,child,task);	
+		if (ret)
+			break;
+		if(success) 
+			* success = 1; 
+	}
+	if(task && ret)
+		return task;
+
+	return NULL;
+	
+}
+
 void starpu_sched_tree_add_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers)
 {
 	STARPU_ASSERT(sched_ctx_id < STARPU_NMAX_SCHED_CTXS);