deploop.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2011, 2013, 2015 Université de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012, 2013 CNRS
  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},
  33. .cpu_funcs_name = {"dummy_func"},
  34. .cuda_funcs = {dummy_func},
  35. .opencl_funcs = {dummy_func},
  36. .model = NULL,
  37. .nbuffers = 1,
  38. .modes = { STARPU_RW }
  39. };
  40. int main(int argc, char **argv)
  41. {
  42. int ret;
  43. starpu_data_handle_t handle;
  44. ret = starpu_init(NULL);
  45. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  46. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  47. starpu_void_data_register(&handle);
  48. struct starpu_task *taskA, *taskB;
  49. /* Make B depend on A */
  50. starpu_tag_declare_deps(1, 1, (starpu_tag_t) 0);
  51. taskA = starpu_task_create();
  52. taskA->cl = &dummy_codelet;
  53. taskA->tag_id = 0;
  54. taskA->use_tag = 1;
  55. taskA->handles[0] = handle;
  56. taskA->sequential_consistency = 0;
  57. FPRINTF(stderr,"A is %p\n", taskA);
  58. taskB = starpu_task_create();
  59. taskB->cl = &dummy_codelet;
  60. taskB->tag_id = 1;
  61. taskB->use_tag = 1;
  62. taskB->handles[0] = handle;
  63. FPRINTF(stderr,"B is %p\n", taskB);
  64. ret = starpu_task_submit(taskB);
  65. if (ret == -ENODEV)
  66. return STARPU_TEST_SKIPPED;
  67. ret = starpu_task_submit(taskA);
  68. if (ret == -ENODEV)
  69. return STARPU_TEST_SKIPPED;
  70. ret = starpu_task_wait_for_all();
  71. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
  72. starpu_data_unregister(handle);
  73. starpu_shutdown();
  74. return EXIT_SUCCESS;
  75. }