瀏覽代碼

Add starpu_task_declare_deps

Samuel Thibault 6 年之前
父節點
當前提交
0b0f8f2a8a

+ 1 - 0
ChangeLog

@@ -116,6 +116,7 @@ Small features:
   * New function starpu_data_partition_not_automatic() to disable the
     automatic partitioning of a data handle for which a asynchronous
     plan has previously been submitted
+  * Add starpu_task_declare_deps.
 
 Changes:
   * Vastly improve simgrid simulation time.

+ 2 - 2
doc/doxygen/chapters/301_tasks.doxy

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2018                                CNRS
- * Copyright (C) 2009-2011,2014-2016                      Université de Bordeaux
+ * Copyright (C) 2009-2011,2014-2016, 2018                      Université de Bordeaux
  * Copyright (C) 2011-2012,2018                           Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -105,7 +105,7 @@ if (sequential_consistency(task) == 1)
 \subsection TasksAndTagsDependencies Tasks And Tags Dependencies
 
 One can explicitely set dependencies between tasks using
-starpu_task_declare_deps_array(). Dependencies between tasks can be
+starpu_task_declare_deps() or starpu_task_declare_deps_array(). Dependencies between tasks can be
 expressed through tags associated to a tag with the field
 starpu_task::tag_id and using the function starpu_tag_declare_deps()
 or starpu_tag_declare_deps_array().

+ 15 - 1
doc/doxygen/chapters/api/explicit_dependencies.doxy

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2010-2013,2015,2017,2018                      CNRS
- * Copyright (C) 2009-2011,2014-2016                      Université de Bordeaux
+ * Copyright (C) 2009-2011,2014-2016, 2018                      Université de Bordeaux
  * Copyright (C) 2011-2012                                Inria
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -32,6 +32,20 @@ call starpu_task_declare_deps_array() several times on the same task,
 in this case, the dependencies are added. It is possible to have
 redundancy in the task dependencies.
 
+\fn void starpu_task_declare_deps(starpu_task *task, unsigned ndeps, ...)
+\ingroup API_Explicit_Dependencies
+Declare task dependencies between a \p task and an series of \p ndeps tasks,
+similarly to starpu_task_declare_deps_array(), but the tasks are passed after \p
+ndeps, which indicates how many tasks \p task shall be made to depend on.
+If \p ndeps is 0, no dependency is added.
+
+Specify the dependencies of the task identified by tag \p id.
+The first argument specifies the tag which is configured, the second
+argument gives the number of tag(s) on which \p id depends. The
+following arguments are the tags which have to be terminated to unlock
+the task. This function must be called before the associated task is
+submitted to StarPU with starpu_task_submit().
+
 \fn int starpu_task_get_task_succs(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[])
 \ingroup API_Explicit_Dependencies
 Fill \p task_array with the list of tasks which are direct children of \p task.

+ 1 - 0
include/starpu_task.h

@@ -303,6 +303,7 @@ struct starpu_task
 void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...);
 void starpu_tag_declare_deps_array(starpu_tag_t id, unsigned ndeps, starpu_tag_t *array);
 
+void starpu_task_declare_deps(struct starpu_task *task, unsigned ndeps, ...);
 void starpu_task_declare_deps_array(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[]);
 
 void starpu_task_end_dep_add(struct starpu_task *t, int nb_deps);

+ 15 - 0
src/core/dependencies/task_deps.c

@@ -156,6 +156,21 @@ void starpu_task_declare_deps_array(struct starpu_task *task, unsigned ndeps, st
 	_starpu_task_declare_deps_array(task, ndeps, task_array, 1);
 }
 
