Переглянути джерело

more doc, more comments
less bugs in bitmap.c

Simon Archipoff 11 роки тому
батько
коміт
91a7000e93

+ 20 - 14
doc/doxygen/chapters/modularized_scheduler.doxy

@@ -5,44 +5,50 @@
 
 Scheduler are a tree-like structure of homogeneous nodes that each
 provides push and pop primitives. Each node may have one father by
-context, specially worker nodes ase they are shared between all contexts.
+context, specially worker nodes as they are shared between all contexts.
 
 Tasks make a top bottom traversal of tree.
 
 A push call on a node make either a recursive call on one of its
 childs or make the task stored in the node and made available to a
-pop, in this case that node should call available to wake workers
+pop, in this case that node should call starpu_sched_node_available to wake workers
 up. Push must be called on a child, and only if this child can execute
 the task.
 
 A pop call on a node can either return a localy stored task or perform
 a recursive call on its father in its current context. Only workers
-can call pop.
+should call pop.
 
 
 \section Initialization
-The scheduler is initialized with all workers, and workers are then
-added or removed by simply masking them. 
-Scheduler nodes are created by <tt> starpu_sched_node_foo_create(void
-\* arg) </tt>, arg may be stored in starpu_sched_node::data
-The starpu_sched_node::init_data is the last function to be called during
-initialization, it can use starpu_sched_node::workers and
-starpu_sched_node::data.
+Scheduler node are created with the starpu_sched_node_foo_create() functions
+and then must be assembled using them starpu_sched_node::add_child and
+starpu_sched_node::remove_child function.
+A father can be set in order to allow him to be reacheable by a starpu_sched_node::pop_task
+call.
+
+Underlayings workers are memoized in starpu_sched_node::workers. Hence the
+function starpu_sched_tree_update_workers should be called when the scheduler is
+finished, or modified.
+
+\section Adding and removing workers
+
+
+
+
 
 \section Push
 All scheduler node must define a starpu_sched_node::push_task
 function. The caller ensure that the node can realy execute the task.
 
+
 \section Pop
 starpu_sched_node::push_task should either return a local task or
-perform a recursive call on 
+perform a recursive call on
 starpu_sched_node::fathers[sched_ctx_id], or \c NULL if its a root
 node.
 
 
-
-
-
 \section WorkersAndCombinedWorkers Workers and Combined workers
 
 Leafs are either a worker node that is bind to a starpu workers or a

+ 9 - 7
src/sched_policies/README

@@ -1,6 +1,8 @@
-Mutex policy
 
 
+
+Mutex policy
+
 scheduler have to be protected when the hypervisor is modifying it.
 there is a mutex in struct starpu_sched_tree wich should be taken by
 the application to push a task
@@ -11,13 +13,12 @@ The hypervisor must take all of them to modifying the scheduler.
 
 
 
-
 Creation/Destruction
 
-all the struct starpu_sched_node * starpu_sched_node_foo_create()
+All the struct starpu_sched_node * starpu_sched_node_foo_create()
 function return a initialized struct starpu_sched_node.
 
-the void starpu_sched_node_destroy(struct starpu_sched_node * node)
+The void starpu_sched_node_destroy(struct starpu_sched_node * node)
 function call node->deinit_data(node) to free data allocated during
 creation
 
@@ -26,13 +27,16 @@ accessor to garanty unicity of worker nodes. worker_node->workers and
 worker_node->workers_in_ctx should not be modified.
 
 
+
+
+
 Add/Remove workers
+
 I see 2 way for adding/removing workers of the scheduler
 The hypervisor block all the scheduling and modify the scheduler in
 the way it wants, and then update all node->workers_in_ctx bitmaps, and
 all node->push_task should respect it.
 
-
 And the second one may be done in an atomic way. The struct
 starpu_sched_tree hold a struct starpu_bitmap * that represent
 available workers in context. All node can make a call to struct starpu_bitmap
@@ -47,8 +51,6 @@ be better.
 
 
 
-
-
 In several place realloc is used (in prio_deque and for
 starpu_sched_node_add_child), because we should not have a lot
 different priority level nor adding too many childs.

+ 6 - 3
src/sched_policies/bitmap.c

@@ -10,9 +10,10 @@
 
 
 
-struct starpu_bitmap{
+struct starpu_bitmap
+{
 	unsigned long * bits;
-	int size;
+	int size; /* the size of bits array in number of unsigned long */
 	int cardinal;
 };
 
@@ -51,6 +52,8 @@ void starpu_bitmap_set(struct starpu_bitmap * b, int e)
 
 	if(!starpu_bitmap_get(b, e))
 		b->cardinal++;
+	else
+		return;
 	if((e/LONG_BIT) + 1 > b->size)
 	{
 		b->bits = realloc(b->bits, sizeof(unsigned long) * ((e/LONG_BIT) + 1));
@@ -193,7 +196,7 @@ int starpu_bitmap_next(struct starpu_bitmap *b, int e)
 {
 	int nb_long = e / LONG_BIT;
 	int nb_bit = e % LONG_BIT;
-	unsigned long rest = (~0ul << (nb_bit + 1)) & b->bits[nb_long];
+	unsigned long rest = nb_bit == LONG_BIT - 1 ? 0 : (~0ul << (nb_bit + 1)) & b->bits[nb_long];
 	if(nb_bit != (LONG_BIT - 1) && rest)
 	{
 		int i = get_first_bit_rank(rest);