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

new functions starpu_task_set_implementation() and starpu_task_get_implementation() to be used by schedulers

Nathalie Furmento 12 роки тому
батько
коміт
12aeacef0f

+ 10 - 0
doc/chapters/api.texi

@@ -2288,6 +2288,16 @@ Output on @code{stderr} some statistics on the codelet @var{cl}.
 This function waits until there is no more ready task.
 @end deftypefun
 
+@deftypefun void starpu_task_set_implementation ({struct starpu_task *}@var{task}, unsigned @var{impl})
+This function should be called by schedulers to specify the codelet
+implementation to be executed when executing the task.
+@end deftypefun
+
+@deftypefun unsigned starpu_task_get_implementation ({struct starpu_task *}@var{task})
+This function return the codelet implementation to be executed when
+executing the task.
+@end deftypefun
+
 @c Callbacks: what can we put in callbacks ?
 
 @node Insert Task

+ 3 - 0
include/starpu_task.h

@@ -360,6 +360,9 @@ void starpu_parallel_task_barrier_init(struct starpu_task* task, int workerid);
 /* duplicate the given task */
 struct starpu_task *starpu_task_dup(struct starpu_task *task);
 
+void starpu_task_set_implementation(struct starpu_task *task, unsigned impl);
+unsigned starpu_task_get_implementation(struct starpu_task *task);
+
 #ifdef __cplusplus
 }
 #endif

+ 10 - 0
src/core/task.c

@@ -910,3 +910,13 @@ starpu_opencl_func_t _starpu_task_get_opencl_nth_implementation(struct starpu_co
 {
 	return cl->opencl_funcs[nimpl];
 }
+
+void starpu_task_set_implementation(struct starpu_task *task, unsigned impl)
+{
+	_starpu_get_job_associated_to_task(task)->nimpl = impl;
+}
+
+unsigned starpu_task_get_implementation(struct starpu_task *task)
+{
+	return _starpu_get_job_associated_to_task(task)->nimpl;
+}

+ 8 - 9
src/sched_policies/deque_modeling_policy_data_aware.c

@@ -20,14 +20,13 @@
 /* Distributed queues using performance modeling to assign tasks */
 
 #include <starpu_config.h>
-#include <limits.h>
+#include <starpu_scheduler.h>
+
+#include <common/fxt.h>
+#include <core/task.h>
 
-#include <core/perfmodel/perfmodel.h>
-#include <core/task_bundle.h>
-#include <core/workers.h>
 #include <sched_policies/fifo_queues.h>
-#include <core/perfmodel/perfmodel.h>
-#include <core/debug.h>
+#include <limits.h>
 
 #ifndef DBL_MIN
 #define DBL_MIN __DBL_MIN__
@@ -495,7 +494,7 @@ static int _dm_push_task(struct starpu_task *task, unsigned prio, unsigned sched
 
 	//_STARPU_DEBUG("Scheduler dm: kernel (%u)\n", best_impl);
 
-	_starpu_get_job_associated_to_task(task)->nimpl = best_impl;
+	starpu_task_set_implementation(task, best_impl);
 
 	/* we should now have the best worker in variable "best" */
 	return push_task_on_best_worker(task, best,
@@ -767,7 +766,7 @@ static int _dmda_push_task(struct starpu_task *task, unsigned prio, unsigned sch
 	}
 
 	//_STARPU_DEBUG("Scheduler dmda: kernel (%u)\n", best_impl);
-	 _starpu_get_job_associated_to_task(task)->nimpl = selected_impl;
+	starpu_task_set_implementation(task, selected_impl);
 
 	/* we should now have the best worker in variable "best" */
 	return push_task_on_best_worker(task, best, model_best, transfer_model_best, prio, sched_ctx_id);
@@ -928,7 +927,7 @@ static void dmda_push_task_notify(struct starpu_task *task, int workerid, unsign
 	unsigned memory_node = starpu_worker_get_memory_node(workerid);
 
 	double predicted = starpu_task_expected_length(task, perf_arch,
-			_starpu_get_job_associated_to_task(task)->nimpl);
+						       starpu_task_get_implementation(task));
 
 	double predicted_transfer = starpu_task_expected_data_transfer_time(memory_node, task);
 	starpu_pthread_mutex_t *sched_mutex;

+ 3 - 5
src/sched_policies/eager_central_priority_policy.c

@@ -23,9 +23,8 @@
 
 #include <starpu.h>
 #include <starpu_scheduler.h>
-#include <common/config.h>
-#include <core/workers.h>
-#include <common/utils.h>
+
+#include <common/fxt.h>
 
 #define MIN_LEVEL	(-5)
 #define MAX_LEVEL	(+5)
@@ -109,7 +108,6 @@ static int _starpu_priority_push_task(struct starpu_task *task)
 	struct _starpu_eager_central_prio_data *data = (struct _starpu_eager_central_prio_data*)starpu_sched_ctx_get_policy_data(sched_ctx_id);
 
 	struct _starpu_priority_taskq *taskq = data->taskq;
-	int ret_val = -1;
 	
 
 	STARPU_PTHREAD_MUTEX_LOCK(&data->policy_mutex);
@@ -193,7 +191,7 @@ static struct starpu_task *_starpu_priority_pop_task(unsigned sched_ctx_id)
 					if (starpu_worker_can_execute_task(workerid, task, nimpl))
 					{
 						/* there is some task that we can grab */
-						_starpu_get_job_associated_to_task(task)->nimpl = nimpl;
+						starpu_task_set_implementation(task, nimpl);
 						starpu_task_list_erase(&taskq->taskq[priolevel], task);
 						chosen_task = task;
 						taskq->ntasks[priolevel]--;

+ 5 - 6
src/sched_policies/fifo_queues.c

@@ -18,11 +18,10 @@
 
 /* FIFO queues, ready for use by schedulers */
 
+#include <starpu_scheduler.h>
+
 #include <sched_policies/fifo_queues.h>
-#include <errno.h>
-#include <common/utils.h>
-#include <core/task.h>
-#include <core/workers.h>
+#include <common/fxt.h>
 
 struct _starpu_fifo_taskq *_starpu_create_fifo(void)
 {
@@ -145,7 +144,7 @@ struct starpu_task *_starpu_fifo_pop_task(struct _starpu_fifo_taskq *fifo_queue,
 		for (nimpl = 0; nimpl < STARPU_MAXIMPLEMENTATIONS; nimpl++)
 			if (starpu_worker_can_execute_task(workerid, task, nimpl))
 			{
-				_starpu_get_job_associated_to_task(task)->nimpl = nimpl;
+				starpu_task_set_implementation(task, nimpl);
 				starpu_task_list_erase(&fifo_queue->taskq, task);
 				fifo_queue->ntasks--;
 				_STARPU_TRACE_JOB_POP(task, 0);
@@ -220,7 +219,7 @@ struct starpu_task *_starpu_fifo_pop_every_task(struct _starpu_fifo_taskq *fifo_
 					task->prev = NULL;
 					task->next = NULL;
 				}
-				_starpu_get_job_associated_to_task(task)->nimpl = nimpl;
+				starpu_task_set_implementation(task, nimpl);
 				break;
 			}