Sfoglia il codice sorgente

sched: Add do_schedule component method

Samuel Thibault 4 anni fa
parent
commit
ae072d946e
2 ha cambiato i file con 30 aggiunte e 0 eliminazioni
  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);
 
+	/**
+	   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);
 
 	/**
@@ -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);
 
 /**
+   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)
 */
 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);
 }
 
+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];
 
 struct starpu_sched_tree * starpu_sched_tree_create(unsigned sched_ctx_id)