starpu_create_sync_task.c 1.5 KB

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