瀏覽代碼

Reorganize the code of the scheduling policies: to stress the fact that
scheduler needs not be part of the scheduler, we now have a src/sched_policies/
directory.

Cédric Augonnet 15 年之前
父節點
當前提交
56e595124e

+ 11 - 17
src/Makefile.am

@@ -58,15 +58,7 @@ noinst_HEADERS = 						\
 	core/dependencies/tags.h				\
 	core/dependencies/htable.h				\
 	core/dependencies/implicit_data_deps.h			\
-	core/policies/eager_central_priority_policy.h		\
 	core/sched_policy.h					\
-	core/policies/random_policy.h				\
-	core/policies/eager_central_policy.h			\
-	core/policies/work_stealing_policy.h			\
-	core/mechanisms/priority_queues.h			\
-	core/mechanisms/fifo_queues.h				\
-	core/mechanisms/deque_queues.h				\
-	core/mechanisms/stack_queues.h				\
 	core/perfmodel/perfmodel.h				\
 	core/perfmodel/regression.h				\
 	core/jobs.h						\
@@ -75,6 +67,9 @@ noinst_HEADERS = 						\
 	core/topology.h						\
 	core/debug.h						\
 	core/errorcheck.h					\
+	sched_policies/fifo_queues.h				\
+	sched_policies/deque_queues.h				\
+	sched_policies/stack_queues.h				\
 	datawizard/footprint.h					\
 	datawizard/datawizard.h					\
 	datawizard/data_request.h				\
@@ -126,20 +121,19 @@ libstarpu_la_SOURCES = 						\
 	core/dependencies/task_deps.c				\
 	core/dependencies/htable.c				\
 	core/dependencies/data_concurrency.c			\
-	core/mechanisms/stack_queues.c				\
-	core/mechanisms/deque_queues.c				\
-	core/mechanisms/priority_queues.c			\
-	core/mechanisms/fifo_queues.c				\
 	core/perfmodel/perfmodel_history.c			\
 	core/perfmodel/perfmodel_bus.c				\
 	core/perfmodel/perfmodel.c				\
 	core/perfmodel/regression.c				\
-	core/policies/eager_central_policy.c			\
-	core/policies/eager_central_priority_policy.c		\
-	core/policies/work_stealing_policy.c			\
 	core/sched_policy.c					\
-	core/policies/random_policy.c				\
-	core/policies/deque_modeling_policy_data_aware.c	\
+	sched_policies/eager_central_policy.c			\
+	sched_policies/eager_central_priority_policy.c		\
+	sched_policies/work_stealing_policy.c			\
+	sched_policies/deque_modeling_policy_data_aware.c	\
+	sched_policies/random_policy.c				\
+	sched_policies/stack_queues.c				\
+	sched_policies/deque_queues.c				\
+	sched_policies/fifo_queues.c				\
 	drivers/driver_common/driver_common.c			\
 	datawizard/memory_nodes.c				\
 	datawizard/write_back.c					\

+ 0 - 46
src/core/mechanisms/priority_queues.c

@@ -1,46 +0,0 @@
-/*
- * StarPU
- * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU Lesser General Public License in COPYING.LGPL for more details.
- */
-
-#include <starpu.h>
-#include <common/config.h>
-#include <core/mechanisms/priority_queues.h>
-#include <common/utils.h>
-
-/*
- * Centralized queue with priorities 
- */
-
-struct starpu_priority_taskq_s *_starpu_create_priority_taskq(void)
-{
-	struct starpu_priority_taskq_s *central_queue;
-	
-	central_queue = malloc(sizeof(struct starpu_priority_taskq_s));
-	central_queue->total_ntasks = 0;
-
-	unsigned prio;
-	for (prio = 0; prio < NPRIO_LEVELS; prio++)
-	{
-		starpu_task_list_init(&central_queue->taskq[prio]);
-		central_queue->ntasks[prio] = 0;
-	}
-
-	return central_queue;
-}
-
-void _starpu_destroy_priority_taskq(struct starpu_priority_taskq_s *priority_queue)
-{
-	free(priority_queue);
-}

+ 0 - 39
src/core/mechanisms/priority_queues.h

