Browse Source

Add a callback to the empty task created by starpu_create_sync_task.

Cédric Augonnet 15 years ago
parent
commit
6279da10bf

+ 2 - 1
include/starpu-util.h

@@ -223,7 +223,8 @@ void starpu_execute_on_each_worker(void (*func)(void *), void *arg, uint32_t whe
 
 /* This creates (and submits) an empty task that unlocks a tag once all its
  * dependencies are fulfilled. */
-void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t *deps);
+void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t *deps,
+				void (*callback)(void *), void *callback_arg);
 
 #ifdef USE_CUDA
 /* In case the application is using streams, these functions will

+ 7 - 1
src/util/starpu_create_sync_task.c

@@ -19,7 +19,10 @@
 
 /* This creates (and submits) an empty task that unlocks a tag once all its
  * dependencies are fulfilled. */
-void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t *deps)
+/* TODO it would be nice to have such a function without sync_tag in case we
+ * just want to execute the callback. */
+void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t *deps,
+				void (*callback)(void *), void *callback_arg)
 {
 	starpu_tag_declare_deps_array(sync_tag, ndeps, deps);
 
@@ -29,6 +32,9 @@ void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t
 	sync_task->use_tag = 1;
 	sync_task->tag_id = sync_tag;
 
+	sync_task->callback_func = callback;
+	sync_task->callback_arg = callback_arg;
+
 	/* This task does nothing */
 	sync_task->cl = NULL;
 

+ 1 - 1
tests/helper/starpu_create_sync_task.c

@@ -72,7 +72,7 @@ int main(int argc, char **argv)
 			create_dummy_task(deps[d]);
 		}
 
-		starpu_create_sync_task(sync_tag, ndeps, deps);
+		starpu_create_sync_task(sync_tag, ndeps, deps, NULL, NULL);
 	}
 
 	/* Wait all the synchronization tasks */