starpu_create_sync_task.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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,2019 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. void starpu_create_sync_task(starpu_tag_t sync_tag, unsigned ndeps, starpu_tag_t *deps, void (*callback)(void *), void *callback_arg)
  22. {
  23. starpu_tag_declare_deps_array(sync_tag, ndeps, deps);
  24. /* We create an empty task */
  25. struct starpu_task *sync_task = starpu_task_create();
  26. sync_task->name = "create_sync_task";
  27. sync_task->use_tag = 1;
  28. sync_task->tag_id = sync_tag;
  29. sync_task->callback_func = callback;
  30. sync_task->callback_arg = callback_arg;
  31. /* This task does nothing */
  32. sync_task->cl = NULL;
  33. int sync_ret = _starpu_task_submit_internally(sync_task);
  34. STARPU_ASSERT(!sync_ret);
  35. }
  36. void starpu_create_callback_task(void (*callback)(void *), void *callback_arg)
  37. {
  38. /* We create an empty task */
  39. struct starpu_task *empty_task = starpu_task_create();
  40. empty_task->name = "empty_task";
  41. empty_task->callback_func = callback;
  42. empty_task->callback_arg = callback_arg;
  43. /* This task does nothing */
  44. empty_task->cl = NULL;
  45. int ret = _starpu_task_submit_internally(empty_task);
  46. STARPU_ASSERT(!ret);
  47. }