empty_task_chain.c 1.9 KB

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