starpu_create_sync_task.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * StarPU
  3. * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <starpu.h>
  17. #include <common/config.h>
  18. /* This creates (and submits) an empty task that unlocks a tag once all its
  19. * dependencies are fulfilled. */
  20. /* TODO it would be nice to have such a function without sync_tag in case we
  21. * just want to execute the callback. */
  22. void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t *deps,
  23. void (*callback)(void *), void *callback_arg)
  24. {
  25. starpu_tag_declare_deps_array(sync_tag, ndeps, deps);
  26. /* We create an empty task */
  27. struct starpu_task *sync_task = starpu_task_create();
  28. sync_task->use_tag = 1;
  29. sync_task->tag_id = sync_tag;
  30. sync_task->callback_func = callback;
  31. sync_task->callback_arg = callback_arg;
  32. /* This task does nothing */
  33. sync_task->cl = NULL;
  34. int sync_ret = starpu_task_submit(sync_task);
  35. STARPU_ASSERT(!sync_ret);
  36. }