deploop.c 2.4 KB

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