Browse Source

Make work stealing component make sure to push to a child which actually can execute the task

Samuel Thibault 5 years ago
parent
commit
2ac9af6892
1 changed files with 25 additions and 0 deletions
  1. 25 0
      src/sched_policies/component_work_stealing.c

+ 25 - 0
src/sched_policies/component_work_stealing.c

@@ -238,7 +238,32 @@ static int push_task(struct starpu_sched_component * component, struct starpu_ta
 	struct _starpu_component_work_stealing_data * wsd = component->data;
 	int ret;
 	unsigned i = wsd->last_push_child;
+	int found = 0;
+
+	/* Find a child component that can execute this task */
 	i = (i+1)%component->nchildren;
+	while(1) {
+		int workerid;
+		for(workerid = starpu_bitmap_first(component->children[i]->workers_in_ctx);
+		    -1 != workerid;
+		    workerid = starpu_bitmap_next(component->children[i]->workers_in_ctx, workerid))
+		{
+			unsigned impl;
+			int can_execute = starpu_worker_can_execute_task_first_impl(workerid, task, &impl);
+			if (can_execute)
+			{
+				/* Found one, set the implementation by the way */
+				starpu_task_set_implementation(task, impl);
+				found = 1;
+				break;
+			}
+		}
+		if (found)
+			break;
+		STARPU_ASSERT_MSG(i != wsd->last_push_child, "Could not find child able to execute this task");
+		i = (i+1)%component->nchildren;
+	}
+
 	STARPU_COMPONENT_MUTEX_LOCK(wsd->mutexes[i]);
 	starpu_sched_task_break(task);
 	ret = _starpu_prio_deque_push_front_task(wsd->fifos[i], task);