Procházet zdrojové kódy

Make starpu schedulers use the internal list type instead of the external list type that has limited support

Samuel Thibault před 8 roky
rodič
revize
fdedfafe52

+ 3 - 1
include/starpu.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2014, 2016  Université de Bordeaux
+ * Copyright (C) 2009-2014, 2016-2017  Université de Bordeaux
  * Copyright (C) 2010-2015  CNRS
  * Copyright (C) 2014, 2016  INRIA
  *
@@ -53,7 +53,9 @@ typedef UINT_PTR uintptr_t;
 #include <starpu_perfmodel.h>
 #include <starpu_worker.h>
 #include <starpu_task.h>
+#ifndef BUILDING_STARPU
 #include <starpu_task_list.h>
+#endif
 #include <starpu_task_util.h>
 #include <starpu_sched_ctx.h>
 #include <starpu_expert.h>

+ 5 - 2
src/common/list.h

@@ -132,8 +132,6 @@
 #define LIST_TYPE(ENAME, DECL) \
   LIST_CREATE_TYPE(ENAME, DECL)
 
-/**@hideinitializer
- * The effective type declaration for lists */
 #define LIST_CREATE_TYPE(ENAME, DECL) \
   /** from automatic type: struct ENAME */ \
   struct ENAME \
@@ -142,6 +140,11 @@
     struct ENAME *_next; /**< @internal next cell */ \
     DECL \
   }; \
