Przeglądaj źródła

Add starpu_sched_component_estimated_end_min_add

This allows to fix completion estimations in smart modular schedulers such
as modular-heft or Lyon people's.
Samuel Thibault 6 lat temu
rodzic
commit
fc2700b62e

+ 2 - 0
ChangeLog

@@ -102,6 +102,8 @@ Small features:
   * Add a new value STARPU_TASK_SYNCHRONOUS to be used in
     starpu_task_insert() to define if the task is (or not) synchronous
   * Add memory states events in the traces.
+  * Add starpu_sched_component_estimated_end_min_add() to fix termination
+    estimations in modular schedulers.
 
 Changes:
   * Vastly improve simgrid simulation time.

+ 8 - 0
doc/doxygen/chapters/api/modularized_scheduler.doxy

@@ -268,6 +268,14 @@ of the children of the component.
 \ingroup API_Modularized_Scheduler
 function that can be used for the estimated_end component method, which just computes the minimum completion time of the children.
 
+\fn double starpu_sched_component_estimated_end_min_add(struct starpu_sched_component * component, double exp_len);
+\ingroup API_Modularized_Scheduler
+function that can be used for the estimated_end component method, which computes
+the minimum completion time of the children, and adds to it an estimation of how
+existing queued work, plus the exp_len work, can be completed. This is typically
+used instead of starpu_sched_component_estimated_end_min when the component
+contains a queue of tasks, which thus needs to be added to the estimations.
+
 \fn double starpu_sched_component_estimated_end_average(struct starpu_sched_component * component);
 \ingroup API_Modularized_Scheduler
 default function for the estimated_end component method, which just computes the average completion time of the children.

+ 1 - 0
include/starpu_sched_component.h

@@ -128,6 +128,7 @@ int starpu_sched_component_can_push(struct starpu_sched_component * component, s
 int starpu_sched_component_can_pull(struct starpu_sched_component * component);
 double starpu_sched_component_estimated_load(struct starpu_sched_component * component);
 double starpu_sched_component_estimated_end_min(struct starpu_sched_component * component);
+double starpu_sched_component_estimated_end_min_add(struct starpu_sched_component * component, double exp_len);
 double starpu_sched_component_estimated_end_average(struct starpu_sched_component * component);
 
 struct starpu_sched_component_fifo_data

+ 1 - 9
src/sched_policies/component_fifo.c

@@ -45,15 +45,7 @@ static double fifo_estimated_end(struct starpu_sched_component * component)
 	STARPU_ASSERT(component && component->data);
 	struct _starpu_fifo_data * data = component->data;
 	struct _starpu_fifo_taskq * fifo = data->fifo;
-	int card = starpu_bitmap_cardinal(component->workers_in_ctx);
-	if (card == 0)
-                /* Oops, no resources to compute our tasks. Let's just hope that
-                 * we will be given one at some point */
-		card = 1;
-	double estimated_end = starpu_sched_component_estimated_end_min(component);
-	estimated_end += fifo->exp_len / card;
-
-	return estimated_end;
+	return starpu_sched_component_estimated_end_min_add(component, fifo->exp_len);
 }
 
 static double fifo_estimated_load(struct starpu_sched_component * component)

+ 1 - 9
src/sched_policies/component_prio.c

@@ -64,15 +64,7 @@ static double prio_estimated_end(struct starpu_sched_component * component)
 	STARPU_ASSERT(component && component->data);
 	struct _starpu_prio_data * data = component->data;
 	struct _starpu_prio_deque * prio = &data->prio;
-	int card = starpu_bitmap_cardinal(component->workers_in_ctx);
-	if (card == 0)
-                /* Oops, no resources to compute our tasks. Let's just hope that
-                 * we will be given one at some point */
-		card = 1;
-	double estimated_end = starpu_sched_component_estimated_end_min(component);
-	estimated_end += prio->exp_len / card;
-
-	return estimated_end;
+	return starpu_sched_component_estimated_end_min_add(component, prio->exp_len);
 }
 
 static double prio_estimated_load(struct starpu_sched_component * component)

+ 23 - 1
src/sched_policies/component_sched.c

@@ -635,10 +635,11 @@ double starpu_sched_component_estimated_load(struct starpu_sched_component * com
 	return sum;
 }
 
-double starpu_sched_component_estimated_end_min(struct starpu_sched_component * component)
+double starpu_sched_component_estimated_end_min_add(struct starpu_sched_component * component, double exp_len)
 {
 	STARPU_ASSERT(component);
 	double min = DBL_MAX;
+	double sum = 0;
 	unsigned i;
 	for(i = 0; i < component->nchildren; i++)
 	{
@@ -646,9 +647,30 @@ double starpu_sched_component_estimated_end_min(struct starpu_sched_component *
 		if(tmp < min)
 			min = tmp;
 	}
+	if (exp_len > 0)
+	{
+		/* We don't know which workers will do this, assume it will be
+		 * evenly distributed to existing work */
+		int card = starpu_bitmap_cardinal(component->workers_in_ctx);
+		if (card == 0)
+			/* Oops, no resources to compute our tasks. Let's just hope that
+			 * we will be given one at some point */
+			card = 1;
+		for(i = 0; i < component->nchildren; i++)
+		{
+			double tmp = component->children[i]->estimated_end(component->children[i]);
+			exp_len += tmp - min;
+		}
+		min += exp_len / card;
+	}
 	return min;
 }
 
+double starpu_sched_component_estimated_end_min(struct starpu_sched_component * component)
+{
+  return starpu_sched_component_estimated_end_min_add(component, 0.);
+}
+
 double starpu_sched_component_estimated_end_average(struct starpu_sched_component * component)
 {
 	STARPU_ASSERT(component);