deploop.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #include <stdio.h>
  17. #include <unistd.h>
  18. #include <starpu.h>
  19. #include "../helper.h"
  20. /*
  21. * Create task A and B such that
  22. * - B depends on A by tag dependency.
  23. * - A would depend on B by data dependency, but we disable that by disabling
  24. * sequential consistency.
  25. */
  26. void dummy_func(void *descr[], void *arg)
  27. {
  28. (void)descr;
  29. (void)arg;
  30. FPRINTF(stderr,"executing task %p\n", starpu_task_get_current());
  31. }
  32. static struct starpu_codelet dummy_codelet =
  33. {
  34. .cpu_funcs = {dummy_func},
  35. .cpu_funcs_name = {"dummy_func"},
  36. .cuda_funcs = {dummy_func},
  37. .opencl_funcs = {dummy_func},
  38. .model = NULL,
  39. .nbuffers = 1,
  40. .modes = { STARPU_RW }
  41. };
  42. int main(void)
  43. {
  44. int ret;
  45. starpu_data_handle_t handle;
  46. ret = starpu_init(NULL);
  47. if (ret == -ENODEV) return STARPU_TEST_SKIPPED;
  48. STARPU_CHECK_RETURN_VALUE(ret, "starpu_init");
  49. starpu_void_data_register(&handle);
  50. struct starpu_task *taskA, *taskB;
  51. /* Make B depend on A */
  52. starpu_tag_declare_deps(1, 1, (starpu_tag_t) 0);
  53. taskA = starpu_task_create();
  54. taskA->cl = &dummy_codelet;
  55. taskA->tag_id = 0;
  56. taskA->use_tag = 1;
  57. taskA->handles[0] = handle;
  58. taskA->sequential_consistency = 0;
  59. FPRINTF(stderr,"A is %p\n", taskA);
  60. taskB = starpu_task_create();
  61. taskB->cl = &dummy_codelet;
  62. taskB->tag_id = 1;
  63. taskB->use_tag = 1;
  64. taskB->handles[0] = handle;
  65. FPRINTF(stderr,"B is %p\n", taskB);
  66. ret = starpu_task_submit(taskB);
  67. if (ret == -ENODEV)
  68. return STARPU_TEST_SKIPPED;
  69. ret = starpu_task_submit(taskA);
  70. if (ret == -ENODEV)
  71. return STARPU_TEST_SKIPPED;
  72. ret = starpu_task_wait_for_all();
  73. STARPU_CHECK_RETURN_VALUE(ret, "starpu_task_wait_for_all");
  74. starpu_data_unregister(handle);
  75. starpu_shutdown();
  76. return EXIT_SUCCESS;
  77. }