Procházet zdrojové kódy

New function starpu_create_callback_task() which creates and submits an empty task with the specified callback

Nathalie Furmento před 5 roky
rodič
revize
2271b27506
3 změnil soubory, kde provedl 25 přidání a 8 odebrání
  1. 2 0
      ChangeLog
  2. 6 1
      include/starpu_task.h
  3. 17 7
      src/util/starpu_create_sync_task.c

+ 2 - 0
ChangeLog

@@ -31,6 +31,8 @@ Small features:
   * New starpu_task_insert() and alike parameters
     STARPU_SEQUENTIAL_CONSISTENCY, STARPU_TASK_NO_SUBMITORDER and
     STARPU_TASK_PROFILING_INFO
+  * New function starpu_create_callback_task() which creates and
+    submits an empty task with the specified callback
 
 Small changes:
   * Update starpu_task_insert() and alike to set

+ 6 - 1
include/starpu_task.h

@@ -1530,12 +1530,17 @@ void starpu_task_set_implementation(struct starpu_task *task, unsigned impl);
 unsigned starpu_task_get_implementation(struct starpu_task *task);
 
 /**
-   Create (and submit) an empty task that unlocks a tag once all its
+   Create and submit 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 (*callback)(void *), void *callback_arg);
 
 /**
+   Create and submit an empty task with the given callback
+ */
+void starpu_create_callback_task(void (*callback)(void *), void *callback_arg);
+
+/**
    Function to be used as a prologue callback to enable fault tolerance for the
    task. This prologue will create a try-task, i.e a duplicate of the task,
    which will to the actual computation.

+ 17 - 7
src/util/starpu_create_sync_task.c

@@ -2,7 +2,7 @@
  *
  * Copyright (C) 2011,2012                                Inria
  * Copyright (C) 2010,2011,2014                           Université de Bordeaux
- * Copyright (C) 2010-2013,2015,2017                      CNRS
+ * Copyright (C) 2010-2013,2015,2017,2019                 CNRS
  *
  * 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
@@ -20,12 +20,7 @@
 #include <common/config.h>
 #include <core/task.h>
 
-/* This creates (and submits) an empty task that unlocks a tag once all its
- * dependencies are fulfilled. */
-/* 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)
+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);
 
@@ -45,3 +40,18 @@ void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t
 	int sync_ret = _starpu_task_submit_internally(sync_task);
 	STARPU_ASSERT(!sync_ret);
 }
+
+void starpu_create_callback_task(void (*callback)(void *), void *callback_arg)
+{
+	/* We create an empty task */
+	struct starpu_task *empty_task = starpu_task_create();
+	empty_task->name = "empty_task";
+	empty_task->callback_func = callback;
+	empty_task->callback_arg = callback_arg;
+
+	/* This task does nothing */
+	empty_task->cl = NULL;
+
+	int ret = _starpu_task_submit_internally(empty_task);
+	STARPU_ASSERT(!ret);
+}