Browse Source

add hierarchical heft in sched policies list
bug : a scheduler built with hwloc topology fail if starpu has been
restarted.

move scheduler_maker functions to public interface, documented them
minor bugfix in node_composed

Simon Archipoff 11 years ago
parent
commit
61b17de279

+ 26 - 0
doc/doxygen/chapters/api/modularized_scheduler.doxy

@@ -318,4 +318,30 @@ starpu_sched_node_heft_create parameters
 \fn struct starpu_sched_node * starpu_sched_node_composed_node_create(struct starpu_sched_node_composed_recipe * recipe)
 \ingroup API_Modularized_Scheduler
 	 create a node that behave as all node of recipe where linked. Except that you cant use starpu_sched_node_is_foo function
+	 if recipe contain a single create_foo arg_foo pair, create_foo(arg_foo) is returned instead of a composed node
+
+
+\struct starpu_sched_specs
+\ingroup API_Modularized_Scheduler
+	 Define how build a scheduler according to topology.
+\var starpu_sched_specs::hwloc_machine_composed_sched_node
+     the composed node to put on the top of the scheduler
+\var starpu_sched_specs::hwloc_node_composed_sched_node
+     the composed node to put for each memory node
+\var starpu_sched_specs::hwloc_socket_composed_sched_node
+     the composed node to put for each socket
+\var starpu_sched_specs::hwloc_cache_composed_sched_node
+     the composed node to put for each cache
+     
+\var starpu_sched_specs::worker_composed_sched_node
+     a function that return a starpu_sched_node_composed_recipe to put on top of a worker of type \p archtype
+\var starpu_sched_specs::mix_heterogeneous_workers
+     this flag is a dirty hack because of the poor expressivity of this interface. As example, if you want to build
+     a heft node with a fifo node per numa node, and you also have GPUs, if this flag is set, GPUs will share those fifos.
+     If this flag is not set, a new fifo will be built for each of them (if they have the same starpu_perf_arch and the same
+     numa node it will be shared
+
+\fn struct starpu_sched_tree * starpu_sched_node_make_scheduler(unsigned sched_ctx_id, struct starpu_sched_specs s);
+\ingroup API_Modularized_Scheduler
+	 this function build a scheduler for \p sched_ctx_id according to \p s and the hwloc topology of the machine.
 */

+ 26 - 1
include/starpu_sched_node.h

@@ -242,7 +242,32 @@ struct starpu_sched_node_composed_recipe * starpu_sched_node_create_recipe_singl
 void starpu_sched_recipe_add_node(struct starpu_sched_node_composed_recipe * recipe, struct starpu_sched_node *(*create_node)(void * arg), void * arg);
 
 void starpu_destroy_composed_sched_node_recipe(struct starpu_sched_node_composed_recipe *);
-
 struct starpu_sched_node * starpu_sched_node_composed_node_create(struct starpu_sched_node_composed_recipe * recipe);
 
+
+#ifdef STARPU_HAVE_HWLOC
+/* null pointer mean to ignore a level L of hierarchy, then nodes of levels > L become childs of level L - 1 */
+struct starpu_sched_specs
+{
+	/* hw_loc_machine_composed_sched_node must be set as its the root of the topology */
+	struct starpu_sched_node_composed_recipe * hwloc_machine_composed_sched_node;
+	struct starpu_sched_node_composed_recipe * hwloc_node_composed_sched_node;
+	struct starpu_sched_node_composed_recipe * hwloc_socket_composed_sched_node;
+	struct starpu_sched_node_composed_recipe * hwloc_cache_composed_sched_node;
+
+	/* this member should return a new allocated starpu_sched_node_composed_recipe or NULL
+	 * the starpu_sched_node_composed_recipe_t must not include the worker node
+	 */
+	struct starpu_sched_node_composed_recipe * (*worker_composed_sched_node)(enum starpu_worker_archtype archtype);
+ 
+	/* this flag indicate if heterogenous workers should be brothers or cousins,
+	 * as example, if a gpu and a cpu should share or not there numa node
+	 */
+	int mix_heterogeneous_workers;
+};
+
+struct starpu_sched_tree * starpu_sched_node_make_scheduler(unsigned sched_ctx_id, struct starpu_sched_specs);
+#endif /* STARPU_HAVE_HWLOC */
+
+
 #endif

+ 1 - 2
src/Makefile.am

@@ -133,8 +133,7 @@ noinst_HEADERS = 						\
 	top/starpu_top_connection.h				\
 	top/starpu_top_core.h					\
 	sched_policies/prio_deque.h				\
-	sched_policies/sched_node.h				\
-	sched_policies/scheduler_maker.h			
+	sched_policies/sched_node.h
 
 libstarpu_@STARPU_EFFECTIVE_VERSION@_la_SOURCES = 		\
 	common/barrier.c					\

+ 3 - 1
src/core/sched_policy.c

@@ -33,11 +33,13 @@ int starpu_get_prefetch_flag(void)
 
 static struct starpu_sched_policy *predefined_policies[] =
 {
+#ifdef STARPU_HAVE_HWLOC
+	&_starpu_sched_tree_heft_hierarchical_policy,
+#endif
 	&_starpu_sched_tree_eager_policy,
 	&_starpu_sched_tree_random_policy,
 	&_starpu_sched_tree_ws_policy,
 	&_starpu_sched_tree_heft_policy,
-//	&_starpu_sched_tree_heft_hierarchical_policy,
 	&_starpu_sched_eager_policy,
 	&_starpu_sched_prio_policy,
 	&_starpu_sched_random_policy,

+ 1 - 1
src/core/sched_policy.h

@@ -71,5 +71,5 @@ extern struct starpu_sched_policy _starpu_sched_tree_eager_policy;
 extern struct starpu_sched_policy _starpu_sched_tree_random_policy;
 extern struct starpu_sched_policy _starpu_sched_tree_ws_policy;
 extern struct starpu_sched_policy _starpu_sched_tree_heft_policy;
-//extern struct starpu_sched_policy _starpu_sched_tree_heft_hierarchical_policy;
+extern struct starpu_sched_policy _starpu_sched_tree_heft_hierarchical_policy;
 #endif // __SCHED_POLICY_H__

+ 1 - 2
src/sched_policies/hierarchical_heft.c

@@ -1,6 +1,5 @@
 #include <starpu_sched_node.h>
 #include <core/workers.h>
-#include "scheduler_maker.h"
 
 static struct  starpu_sched_node_composed_recipe *  recipe_for_worker(enum starpu_worker_archtype a STARPU_ATTRIBUTE_UNUSED)
 {
@@ -42,7 +41,7 @@ static void initialize_heft_center_policy(unsigned sched_ctx_id)
 	specs.hwloc_node_composed_sched_node = r;
 	specs.worker_composed_sched_node = recipe_for_worker;
 
-	struct starpu_sched_tree *t = _starpu_make_scheduler(sched_ctx_id, specs);
+	struct starpu_sched_tree *t = starpu_sched_node_make_scheduler(sched_ctx_id, specs);
 
 	starpu_destroy_composed_sched_node_recipe(specs.hwloc_machine_composed_sched_node);
 

+ 1 - 0
src/sched_policies/node_composed.c

@@ -133,6 +133,7 @@ static void composed_node_add_child(struct starpu_sched_node * node, struct star
 static void composed_node_remove_child(struct starpu_sched_node * node, struct starpu_sched_node * child)
 {
 	struct composed_node * c = node->data;
+	starpu_sched_node_remove_child(node, child);
 	c->bottom->remove_child(c->bottom, child);
 }
 

+ 1 - 2
src/sched_policies/scheduler_maker.c

@@ -1,5 +1,4 @@
 #include "sched_node.h"
-#include "scheduler_maker.h"
 #include <starpu_sched_node.h>
 #include <common/list.h>
 #include <stdarg.h>
@@ -210,7 +209,7 @@ static void helper_display_scheduler(FILE* out, unsigned depth, struct starpu_sc
 		helper_display_scheduler(out, depth + 1, node->childs[i]);
 }
 #endif //STARPU_DEVEL
-struct starpu_sched_tree * _starpu_make_scheduler(unsigned sched_ctx_id, struct starpu_sched_specs specs)
+struct starpu_sched_tree * starpu_sched_node_make_scheduler(unsigned sched_ctx_id, struct starpu_sched_specs specs)
 {
 	struct starpu_sched_tree * tree = starpu_sched_tree_create(sched_ctx_id);
 	

+ 0 - 33
src/sched_policies/scheduler_maker.h

@@ -1,33 +0,0 @@
-#include <starpu_config.h>
-#ifdef STARPU_HAVE_HWLOC
-#ifndef __SCHEDULER_MAKER_H__
-#define __SCHEDULER_MAKER_H__
-#include <starpu_sched_node.h>
-#include <common/list.h>
-
-
-
-//null pointer mean to ignore a level L of hierarchy, then nodes of levels > L become childs of level L - 1
-struct starpu_sched_specs
-{
-	//hw_loc_machine_composed_sched_node must be set as its the root of the topology
-	struct starpu_sched_node_composed_recipe * hwloc_machine_composed_sched_node;
-	struct starpu_sched_node_composed_recipe * hwloc_node_composed_sched_node;
-	struct starpu_sched_node_composed_recipe * hwloc_socket_composed_sched_node;
-	struct starpu_sched_node_composed_recipe * hwloc_cache_composed_sched_node;
-
-	/* this member should return a new allocated starpu_sched_node_composed_recipe or NULL
-	 * the starpu_sched_node_composed_recipe_t must not include the worker node
-	 */
-	struct starpu_sched_node_composed_recipe * (*worker_composed_sched_node)(enum starpu_worker_archtype);
-
-	/* this flag indicate if heterogenous workers should be brothers or cousins,
-	 * as exemple, if a gpu and a cpu should share or not there numa node
-	 */
-	int mix_heterogeneous_workers;
-};
-
-struct starpu_sched_tree * _starpu_make_scheduler(unsigned sched_ctx_id, struct starpu_sched_specs);
-
-#endif//#ifndef __SCHEDULER_MAKER_H__
-#endif//#ifdef STARPU_HAVE_HWLOC