Procházet zdrojové kódy

Export the current state of the task so that the SOCL lib may implement
clGetEventInfo with the EXECUTION_STATUS option.

Cédric Augonnet před 15 roky
rodič
revize
1d223b5abe

+ 10 - 0
include/starpu_task.h

@@ -37,6 +37,13 @@
 #define STARPU_MAX_PRIO        5
 #define STARPU_DEFAULT_PRIO	0
 
+/* task status */
+#define STARPU_TASK_INVALID	0
+#define STARPU_TASK_BLOCKED	1
+#define STARPU_TASK_READY	2
+#define STARPU_TASK_RUNNING	3
+#define STARPU_TASK_FINISHED	4
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -116,6 +123,8 @@ struct starpu_task {
 	 * set too. */ 
 	int regenerate;
 
+	unsigned status;
+
 	struct starpu_task_profiling_info *profiling_info;
 
 	/* this is private to StarPU, do not modify. If the task is allocated
@@ -141,6 +150,7 @@ struct starpu_task {
 	.detach = 1,					\
 	.destroy = 0,					\
 	.regenerate = 0,				\
+	.status = STARPU_TASK_INVALID,			\
 	.profiling_info = NULL,				\
 	.starpu_private = NULL				\
 };

+ 2 - 0
src/core/jobs.c

@@ -117,6 +117,8 @@ void _starpu_handle_job_termination(starpu_job_t j, unsigned job_is_already_lock
 	if (!job_is_already_locked)
 		PTHREAD_MUTEX_LOCK(&j->sync_mutex);
 
+	task->status = STARPU_TASK_FINISHED;
+
 	/* in case there are dependencies, wake up the proper tasks */
 	j->submitted = 0;
 	_starpu_notify_dependencies(j);

+ 6 - 3
src/core/policies/sched_policy.c

@@ -206,18 +206,21 @@ int _starpu_push_task(starpu_job_t j, unsigned job_is_already_locked)
 {
 	struct starpu_jobq_s *queue = policy.starpu_get_local_queue(&policy);
 
+	struct starpu_task *task = j->task;
+
+	task->status = STARPU_TASK_READY;
+
 	/* in case there is no codelet associated to the task (that's a control
 	 * task), we directly execute its callback and enforce the
 	 * corresponding dependencies */
-	if (j->task->cl == NULL)
+	if (task->cl == NULL)
 	{
 		_starpu_handle_job_termination(j, job_is_already_locked);
 		return 0;
 	}
 
-	if (STARPU_UNLIKELY(j->task->execute_on_a_specific_worker))
+	if (STARPU_UNLIKELY(task->execute_on_a_specific_worker))
 	{
-		struct starpu_task *task = j->task;
 		unsigned workerid = task->workerid;
 		struct starpu_worker_s *worker = _starpu_get_worker_struct(workerid);
 		

+ 6 - 0
src/core/task.c

@@ -64,6 +64,8 @@ void starpu_task_init(struct starpu_task *task)
 
 	task->regenerate = 0;
 
+	task->status = STARPU_TASK_INVALID;
+
 	task->profiling_info = NULL;
 
 	task->starpu_private = NULL;
@@ -207,6 +209,10 @@ int starpu_task_submit(struct starpu_task *task)
 	struct starpu_task_profiling_info *info;
 	info = _starpu_allocate_profiling_info_if_needed();
 	task->profiling_info = info;
+
+	/* The task is considered as block until we are sure there remains not
+	 * dependency. */
+	task->status = STARPU_TASK_BLOCKED;
 	
 	if (info)
 		info->submit_time = (int64_t)_starpu_timing_now();

+ 2 - 0
src/drivers/cpu/driver_cpu.c

@@ -68,6 +68,8 @@ static int execute_job_on_cpu(starpu_job_t j, struct starpu_worker_s *cpu_args)
 		start_time = (int64_t)_starpu_timing_now();
 
 	cpu_args->status = STATUS_EXECUTING;
+	task->status = STARPU_TASK_RUNNING;	
+
 	cl_func func = cl->cpu_func;
 	func(task->interface, task->cl_arg);
 

+ 2 - 0
src/drivers/cuda/driver_cuda.c

@@ -138,6 +138,8 @@ static int execute_job_on_cuda(starpu_job_t j, struct starpu_worker_s *args)
 		start_time = (int64_t)_starpu_timing_now();
 
 	args->status = STATUS_EXECUTING;
+	task->status = STARPU_TASK_RUNNING;	
+
 	cl_func func = cl->cuda_func;
 	STARPU_ASSERT(func);
 	STARPU_GET_TICK(codelet_start);

+ 2 - 0
src/drivers/opencl/driver_opencl.c

@@ -388,6 +388,8 @@ static int _starpu_opencl_execute_job(starpu_job_t j, struct starpu_worker_s *ar
 		start_time = (int64_t)_starpu_timing_now();
 
 	args->status = STATUS_EXECUTING;
+	task->status = STARPU_TASK_RUNNING;	
+
 	cl_func func = cl->opencl_func;
 	STARPU_ASSERT(func);
 	STARPU_GET_TICK(codelet_start);