empty_task_chain.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010 Université de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012 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_initialize(NULL, &argc, &argv);
  24. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  25. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  26. struct starpu_task **tasks = (struct starpu_task **) malloc(N*sizeof(struct starpu_task *));
  27. for (i = 0; i < N; i++)
  28. {
  29. tasks[i] = starpu_task_create();
  30. tasks[i]->cl = NULL;
  31. if (i > 0)
  32. {
  33. starpu_task_declare_deps_array(tasks[i], 1, &tasks[i-1]);
  34. ret = starpu_task_submit(tasks[i]);
  35. if (ret == -ENODEV) goto enodev;
  36. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  37. }
  38. if (i == (N-1))
  39. tasks[i]->detach = 0;
  40. }
  41. ret = starpu_task_submit(tasks[0]);
  42. if (ret == -ENODEV) goto enodev;
  43. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_submit");
  44. ret = starpu_task_wait(tasks[N-1]);
  45. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait");
  46. starpu_shutdown();
  47. free(tasks);
  48. return EXIT_SUCCESS;
  49. enodev:
  50. fprintf(stderr, "WARNING: No one can execute this task\n");
  51. /* yes, we do not perform the computation but we did detect that no one
  52. * could perform the kernel, so this is not an error from StarPU */
  53. starpu_shutdown();
  54. return STARPU_TEST_SKIPPED;
  55. }