Browse Source

dmdar: Also prefer tasks which have their data already allocated

Samuel Thibault 4 years ago
parent
commit
48ca06e40f
3 changed files with 30 additions and 11 deletions
  1. 18 7
      src/sched_policies/fifo_queues.c
  2. 1 1
      src/sched_policies/fifo_queues.h
  3. 11 3
      src/sched_policies/prio_deque.c

+ 18 - 7
src/sched_policies/fifo_queues.c

@@ -355,9 +355,9 @@ int _starpu_normalize_prio(int priority, int num_priorities, unsigned sched_ctx_
 	return ((num_priorities-1)/(max-min)) * (priority - min);
 }
 
-void _starpu_size_non_ready_buffers(struct starpu_task *task, unsigned worker, size_t *non_readyp, size_t *non_loadingp)
+void _starpu_size_non_ready_buffers(struct starpu_task *task, unsigned worker, size_t *non_readyp, size_t *non_allocatedp, size_t *non_loadingp)
 {
-	size_t non_ready = 0, non_loading = 0;
+	size_t non_ready = 0, non_allocated = 0, non_loading = 0;
 	unsigned nbuffers = STARPU_TASK_GET_NBUFFERS(task);
 	unsigned index;
 
@@ -368,18 +368,21 @@ void _starpu_size_non_ready_buffers(struct starpu_task *task, unsigned worker, s
 
 		handle = STARPU_TASK_GET_HANDLE(task, index);
 
-		int is_valid, is_loading;
-		starpu_data_query_status2(handle, buffer_node, NULL, &is_valid, &is_loading, NULL);
+		int is_allocated, is_valid, is_loading;
+		starpu_data_query_status2(handle, buffer_node, &is_allocated, &is_valid, &is_loading, NULL);
 
 		if (!is_valid)
 		{
 			non_ready+=starpu_data_get_size(handle);
+			if (!is_allocated)
+				non_allocated+=starpu_data_get_size(handle);
 			if (!is_loading)
 				non_loading+=starpu_data_get_size(handle);
 		}
 	}
 
 	*non_readyp = non_ready;
+	*non_allocatedp = non_allocated;
 	*non_loadingp = non_loading;
 }
 
@@ -424,6 +427,7 @@ struct starpu_task *_starpu_fifo_pop_first_ready_task(struct _starpu_fifo_taskq
 		int first_task_priority = task->priority;
 
 		size_t non_ready_best = SIZE_MAX;
+		size_t non_allocated_best = SIZE_MAX;
 		size_t non_loading_best = SIZE_MAX;
 
 		for (current = task; current; current = current->next)
@@ -432,18 +436,25 @@ struct starpu_task *_starpu_fifo_pop_first_ready_task(struct _starpu_fifo_taskq
 
 			if (priority >= first_task_priority)
 			{
-				size_t non_ready, non_loading;
-				_starpu_size_non_ready_buffers(current, workerid, &non_ready, &non_loading);
+				size_t non_allocated, non_ready, non_loading;
+				_starpu_size_non_ready_buffers(current, workerid, &non_ready, &non_allocated, &non_loading);
 				if (non_ready < non_ready_best)
 				{
 					non_ready_best = non_ready;
+					non_allocated_best = non_allocated;
 					non_loading_best = non_loading;
 					task = current;
 
 					if (non_ready == 0)
 						break;
 				}
-				else if (non_ready == non_ready_best && non_loading < non_loading_best)
+				else if (non_ready == non_ready_best && non_allocated < non_allocated_best)
+				{
+					non_allocated_best = non_allocated;
+					non_loading_best = non_loading;
+					task = current;
+				}
+				else if (non_ready == non_ready_best && non_allocated == non_allocated_best && non_loading < non_loading_best)
 				{
 					non_loading_best = non_loading;
 					task = current;

+ 1 - 1
src/sched_policies/fifo_queues.h

@@ -71,7 +71,7 @@ struct starpu_task *_starpu_fifo_pop_local_task(struct _starpu_fifo_taskq *fifo)
 struct starpu_task *_starpu_fifo_pop_every_task(struct _starpu_fifo_taskq *fifo, int workerid);
 int _starpu_normalize_prio(int priority, int num_priorities, unsigned sched_ctx_id);
 int _starpu_count_non_ready_buffers(struct starpu_task *task, unsigned worker);
-void _starpu_size_non_ready_buffers(struct starpu_task *task, unsigned worker, size_t *non_ready, size_t *non_loading);
+void _starpu_size_non_ready_buffers(struct starpu_task *task, unsigned worker, size_t *non_ready, size_t *non_allocated, size_t *non_loading);
 struct starpu_task *_starpu_fifo_pop_first_ready_task(struct _starpu_fifo_taskq *fifo_queue, unsigned workerid, int num_priorities);
 
 #pragma GCC visibility pop

+ 11 - 3
src/sched_policies/prio_deque.c

@@ -95,6 +95,7 @@ struct starpu_task *_starpu_prio_deque_deque_first_ready_task(struct _starpu_pri
 
 		int first_task_priority = task->priority;
 		size_t non_ready_best = SIZE_MAX;
+		size_t non_allocated_best = SIZE_MAX;
 		size_t non_loading_best = SIZE_MAX;
 
 		for (current = starpu_task_prio_list_begin(&pdeque->list);
@@ -105,18 +106,25 @@ struct starpu_task *_starpu_prio_deque_deque_first_ready_task(struct _starpu_pri
 
 			if (priority >= first_task_priority)
 			{
-				size_t non_ready, non_loading;
-				_starpu_size_non_ready_buffers(current, workerid, &non_ready, &non_loading);
+				size_t non_ready, non_allocated, non_loading;
+				_starpu_size_non_ready_buffers(current, workerid, &non_ready, &non_allocated, &non_loading);
 				if (non_ready < non_ready_best)
 				{
 					non_ready_best = non_ready;
+					non_allocated_best = non_allocated;
 					non_loading_best = non_loading;
 					task = current;
 
 					if (non_ready == 0)
 						break;
 				}
-				else if (non_ready == non_ready_best && non_loading < non_loading_best)
+				else if (non_ready == non_ready_best && non_allocated < non_allocated_best)
+				{
+					non_allocated_best = non_allocated;
+					non_loading_best = non_loading;
+					task = current;
+				}
+				else if (non_ready == non_ready_best && non_allocated == non_allocated_best && non_loading < non_loading_best)
 				{
 					non_loading_best = non_loading;
 					task = current;