deploop.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2011, 2013 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012, 2013 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. /*
  18. * Create task A and B such that
  19. * - B depends on A by tag dependency.
  20. * - A would depend on B by data dependency, but we disable that.
  21. */
  22. #include <stdio.h>
  23. #include <unistd.h>
  24. #include <starpu.h>
  25. #include "../helper.h"
  26. void dummy_func(void *descr[] STARPU_ATTRIBUTE_UNUSED, void *arg STARPU_ATTRIBUTE_UNUSED)
  27. {
  28. FPRINTF(stderr,"executing task %p\n", starpu_task_get_current());
  29. }
  30. static struct starpu_codelet dummy_codelet =
  31. {
  32. .cpu_funcs = {dummy_func, NULL},
  33. .cuda_funcs = {dummy_func, NULL},
  34. .opencl_funcs = {dummy_func, NULL},
  35. .model = NULL,
  36. .nbuffers = 1,
  37. .modes = { STARPU_RW }
  38. };
  39. int main(int argc, char **argv)
  40. {
  41. int ret;
  42. starpu_data_handle_t handle;
  43. ret = starpu_init(NULL);
  44. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  45. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  46. starpu_void_data_register(&handle);
  47. struct starpu_task *taskA, *taskB;
  48. /* Make B depend on A */
  49. starpu_tag_declare_deps(1, 1, (starpu_tag_t) 0);
  50. taskA = starpu_task_create();
  51. taskA->cl = &dummy_codelet;
  52. taskA->tag_id = 0;
  53. taskA->use_tag = 1;
  54. taskA->handles[0] = handle;
  55. taskA->sequential_consistency = 0;
  56. FPRINTF(stderr,"A is %p\n", taskA);
  57. taskB = starpu_task_create();
  58. taskB->cl = &dummy_codelet;
  59. taskB->tag_id = 1;
  60. taskB->use_tag = 1;
  61. taskB->handles[0] = handle;
  62. FPRINTF(stderr,"B is %p\n", taskB);
  63. ret = starpu_task_submit(taskB);
  64. if (ret == -ENODEV)
  65. return STARPU_TEST_SKIPPED;
  66. ret = starpu_task_submit(taskA);
  67. if (ret == -ENODEV)
  68. return STARPU_TEST_SKIPPED;
  69. ret = starpu_task_wait_for_all();
  70. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
  71. starpu_data_unregister(handle);
  72. starpu_shutdown();
  73. return EXIT_SUCCESS;
  74. }