empty_task_chain.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #include "../helper.h"
  19. #define N 4
  20. int main(int argc, char **argv)
  21. {
  22. int i, ret;
  23. ret = starpu_init(NULL);
  24. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  25. struct starpu_task **tasks = (struct starpu_task **) malloc(N*sizeof(struct starpu_task *));
  26. for (i = 0; i < N; i++)
  27. {
  28. tasks[i] = starpu_task_create();
  29. tasks[i]->cl = NULL;
  30. if (i > 0)
  31. {
  32. starpu_task_declare_deps_array(tasks[i], 1, &tasks[i-1]);
  33. ret = starpu_task_submit(tasks[i]);
  34. if (ret == -ENODEV) goto enodev;
  35. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  36. }
  37. if (i == (N-1))
  38. tasks[i]->detach = 0;
  39. }
  40. ret = starpu_task_submit(tasks[0]);
  41. if (ret == -ENODEV) goto enodev;
  42. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  43. ret = starpu_task_wait(tasks[N-1]);
  44. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
  45. starpu_shutdown();
  46. free(tasks);
  47. return EXIT_SUCCESS;
  48. enodev:
  49. fprintf(stderr, "WARNING: No one can execute this task\n");
  50. /* yes, we do not perform the computation but we did detect that no one
  51. * could perform the kernel, so this is not an error from StarPU */
  52. starpu_shutdown();
  53. return STARPU_TEST_SKIPPED;
  54. }