+void starpu_task_declare_deps(struct starpu_task *task, unsigned ndeps, ...)
+{
+	if (ndeps == 0)
+		return;
+	struct starpu_task *tasks[ndeps];
+	unsigned i;
+	va_list pa;
+	va_start(pa, ndeps);
+	for (i = 0; i < ndeps; i++) {
+		tasks[i] = va_arg(pa, struct starpu_task *);
+	}
+	va_end(pa);
+	starpu_task_declare_deps_array(task, ndeps, tasks);
+}
+
 int starpu_task_get_task_succs(struct starpu_task *task, unsigned ndeps, struct starpu_task *task_array[])
 {
 	struct _starpu_job *j = _starpu_get_job_associated_to_task(task);

+ 2 - 3
tests/main/empty_task_sync_point_tasks.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2012                                     Inria
  * Copyright (C) 2010-2013,2015,2017                      CNRS
- * Copyright (C) 2010,2013-2014,2016                      Université de Bordeaux
+ * Copyright (C) 2010,2013-2014,2016, 2018                      Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -66,8 +66,7 @@ int main(int argc, char **argv)
 	struct starpu_task *taskF = starpu_task_create();
 	taskF->cl = &dummy_codelet;
 
-	struct starpu_task *tasksABC[3] = {taskA, taskB, taskC};
-	starpu_task_declare_deps_array(taskD, 3, tasksABC);
+	starpu_task_declare_deps(taskD, 3, taskA, taskB, taskC);
 	starpu_task_declare_deps_array(taskE, 1, &taskD);
 	starpu_task_declare_deps_array(taskF, 1, &taskD);
 

+ 4 - 6
tests/main/subgraph_repeat.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2012-2013                                Inria
  * Copyright (C) 2010-2015,2017                           CNRS
- * Copyright (C) 2010,2012-2016                           Université de Bordeaux
+ * Copyright (C) 2010,2012-2016, 2018                           Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -138,12 +138,10 @@ int main(int argc, char **argv)
 	taskD.callback_func = callback_task_D;
 	taskD.handles[0] = check_data;
 
-	struct starpu_task *depsBC_array[1] = {&taskA};
-	starpu_task_declare_deps_array(&taskB, 1, depsBC_array);
-	starpu_task_declare_deps_array(&taskC, 1, depsBC_array);
+	starpu_task_declare_deps(&taskB, 1, &taskA);
+	starpu_task_declare_deps(&taskC, 1, &taskA);
 
-	struct starpu_task *depsD_array[2] = {&taskB, &taskC};
-	starpu_task_declare_deps_array(&taskD, 2, depsD_array);
+	starpu_task_declare_deps(&taskD, 2, &taskB, &taskC);
 
 	ret = starpu_task_submit(&taskA); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	ret = starpu_task_submit(&taskB); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");

+ 4 - 6
tests/main/subgraph_repeat_regenerate.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2012-2013                                Inria
  * Copyright (C) 2010-2015,2017                           CNRS
- * Copyright (C) 2010-2016                                Université de Bordeaux
+ * Copyright (C) 2010-2016, 2018                                Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -160,12 +160,10 @@ int main(int argc, char **argv)
 	taskD.regenerate = 1;
 	taskD.handles[0] = check_data;
 
-	struct starpu_task *depsBC_array[1] = {&taskA};
-	starpu_task_declare_deps_array(&taskB, 1, depsBC_array);
-	starpu_task_declare_deps_array(&taskC, 1, depsBC_array);
+	starpu_task_declare_deps(&taskB, 1, &taskA);
+	starpu_task_declare_deps(&taskC, 1, &taskA);
 
-	struct starpu_task *depsD_array[2] = {&taskB, &taskC};
-	starpu_task_declare_deps_array(&taskD, 2, depsD_array);
+	starpu_task_declare_deps(&taskD, 2, &taskB, &taskC);
 
 	ret = starpu_task_submit(&taskA); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	ret = starpu_task_submit(&taskB); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");

+ 4 - 6
tests/main/subgraph_repeat_tag.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2012-2013                                Inria
- * Copyright (C) 2010-2016                                Université de Bordeaux
+ * Copyright (C) 2010-2016, 2018                                Université de Bordeaux
  * Copyright (C) 2010-2015,2017                           CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -169,12 +169,10 @@ int main(int argc, char **argv)
 	taskD.regenerate = 1;
 	taskD.handles[0] = check_data;
 
-	struct starpu_task *depsBC_array[1] = {&taskA};
-	starpu_task_declare_deps_array(&taskB, 1, depsBC_array);
-	starpu_task_declare_deps_array(&taskC, 1, depsBC_array);
+	starpu_task_declare_deps(&taskB, 1, &taskA);
+	starpu_task_declare_deps(&taskC, 1, &taskA);
 
-	struct starpu_task *depsD_array[2] = {&taskB, &taskC};
-	starpu_task_declare_deps_array(&taskD, 2, depsD_array);
+	starpu_task_declare_deps(&taskD, 2, &taskB, &taskC);
 
 	ret = starpu_task_submit(&taskA); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	ret = starpu_task_submit(&taskB); if (ret == -ENODEV) goto enodev; STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");

+ 2 - 3
tests/main/task_wait_api.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2012,2015                                Inria
  * Copyright (C) 2010-2013,2015,2017                      CNRS
- * Copyright (C) 2010,2013-2014,2016                      Université de Bordeaux
+ * Copyright (C) 2010,2013-2014,2016, 2018                      Université de Bordeaux
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -89,8 +89,7 @@ int main(int argc, char **argv)
 	taskF = create_dummy_task();
 	taskG = create_dummy_task();
 
-	struct starpu_task *tasksCDEF[4] = {taskC, taskD, taskE, taskF};
-	starpu_task_declare_deps_array(taskG, 4, tasksCDEF);
+	starpu_task_declare_deps(taskG, 4, taskC, taskD, taskE, taskF);
 
 	ret = starpu_task_submit(taskC); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
 	ret = starpu_task_submit(taskD); STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");