瀏覽代碼

Introduce new function starpu_task_clean.

Useful when the user wants to submit several times the same task with as
least overhead as possible. Only unset fields which are initialised in StarPU.
Value set by the user remain unchanded.
Nicolas Collin 13 年之前
父節點
當前提交
55112c9ebd
共有 3 個文件被更改,包括 36 次插入0 次删除
  1. 9 0
      doc/chapters/basic-api.texi
  2. 7 0
      include/starpu_task.h
  3. 20 0
      src/core/task.c

+ 9 - 0
doc/chapters/basic-api.texi

@@ -1592,6 +1592,15 @@ by the task have to be freed by calling
 @code{starpu_task_destroy}.
 @code{starpu_task_destroy}.
 @end deftypefun
 @end deftypefun
 
 
+@deftypefun void starpu_task_clean ({struct starpu_task} *@var{task})
+Clean the task, unset internally initialised fields and let the values
+previously set by the user, like codelet and handles, unchanged.
+It is useful for statically allocated tasks ; when the user wants to execute
+the same operation several times with as least overhead as possible.
+It should be called after explicitly waiting for the task:
+@code{starpu_task_wait} or @code{starpu_task_wait_for_all}.
+@end deftypefun
+
 @deftypefun void starpu_task_deinit ({struct starpu_task} *@var{task})
 @deftypefun void starpu_task_deinit ({struct starpu_task} *@var{task})
 Release all the structures automatically allocated to execute @var{task}, but
 Release all the structures automatically allocated to execute @var{task}, but
 not the task structure itself. It is thus useful for statically allocated tasks
 not the task structure itself. It is thus useful for statically allocated tasks

+ 7 - 0
include/starpu_task.h

@@ -270,6 +270,13 @@ void starpu_task_init(struct starpu_task *task);
  * instance. */
  * instance. */
 void starpu_task_deinit(struct starpu_task *task);
 void starpu_task_deinit(struct starpu_task *task);
 
 
+/* Clean the task, unset internally initialised fields and let the values
+ * previously set by the user, like codelet and handles, unchanged.
+ * It is useful for statically allocated tasks, when submitting the same task
+ * several times with as least overhead as possible is needed.
+ */
+void starpu_task_clean(struct starpu_task *task);
+
 /* Allocate a task structure and initialize it with default values. Tasks
 /* Allocate a task structure and initialize it with default values. Tasks
  * allocated dynamically with starpu_task_create are automatically freed when
  * allocated dynamically with starpu_task_create are automatically freed when
  * the task is terminated. If the destroy flag is explicitely unset, the
  * the task is terminated. If the destroy flag is explicitely unset, the

+ 20 - 0
src/core/task.c

@@ -91,6 +91,26 @@ void starpu_task_deinit(struct starpu_task *task)
 	}
 	}
 }
 }
 
 
+/* Unset fields internally initialised by StarPU and which must be removed
+ * from a submission to the other.
+ * All values previously set by the user, like codelet and handles, remain
+ * unchanged. Profiling is not modified to keep previously processed profiles
+ * as the task will execute the same functions.
+ */
+void starpu_task_clean(struct starpu_task *task)
+{
+	STARPU_ASSERT(task);
+
+	struct _starpu_job *j = (struct _starpu_job *) task->starpu_private;
+
+	/* As a new submission means new job we must unset it */
+	if (j)
+	{
+		_starpu_job_destroy(j);
+		task->starpu_private = NULL;
+	}
+}
+
 struct starpu_task * __attribute__((malloc)) starpu_task_create(void)
 struct starpu_task * __attribute__((malloc)) starpu_task_create(void)
 {
 {
 	struct starpu_task *task;
 	struct starpu_task *task;