+  LIST_CREATE_TYPE_NOSTRUCT(ENAME, _prev, _next)
+
+/**@hideinitializer
+ * The effective type declaration for lists */
+#define LIST_CREATE_TYPE_NOSTRUCT(ENAME, _prev, _next) \
   /** @internal */ \
   struct ENAME##_list \
   { \

+ 1 - 0
src/core/sched_ctx.h

@@ -26,6 +26,7 @@
 #include <common/barrier_counter.h>
 #include <profiling/profiling.h>
 #include <semaphore.h>
+#include <core/task.h>
 #include "sched_ctx_list.h"
 
 #ifdef STARPU_HAVE_HWLOC

+ 7 - 1
src/core/task.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2009-2016  Université de Bordeaux
+ * Copyright (C) 2009-2017  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2013, 2015, 2016  CNRS
  * Copyright (C) 2011, 2014 INRIA
  *
@@ -135,4 +135,10 @@ void _starpu_watchdog_shutdown(void);
 int _starpu_task_wait_for_all_and_return_nb_waited_tasks(void);
 int _starpu_task_wait_for_all_in_ctx_and_return_nb_waited_tasks(unsigned sched_ctx);
 
+
+#ifdef BUILDING_STARPU
+LIST_CREATE_TYPE_NOSTRUCT(starpu_task, prev, next);
+#define __STARPU_TASK_LIST_H__
+#endif
+
 #endif // __CORE_TASK_H__

+ 0 - 1
src/core/workers.c

@@ -34,7 +34,6 @@
 #include <core/task.h>
 #include <datawizard/malloc.h>
 #include <profiling/profiling.h>
-#include <starpu_task_list.h>
 #include <sched_policies/sched_component.h>
 #include <datawizard/memory_nodes.h>
 #include <top/starpu_top_core.h>

+ 24 - 24
src/sched_policies/fifo_queues.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2016  Université de Bordeaux
+ * Copyright (C) 2010-2017  Université de Bordeaux
  * Copyright (C) 2010, 2011, 2013, 2016  CNRS
  * Copyright (C) 2011  Télécom-SudParis
  * Copyright (C) 2016  Uppsala University
@@ -79,16 +79,16 @@ _starpu_fifo_get_exp_len_prev_task_list(struct _starpu_fifo_taskq *fifo_queue, s
 	struct starpu_perfmodel_arch* perf_arch = starpu_worker_get_perf_archtype(workerid, task->sched_ctx);
 	double exp_len = 0.0;
 	
-	if (list->head != NULL)
+	if (list->_head != NULL)
 	{
-		struct starpu_task *current = list->head;
+		struct starpu_task *current = list->_head;
 		struct starpu_task *prev = NULL;
 
-		if (list->head->priority == task->priority &&
-		    list->head->priority == list->tail->priority)
+		if (list->_head->priority == task->priority &&
+		    list->_head->priority == list->_tail->priority)
 		{
 			/* They all have the same priority, the task's place is at the end */
-			prev = list->tail;
+			prev = list->_tail;
 			current = NULL;
 		}
 		else
@@ -107,7 +107,7 @@ _starpu_fifo_get_exp_len_prev_task_list(struct _starpu_fifo_taskq *fifo_queue, s
 			{
 				/* the task's place is between prev and current */
 				struct starpu_task *it;
-				for(it = list->head; it != current; it = it->next)
+				for(it = list->_head; it != current; it = it->next)
 				{
 					exp_len += starpu_task_expected_length(it, perf_arch, nimpl);
 					(*fifo_ntasks) ++;
@@ -115,7 +115,7 @@ _starpu_fifo_get_exp_len_prev_task_list(struct _starpu_fifo_taskq *fifo_queue, s
 			}
 			else
 			{
-				/* the task's place is at the tail of the list */
+				/* the task's place is at the _tail of the list */
 				exp_len = fifo_queue->exp_len;
 				*fifo_ntasks = fifo_queue->ntasks;
 			}
@@ -131,25 +131,25 @@ _starpu_fifo_push_sorted_task(struct _starpu_fifo_taskq *fifo_queue, struct star
 {
 	struct starpu_task_list *list = &fifo_queue->taskq;
 
-	if (list->head == NULL)
+	if (list->_head == NULL)
 	{
-		list->head = task;
-		list->tail = task;
+		list->_head = task;
+		list->_tail = task;
 		task->prev = NULL;
 		task->next = NULL;
 	}
-	else if (list->head->priority == task->priority &&
-		 list->head->priority == list->tail->priority)
+	else if (list->_head->priority == task->priority &&
+		 list->_head->priority == list->_tail->priority)
 	{
 		/* They all have the same priority, just put at the end */
-		list->tail->next = task;
+		list->_tail->next = task;
 		task->next = NULL;
-		task->prev = list->tail;
-		list->tail = task;
+		task->prev = list->_tail;
+		list->_tail = task;
 	}
 	else
 	{
-		struct starpu_task *current = list->head;
+		struct starpu_task *current = list->_head;
 		struct starpu_task *prev = NULL;
 
 		while (current)
@@ -164,10 +164,10 @@ _starpu_fifo_push_sorted_task(struct _starpu_fifo_taskq *fifo_queue, struct star
 		if (prev == NULL)
 		{
 			/* Insert at the front of the list */
-			list->head->prev = task;
+			list->_head->prev = task;
 			task->prev = NULL;
-			task->next = list->head;
-			list->head = task;
+			task->next = list->_head;
+			list->_head = task;
 		}
 		else
 		{
@@ -181,11 +181,11 @@ _starpu_fifo_push_sorted_task(struct _starpu_fifo_taskq *fifo_queue, struct star
 			}
 			else
 			{
-				/* Insert at the tail of the list */
-				list->tail->next = task;
+				/* Insert at the _tail of the list */
+				list->_tail->next = task;
 				task->next = NULL;
-				task->prev = list->tail;
-				list->tail = task;
+				task->prev = list->_tail;
+				list->_tail = task;
 			}
 		}
 	}

+ 2 - 1
src/sched_policies/fifo_queues.h

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2013, 2016  Université de Bordeaux
+ * Copyright (C) 2010-2013, 2016-2017  Université de Bordeaux
  * Copyright (C) 2016  Uppsala University
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@
 #define __FIFO_QUEUES_H__
 
 #include <starpu.h>
+#include <core/task.h>
 
 struct _starpu_fifo_taskq
 {

+ 4 - 4
src/sched_policies/prio_deque.c

@@ -132,25 +132,25 @@ static inline int pred_can_execute(struct starpu_task * t, void * pworkerid)
 /* From the front of the list for the highest priority */
 struct starpu_task * _starpu_prio_deque_pop_task(struct _starpu_prio_deque * pdeque)
 {
-	REMOVE_TASK(pdeque, head, prev, pred_true, STARPU_POISON_PTR);
+	REMOVE_TASK(pdeque, _head, prev, pred_true, STARPU_POISON_PTR);
 }
 struct starpu_task * _starpu_prio_deque_pop_task_for_worker(struct _starpu_prio_deque * pdeque, int workerid)
 {
 	STARPU_ASSERT(pdeque);
 	STARPU_ASSERT(workerid >= 0 && (unsigned) workerid < starpu_worker_get_count());
-	REMOVE_TASK(pdeque, head, prev, pred_can_execute, &workerid);
+	REMOVE_TASK(pdeque, _head, prev, pred_can_execute, &workerid);
 }
 
 /* From the back of the list for the highest priority */
 struct starpu_task * _starpu_prio_deque_deque_task(struct _starpu_prio_deque * pdeque)
 {
 	STARPU_ASSERT(pdeque);
-	REMOVE_TASK(pdeque, tail, next, pred_true, STARPU_POISON_PTR);
+	REMOVE_TASK(pdeque, _tail, next, pred_true, STARPU_POISON_PTR);
 }
 
 struct starpu_task * _starpu_prio_deque_deque_task_for_worker(struct _starpu_prio_deque * pdeque, int workerid)
 {
 	STARPU_ASSERT(pdeque);
 	STARPU_ASSERT(workerid >= 0 && (unsigned) workerid < starpu_worker_get_count());
-	REMOVE_TASK(pdeque, tail, next, pred_can_execute, &workerid);
+	REMOVE_TASK(pdeque, _tail, next, pred_can_execute, &workerid);
 }

+ 1 - 1
src/sched_policies/prio_deque.h

@@ -16,7 +16,7 @@
 #ifndef __PRIO_DEQUE_H__
 #define __PRIO_DEQUE_H__
 #include <starpu.h>
-#include <starpu_task_list.h>
+#include <core/task.h>
 
 
 struct _starpu_prio_list