@@ -1,39 +0,0 @@
-/*
- * StarPU
- * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU Lesser General Public License in COPYING.LGPL for more details.
- */
-
-#ifndef __PRIORITY_QUEUES_H__
-#define __PRIORITY_QUEUES_H__
-
-#include <starpu.h>
-#include <common/config.h>
-
-#define NPRIO_LEVELS	((STARPU_MAX_PRIO) - (STARPU_MIN_PRIO) + 1)
-
-struct starpu_priority_taskq_s {
-	/* the actual lists 
-	 *	taskq[p] is for priority [p - STARPU_MIN_PRIO] */
-	struct starpu_task_list taskq[NPRIO_LEVELS];
-	unsigned ntasks[NPRIO_LEVELS];
-
-	unsigned total_ntasks;
-};
-
-struct starpu_priority_taskq_s *_starpu_create_priority_taskq(void);
-void _starpu_destroy_priority_taskq(struct starpu_priority_taskq_s *priority_queue);
-
-void _starpu_init_priority_queues_mechanisms(void);
-
-#endif // __PRIORITY_QUEUES_H__

+ 0 - 26
src/core/policies/eager_central_policy.h

@@ -1,26 +0,0 @@
-/*
- * StarPU
- * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU Lesser General Public License in COPYING.LGPL for more details.
- */
-
-#ifndef __EAGER_CENTRAL_POLICY_H__
-#define __EAGER_CENTRAL_POLICY_H__
-
-#include <core/workers.h>
-#include <core/mechanisms/fifo_queues.h>
-
-extern struct starpu_sched_policy_s _starpu_sched_eager_policy;
-extern struct starpu_sched_policy_s _starpu_sched_no_prio_policy;
-
-#endif // __EAGER_CENTRAL_POLICY_H__

+ 0 - 25
src/core/policies/eager_central_priority_policy.h

@@ -1,25 +0,0 @@
-/*
- * StarPU
- * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU Lesser General Public License in COPYING.LGPL for more details.
- */
-
-#ifndef __EAGER_CENTRAL_PRIORITY_POLICY_H__
-#define __EAGER_CENTRAL_PRIORITY_POLICY_H__
-
-#include <core/workers.h>
-#include <core/mechanisms/priority_queues.h>
-
-extern struct starpu_sched_policy_s _starpu_sched_prio_policy;
-
-#endif // __EAGER_CENTRAL_PRIORITY_POLICY_H__

+ 0 - 25
src/core/policies/random_policy.h

@@ -1,25 +0,0 @@
-/*
- * StarPU
- * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU Lesser General Public License in COPYING.LGPL for more details.
- */
-
-#ifndef __RANDOM_POLICY_H__
-#define __RANDOM_POLICY_H__
-
-#include <core/workers.h>
-#include <core/mechanisms/fifo_queues.h>
-
-extern struct starpu_sched_policy_s _starpu_sched_random_policy;
-
-#endif // __RANDOM_POLICY_H__

+ 0 - 25
src/core/policies/work_stealing_policy.h

@@ -1,25 +0,0 @@
-/*
- * StarPU
- * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU Lesser General Public License in COPYING.LGPL for more details.
- */
-
-#ifndef __WORK_STEALING_POLICY_H__
-#define __WORK_STEALING_POLICY_H__
-
-#include <core/workers.h>
-#include <core/mechanisms/deque_queues.h>
-
-extern struct starpu_sched_policy_s _starpu_sched_ws_policy;
-
-#endif // __WORK_STEALING_POLICY_H__

+ 1 - 1
src/core/policies/deque_modeling_policy_data_aware.c

@@ -15,7 +15,7 @@
  */
 
 #include <core/workers.h>
-#include <core/mechanisms/fifo_queues.h>
+#include <sched_policies/fifo_queues.h>
 #include <core/perfmodel/perfmodel.h>
 
 static unsigned nworkers;

+ 1 - 1
src/core/mechanisms/deque_queues.c

@@ -17,7 +17,7 @@
 #include <starpu.h>
 #include <common/config.h>
 #include <core/workers.h>
