瀏覽代碼

Disable computation on expected variables for non worker fifo/queue

Adrien Guilbaud 5 年之前
父節點
當前提交
7cbc79fc5b

+ 2 - 0
include/starpu_sched_component.h

@@ -420,6 +420,7 @@ struct starpu_sched_component_fifo_data
 	unsigned ntasks_threshold;
 	double exp_len_threshold;
 	int ready;
+	int exp;
 };
 
 /**
@@ -446,6 +447,7 @@ struct starpu_sched_component_prio_data
 	unsigned ntasks_threshold;
 	double exp_len_threshold;
 	int ready;
+	int exp;
 };
 struct starpu_sched_component *starpu_sched_component_prio_create(struct starpu_sched_tree *tree, struct starpu_sched_component_prio_data *prio_data) STARPU_ATTRIBUTE_MALLOC;
 int starpu_sched_component_is_prio(struct starpu_sched_component *component);

+ 45 - 36
src/sched_policies/component_fifo.c

@@ -28,6 +28,7 @@ struct _starpu_fifo_data
 	unsigned ntasks_threshold;
 	double exp_len_threshold;
 	int ready;
+	int exp;
 };
 
 static void fifo_component_deinit_data(struct starpu_sched_component * component)
@@ -91,25 +92,52 @@ static int fifo_push_local_task(struct starpu_sched_component * component, struc
 	int ret = 0;
 	const double now = starpu_timing_now();
 	STARPU_COMPONENT_MUTEX_LOCK(mutex);
-	double exp_len;
-	if(!isnan(task->predicted))
-		exp_len = fifo->exp_len + task->predicted;
-	else
-		exp_len = fifo->exp_len;
 
-	if ((data->ntasks_threshold != 0 && fifo->ntasks >= data->ntasks_threshold) || (data->exp_len_threshold != 0.0 && exp_len >= data->exp_len_threshold))
+	if(data->exp)
 	{
-		static int warned;
-		if(data->exp_len_threshold != 0.0 && task->predicted > data->exp_len_threshold && !warned)
+		double exp_len;
+		if(!isnan(task->predicted))
+			exp_len = fifo->exp_len + task->predicted;
+		else
+			exp_len = fifo->exp_len;
+
+		if ((data->ntasks_threshold != 0 && fifo->ntasks >= data->ntasks_threshold) || (data->exp_len_threshold != 0.0 && exp_len >= data->exp_len_threshold))
 		{
-			_STARPU_DISP("Warning : a predicted task length (%lf) exceeds the expected length threshold (%lf) of a prio component queue, you should reconsider the value of this threshold. This message will not be printed again for further thresholds exceeding.\n",task->predicted,data->exp_len_threshold);
-			warned = 1;
+			static int warned;
+			if(data->exp_len_threshold != 0.0 && task->predicted > data->exp_len_threshold && !warned)
+			{
+				_STARPU_DISP("Warning : a predicted task length (%lf) exceeds the expected length threshold (%lf) of a prio component queue, you should reconsider the value of this threshold. This message will not be printed again for further thresholds exceeding.\n",task->predicted,data->exp_len_threshold);
+				warned = 1;
+			}
+			STARPU_ASSERT(!is_pushback);
+			ret = 1;
+			STARPU_COMPONENT_MUTEX_UNLOCK(mutex);
+		}
+		else
+		{
+			if(!isnan(task->predicted_transfer))
+			{
+				double end = fifo_estimated_end(component);
+				double tfer_end = now + task->predicted_transfer;
+				if(tfer_end < end)
+					task->predicted_transfer = 0.0;
+				else
+					task->predicted_transfer = tfer_end - end;
+				exp_len += task->predicted_transfer;
+			}
+
+			if(!isnan(task->predicted))
+			{
+				fifo->exp_len = exp_len;
+				fifo->exp_end = fifo->exp_start + fifo->exp_len;
+			}
+			STARPU_ASSERT(!isnan(fifo->exp_end));
+			STARPU_ASSERT(!isnan(fifo->exp_len));
+			STARPU_ASSERT(!isnan(fifo->exp_start));
 		}
-		STARPU_ASSERT(!is_pushback);
-		ret = 1;
-		STARPU_COMPONENT_MUTEX_UNLOCK(mutex);
 	}
-	else
+
+	if(!ret)
 	{
 		if(is_pushback)
 			ret = _starpu_fifo_push_back_task(fifo,task);
@@ -118,27 +146,6 @@ static int fifo_push_local_task(struct starpu_sched_component * component, struc
 			ret = _starpu_fifo_push_task(fifo,task);
 			starpu_sched_component_prefetch_on_node(component, task);
 		}
-
-		if(!isnan(task->predicted_transfer))
-		{
-			double end = fifo_estimated_end(component);
-			double tfer_end = now + task->predicted_transfer;
-			if(tfer_end < end)
-				task->predicted_transfer = 0.0;
-			else
-				task->predicted_transfer = tfer_end - end;
-			exp_len += task->predicted_transfer;
-		}
-
-		if(!isnan(task->predicted))
-		{
-			fifo->exp_len = exp_len;
-			fifo->exp_end = fifo->exp_start + fifo->exp_len;
-		}
-		STARPU_ASSERT(!isnan(fifo->exp_end));
-		STARPU_ASSERT(!isnan(fifo->exp_len));
-		STARPU_ASSERT(!isnan(fifo->exp_start));
-
 		STARPU_COMPONENT_MUTEX_UNLOCK(mutex);
 		if(!is_pushback)
 			component->can_pull(component);
@@ -172,7 +179,7 @@ static struct starpu_task * fifo_pull_task(struct starpu_sched_component * compo
 		task = _starpu_fifo_pop_first_ready_task(fifo, starpu_bitmap_first(to->workers_in_ctx), -1);
 	else
 		task = _starpu_fifo_pop_task(fifo, starpu_worker_get_id_check());
-	if(task)
+	if(task && data->exp)
 	{
 		if(!isnan(task->predicted))
 		{
@@ -271,12 +278,14 @@ struct starpu_sched_component * starpu_sched_component_fifo_create(struct starpu
 		data->ntasks_threshold=params->ntasks_threshold;
 		data->exp_len_threshold=params->exp_len_threshold;
 		data->ready=params->ready;
+		data->exp=params->exp;
 	}
 	else
 	{
 		data->ntasks_threshold=0;
 		data->exp_len_threshold=0.0;
 		data->ready=0;
+		data->exp=0;
 	}
 
 	return component;

+ 48 - 38
src/sched_policies/component_prio.c

@@ -47,6 +47,7 @@ struct _starpu_prio_data
 	unsigned ntasks_threshold;
 	double exp_len_threshold;
 	int ready;
+	int exp;
 };
 
 static void prio_component_deinit_data(struct starpu_sched_component * component)
@@ -107,27 +108,55 @@ static int prio_push_local_task(struct starpu_sched_component * component, struc
 	struct _starpu_prio_data * data = component->data;
 	struct _starpu_prio_deque * prio = &data->prio;
 	starpu_pthread_mutex_t * mutex = &data->mutex;
-	int ret;
+	int ret = 0;
 	const double now = starpu_timing_now();
 	STARPU_COMPONENT_MUTEX_LOCK(mutex);
-	double exp_len;
-	if(!isnan(task->predicted))
-		exp_len = prio->exp_len + task->predicted;
-	else
-		exp_len = prio->exp_len;
 
-	if ((data->ntasks_threshold != 0 && prio->ntasks >= data->ntasks_threshold) || (data->exp_len_threshold != 0.0 && exp_len >= data->exp_len_threshold))
+	if(data->exp)
 	{
-		static int warned;
-		if(data->exp_len_threshold != 0.0 && task->predicted > data->exp_len_threshold && !warned)
+		double exp_len;
+		if(!isnan(task->predicted))
+			exp_len = prio->exp_len + task->predicted;
+		else
+			exp_len = prio->exp_len;
+
+		if ((data->ntasks_threshold != 0 && prio->ntasks >= data->ntasks_threshold) || (data->exp_len_threshold != 0.0 && exp_len >= data->exp_len_threshold))
 		{
-			_STARPU_DISP("Warning : a predicted task length (%lf) exceeds the expected length threshold (%lf) of a prio component queue, you should reconsider the value of this threshold. This message will not be printed again for further thresholds exceeding.\n",task->predicted,data->exp_len_threshold);
-			warned = 1;
+			static int warned;
+			if(data->exp_len_threshold != 0.0 && task->predicted > data->exp_len_threshold && !warned)
+			{
+				_STARPU_DISP("Warning : a predicted task length (%lf) exceeds the expected length threshold (%lf) of a prio component queue, you should reconsider the value of this threshold. This message will not be printed again for further thresholds exceeding.\n",task->predicted,data->exp_len_threshold);
+				warned = 1;
+			}
+			ret = 1;
+			STARPU_COMPONENT_MUTEX_UNLOCK(mutex);
+		}
+		else
+		{
+
+			if(!isnan(task->predicted_transfer))
+			{
+				double end = prio_estimated_end(component);
+				double tfer_end = now + task->predicted_transfer;
+				if(tfer_end < end)
+					task->predicted_transfer = 0.0;
+				else
+					task->predicted_transfer = tfer_end - end;
+				exp_len += task->predicted_transfer;
+			}
+
+			if(!isnan(task->predicted))
+			{
+				prio->exp_len = exp_len;
+				prio->exp_end = prio->exp_start + prio->exp_len;
+			}
+			STARPU_ASSERT(!isnan(prio->exp_end));
+			STARPU_ASSERT(!isnan(prio->exp_len));
+			STARPU_ASSERT(!isnan(prio->exp_start));
 		}
-		ret = 1;
-		STARPU_COMPONENT_MUTEX_UNLOCK(mutex);
 	}
-	else
+
+	if(!ret)
 	{
 		if(is_pushback)
 			ret = _starpu_prio_deque_push_front_task(prio,task);
@@ -137,27 +166,6 @@ static int prio_push_local_task(struct starpu_sched_component * component, struc
 			starpu_sched_component_prefetch_on_node(component, task);
 			STARPU_TRACE_SCHED_COMPONENT_PUSH_PRIO(component, prio->ntasks, exp_len);
 		}
-
-		if(!isnan(task->predicted_transfer))
-		{
-			double end = prio_estimated_end(component);
-			double tfer_end = now + task->predicted_transfer;
-			if(tfer_end < end)
-				task->predicted_transfer = 0.0;
-			else
-				task->predicted_transfer = tfer_end - end;
-			exp_len += task->predicted_transfer;
-		}
-
-		if(!isnan(task->predicted))
-		{
-			prio->exp_len = exp_len;
-			prio->exp_end = prio->exp_start + prio->exp_len;
-		}
-		STARPU_ASSERT(!isnan(prio->exp_end));
-		STARPU_ASSERT(!isnan(prio->exp_len));
-		STARPU_ASSERT(!isnan(prio->exp_start));
-
 		STARPU_COMPONENT_MUTEX_UNLOCK(mutex);
 		if(!is_pushback)
 			component->can_pull(component);
@@ -192,7 +200,7 @@ static struct starpu_task * prio_pull_task(struct starpu_sched_component * compo
 		task = _starpu_prio_deque_deque_first_ready_task(prio, starpu_bitmap_first(to->workers_in_ctx));
 	else
 		task = _starpu_prio_deque_pop_task(prio);
-	if(task)
+	if(task && data->exp)
 	{
 		if(!isnan(task->predicted))
 		{
@@ -226,9 +234,9 @@ static struct starpu_task * prio_pull_task(struct starpu_sched_component * compo
 		prio->exp_end = prio->exp_start + prio->exp_len;
 		if(prio->ntasks == 0)
 			prio->exp_len = 0.0;
-
-		STARPU_TRACE_SCHED_COMPONENT_POP_PRIO(component, prio->ntasks, prio->exp_len);
 	}
+	if(task)
+		STARPU_TRACE_SCHED_COMPONENT_POP_PRIO(component, prio->ntasks, prio->exp_len);
 	STARPU_ASSERT(!isnan(prio->exp_end));
 	STARPU_ASSERT(!isnan(prio->exp_len));
 	STARPU_ASSERT(!isnan(prio->exp_start));
@@ -292,12 +300,14 @@ struct starpu_sched_component * starpu_sched_component_prio_create(struct starpu
 		data->ntasks_threshold=params->ntasks_threshold;
 		data->exp_len_threshold=params->exp_len_threshold;
 		data->ready=params->ready;
+		data->exp=params->exp;
 	}
 	else
 	{
 		data->ntasks_threshold=0;
 		data->exp_len_threshold=0.0;
 		data->ready=0;
+		data->exp=0;
 	}
 
 	return component;

+ 2 - 0
src/sched_policies/modular_ez.c

@@ -281,6 +281,7 @@ void starpu_sched_component_initialize_simple_schedulers(unsigned sched_ctx_id,
 				.ntasks_threshold = ntasks_threshold,
 				.exp_len_threshold = exp_len_threshold,
 				.ready = ready,
+				.exp = 1,
 			};
 
 		struct starpu_sched_component_fifo_data fifo_data =
@@ -288,6 +289,7 @@ void starpu_sched_component_initialize_simple_schedulers(unsigned sched_ctx_id,
 				.ntasks_threshold = ntasks_threshold,
 				.exp_len_threshold = exp_len_threshold,
 				.ready = ready,
+				.exp = 1,
 			};
 
 		/* Create one fifo+eager component pair per choice, below scheduling decision */