Browse Source

sched: Add do_schedule component method

Samuel Thibault 4 years ago
parent
commit
ae072d946e
2 changed files with 30 additions and 0 deletions
  1. 10 0
      include/starpu_sched_component.h
  2. 20 0
      src/sched_policies/component_sched.c

+ 10 - 0
include/starpu_sched_component.h

@@ -138,6 +138,11 @@ struct starpu_sched_component
 	*/
 	*/
 	int (*can_pull)(struct starpu_sched_component *component);
 	int (*can_pull)(struct starpu_sched_component *component);
 
 
+	/**
+	   This function is called when starpu_do_schedule() is called by the application.
+	*/
+	void (*do_schedule)(struct starpu_sched_component *component);
+
 	int (*notify)(struct starpu_sched_component* component, int message_ID, void* arg);
 	int (*notify)(struct starpu_sched_component* component, int message_ID, void* arg);
 
 
 	/**
 	/**
@@ -260,6 +265,11 @@ void starpu_sched_tree_add_workers(unsigned sched_ctx_id, int *workerids, unsign
 void starpu_sched_tree_remove_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers);
 void starpu_sched_tree_remove_workers(unsigned sched_ctx_id, int *workerids, unsigned nworkers);
 
 
 /**
 /**
+   Run the do_schedule method of the components. This is a helper for starpu_sched_policy::do_schedule.
+*/
+void starpu_sched_tree_do_schedule(unsigned sched_ctx_id);
+
+/**
    Attach component \p child to parent \p parent. Some component may accept only one child, others accept several (e.g. MCT)
    Attach component \p child to parent \p parent. Some component may accept only one child, others accept several (e.g. MCT)
 */
 */
 void starpu_sched_component_connect(struct starpu_sched_component *parent, struct starpu_sched_component *child);
 void starpu_sched_component_connect(struct starpu_sched_component *parent, struct starpu_sched_component *child);

+ 20 - 0
src/sched_policies/component_sched.c

@@ -468,6 +468,26 @@ void starpu_sched_tree_remove_workers(unsigned sched_ctx_id, int *workerids, uns
 	STARPU_COMPONENT_MUTEX_UNLOCK(&t->lock);
 	STARPU_COMPONENT_MUTEX_UNLOCK(&t->lock);
 }
 }
 
 
+static void _starpu_sched_tree_do_schedule(struct starpu_sched_component *component)
+{
+	unsigned i;
+
+	if (component->do_schedule)
+		component->do_schedule(component);
+
+	for (i = 0; i < component->nchildren; i++)
+		_starpu_sched_tree_do_schedule(component->children[i]);
+}
+
+void starpu_sched_tree_do_schedule(unsigned sched_ctx_id)
+{
+	STARPU_ASSERT(sched_ctx_id < STARPU_NMAX_SCHED_CTXS);
+	struct starpu_sched_tree * t = starpu_sched_ctx_get_policy_data(sched_ctx_id);
+
+	if (t->root)
+		_starpu_sched_tree_do_schedule(t->root);
+}
+
 static struct starpu_sched_tree *trees[STARPU_NMAX_SCHED_CTXS];
 static struct starpu_sched_tree *trees[STARPU_NMAX_SCHED_CTXS];
 
 
 struct starpu_sched_tree * starpu_sched_tree_create(unsigned sched_ctx_id)
 struct starpu_sched_tree * starpu_sched_tree_create(unsigned sched_ctx_id)