Bladeren bron

Fix in fifo node : we need to wake up only one worker after an available call, not all

Marc Sergent 11 jaren geleden
bovenliggende
commit
e9495492e9
3 gewijzigde bestanden met toevoegingen van 40 en 2 verwijderingen
  1. 3 0
      include/starpu_sched_node.h
  2. 1 2
      src/sched_policies/node_fifo.c
  3. 36 0
      src/sched_policies/node_sched.c

+ 3 - 0
include/starpu_sched_node.h

@@ -207,6 +207,9 @@ void starpu_sched_tree_update_workers(struct starpu_sched_tree * t);
 /* idem for workers_in_ctx 
  */
 void starpu_sched_tree_update_workers_in_ctx(struct starpu_sched_tree * t);
+/* wake up one underlaying workers of node which can execute the task
+ */
+void starpu_sched_node_wake_available_worker(struct starpu_sched_node * node, struct starpu_task * task );
 /* wake up underlaying workers of node
  */
 void starpu_sched_node_available(struct starpu_sched_node * node);

+ 1 - 2
src/sched_policies/node_fifo.c

@@ -110,7 +110,7 @@ static int fifo_push_task(struct starpu_sched_node * node, struct starpu_task *
 	STARPU_ASSERT(!isnan(fifo->exp_start));
 	STARPU_PTHREAD_MUTEX_UNLOCK(mutex);
 
-	starpu_sched_node_available(node);
+	starpu_sched_node_wake_available_worker(node,task);
 
 	return ret;
 }
@@ -125,7 +125,6 @@ static struct starpu_task * fifo_pop_task(struct starpu_sched_node * node, unsig
 	struct starpu_task * task = _starpu_prio_deque_pop_task_for_worker(fifo, starpu_worker_get_id());
 	if(task)
 	{
-
 		if(!isnan(task->predicted))
 		{
 			fifo->exp_start = starpu_timing_now() + task->predicted;

+ 36 - 0
src/sched_policies/node_sched.c

@@ -35,9 +35,12 @@ static void wake_simple_worker(int workerid)
 	if(workerid == starpu_worker_get_id())
 		return;
 	starpu_worker_get_sched_condition(workerid, &sched_mutex, &sched_cond);
+	starpu_wakeup_worker(workerid, sched_cond, sched_mutex);
+	/*
 	STARPU_PTHREAD_MUTEX_LOCK(sched_mutex);
 	STARPU_PTHREAD_COND_SIGNAL(sched_cond);
 	STARPU_PTHREAD_MUTEX_UNLOCK(sched_mutex);
+	*/
 }
 
 /* wake up all workers of a combined workers
@@ -62,6 +65,39 @@ static void wake_combined_worker(int workerid)
  * because this wouldn't have sense
  * and should dead lock
  */
+void starpu_sched_node_wake_available_worker(struct starpu_sched_node * node, struct starpu_task * task)
+{
+	(void)node;
+	STARPU_ASSERT(node);
+	STARPU_ASSERT(!starpu_sched_node_is_worker(node));
+#ifndef STARPU_NON_BLOCKING_DRIVERS
+	int i;
+	unsigned nimpl;
+	for(i = starpu_bitmap_first(node->workers_in_ctx);
+	    i != -1;
+	    i = starpu_bitmap_next(node->workers_in_ctx, i))
+	{
+		for (nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
+		{
+			if (starpu_worker_can_execute_task(i, task, nimpl))
+			{
+				if(i < (int) starpu_worker_get_count())
+					wake_simple_worker(i);
+				else
+					wake_combined_worker(i);
+				goto out;
+			}
+		}
+	}
+out:
+#endif
+}
+
+
+/* this function must not be called on worker nodes :
+ * because this wouldn't have sense
+ * and should dead lock
+ */
 void starpu_sched_node_available(struct starpu_sched_node * node)
 {
 	(void)node;