Преглед изворни кода

Avoid making dmdasd precisely count the size of non-ready buffers, it does not need it exactly

Samuel Thibault пре 4 година
родитељ
комит
ad3469af27

+ 1 - 1
src/sched_policies/deque_modeling_policy_data_aware.c

@@ -259,7 +259,7 @@ static struct starpu_task *_dmda_pop_task(unsigned sched_ctx_id, int ready)
 #ifdef STARPU_VERBOSE
 		if (task->cl)
 		{
-			size_t non_ready = _starpu_count_non_ready_buffers(task, workerid);
+			int non_ready = _starpu_count_non_ready_buffers(task, workerid);
 			if (non_ready == 0)
 				dt->ready_task_cnt++;
 		}

+ 25 - 2
src/sched_policies/fifo_queues.c

@@ -352,7 +352,7 @@ int _starpu_normalize_prio(int priority, int num_priorities, unsigned sched_ctx_
 	return ((num_priorities-1)/(max-min)) * (priority - min);
 }
 
-size_t _starpu_count_non_ready_buffers(struct starpu_task *task, unsigned worker)
+size_t _starpu_size_non_ready_buffers(struct starpu_task *task, unsigned worker)
 {
 	int cnt = 0;
 	unsigned nbuffers = STARPU_TASK_GET_NBUFFERS(task);
@@ -375,6 +375,29 @@ size_t _starpu_count_non_ready_buffers(struct starpu_task *task, unsigned worker
 	return cnt;
 }
 
+int _starpu_count_non_ready_buffers(struct starpu_task *task, unsigned worker)
+{
+	int cnt = 0;
+	unsigned nbuffers = STARPU_TASK_GET_NBUFFERS(task);
+	unsigned index;
+
+	for (index = 0; index < nbuffers; index++)
+	{
+		starpu_data_handle_t handle;
+		unsigned buffer_node = _starpu_task_data_get_node_on_worker(task, index, worker);
+
+		handle = STARPU_TASK_GET_HANDLE(task, index);
+
+		int is_valid;
+		starpu_data_query_status(handle, buffer_node, NULL, &is_valid, NULL);
+
+		if (!is_valid)
+			cnt++;
+	}
+
+	return cnt;
+}
+
 struct starpu_task *_starpu_fifo_pop_first_ready_task(struct _starpu_fifo_taskq *fifo_queue, unsigned workerid, int num_priorities)
 {
 	struct starpu_task *task = NULL, *current;
@@ -400,7 +423,7 @@ struct starpu_task *_starpu_fifo_pop_first_ready_task(struct _starpu_fifo_taskq
 
 			if (priority >= first_task_priority)
 			{
-				size_t non_ready = _starpu_count_non_ready_buffers(current, workerid);
+				size_t non_ready = _starpu_size_non_ready_buffers(current, workerid);
 				if (non_ready < non_ready_best)
 				{
 					non_ready_best = non_ready;

+ 2 - 1
src/sched_policies/fifo_queues.h

@@ -68,7 +68,8 @@ struct starpu_task *_starpu_fifo_pop_task(struct _starpu_fifo_taskq *fifo, int w
 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);
-size_t _starpu_count_non_ready_buffers(struct starpu_task *task, unsigned worker);
+int _starpu_count_non_ready_buffers(struct starpu_task *task, unsigned worker);
+size_t _starpu_size_non_ready_buffers(struct starpu_task *task, unsigned worker);
 struct starpu_task *_starpu_fifo_pop_first_ready_task(struct _starpu_fifo_taskq *fifo_queue, unsigned workerid, int num_priorities);
 
 #endif // __FIFO_QUEUES_H__

+ 1 - 1
src/sched_policies/prio_deque.c

@@ -104,7 +104,7 @@ struct starpu_task *_starpu_prio_deque_deque_first_ready_task(struct _starpu_pri
 
 			if (priority >= first_task_priority)
 			{
-				size_t non_ready = _starpu_count_non_ready_buffers(current, workerid);
+				size_t non_ready = _starpu_size_non_ready_buffers(current, workerid);
 				if (non_ready < non_ready_best)
 				{
 					non_ready_best = non_ready;