-#include <core/mechanisms/deque_queues.h>
+#include <sched_policies/deque_queues.h>
 #include <errno.h>
 #include <common/utils.h>
 

src/core/mechanisms/deque_queues.h → src/sched_policies/deque_queues.h


+ 2 - 1
src/core/policies/eager_central_policy.c

@@ -14,7 +14,8 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <core/policies/eager_central_policy.h>
+#include <core/workers.h>
+#include <sched_policies/fifo_queues.h>
 
 /*
  *	This is just the trivial policy where every worker use the same

+ 41 - 1
src/core/policies/eager_central_priority_policy.c

@@ -14,7 +14,21 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <core/policies/eager_central_priority_policy.h>
+#include <starpu.h>
+#include <common/config.h>
+#include <core/workers.h>
+#include <common/utils.h>
+
+#define NPRIO_LEVELS	((STARPU_MAX_PRIO) - (STARPU_MIN_PRIO) + 1)
+
+struct starpu_priority_taskq_s {
+	/* the actual lists 
+	 *	taskq[p] is for priority [p - STARPU_MIN_PRIO] */
+	struct starpu_task_list taskq[NPRIO_LEVELS];
+	unsigned ntasks[NPRIO_LEVELS];
+
+	unsigned total_ntasks;
+};
 
 /* the former is the actual queue, the latter some container */
 static struct starpu_priority_taskq_s *taskq;
@@ -24,6 +38,32 @@ static struct starpu_priority_taskq_s *taskq;
 static pthread_cond_t global_sched_cond;
 static pthread_mutex_t global_sched_mutex;
 
+/*
+ * Centralized queue with priorities 
+ */
+
+static struct starpu_priority_taskq_s *_starpu_create_priority_taskq(void)
+{
+	struct starpu_priority_taskq_s *central_queue;
+	
+	central_queue = malloc(sizeof(struct starpu_priority_taskq_s));
+	central_queue->total_ntasks = 0;
+
+	unsigned prio;
+	for (prio = 0; prio < NPRIO_LEVELS; prio++)
+	{
+		starpu_task_list_init(&central_queue->taskq[prio]);
+		central_queue->ntasks[prio] = 0;
+	}
+
+	return central_queue;
+}
+
+static void _starpu_destroy_priority_taskq(struct starpu_priority_taskq_s *priority_queue)
+{
+	free(priority_queue);
+}
+
 static void initialize_eager_center_priority_policy(struct starpu_machine_topology_s *topology, 
 			__attribute__ ((unused))	struct starpu_sched_policy_s *_policy) 
 {

+ 1 - 1
src/core/mechanisms/fifo_queues.c

@@ -15,7 +15,7 @@
  */
 
 #include <pthread.h>
-#include <core/mechanisms/fifo_queues.h>
+#include <sched_policies/fifo_queues.h>
 #include <errno.h>
 #include <common/utils.h>
 #include <core/task.h>

src/core/mechanisms/fifo_queues.h → src/sched_policies/fifo_queues.h


+ 2 - 1
src/core/policies/random_policy.c

@@ -14,7 +14,8 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <core/policies/random_policy.h>
+#include <core/workers.h>
+#include <sched_policies/fifo_queues.h>
 
 static unsigned nworkers;
 static struct starpu_fifo_taskq_s *queue_array[STARPU_NMAXWORKERS];

+ 1 - 1
src/core/mechanisms/stack_queues.c

@@ -15,7 +15,7 @@
  */
 
 #include <starpu.h>
-#include <core/mechanisms/stack_queues.h>
+#include <sched_policies/stack_queues.h>
 #include <errno.h>
 #include <common/utils.h>
 

src/core/mechanisms/stack_queues.h → src/sched_policies/stack_queues.h


+ 2 - 4
src/core/policies/work_stealing_policy.c

@@ -14,10 +14,8 @@
  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  */
 
-#include <core/policies/work_stealing_policy.h>
-
-/* save the general machine configuration */
-//static struct starpu_machine_config_s *machineconfig;
+#include <core/workers.h>
+#include <sched_policies/deque_queues.h>
 
 static unsigned nworkers;
 static unsigned rr_worker;