empty_task_chain.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011 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. #define N 4
  19. int main(int argc, char **argv)
  20. {
  21. int i, ret;
  22. starpu_init(NULL);
  23. struct starpu_task **tasks = (struct starpu_task **) malloc(N*sizeof(struct starpu_task *));
  24. for (i = 0; i < N; i++)
  25. {
  26. tasks[i] = starpu_task_create();
  27. tasks[i]->cl = NULL;
  28. if (i > 0)
  29. {
  30. starpu_task_declare_deps_array(tasks[i], 1, &tasks[i-1]);
  31. ret = starpu_task_submit(tasks[i]);
  32. STARPU_ASSERT(!ret);
  33. }
  34. if (i == (N-1))
  35. tasks[i]->detach = 0;
  36. }
  37. ret = starpu_task_submit(tasks[0]);
  38. STARPU_ASSERT(!ret);
  39. starpu_task_wait(tasks[N-1]);
  40. starpu_shutdown();
  41. free(tasks);
  42. return 0;
  43. }