starpu_create_sync_task.c 1.7 KB

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