task_bundle.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2020 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. #ifndef __CORE_TASK_BUNDLE_H__
  17. #define __CORE_TASK_BUNDLE_H__
  18. /** @file */
  19. #include <starpu_thread.h>
  20. /** struct _starpu_task_bundle_entry
  21. * ================================
  22. * Purpose
  23. * =======
  24. * Structure used to describe a linked list containing tasks in _starpu_task_bundle.
  25. *
  26. * Fields
  27. * ======
  28. * task Pointer to the task structure.
  29. *
  30. * next Pointer to the next element in the linked list.
  31. */
  32. struct _starpu_task_bundle_entry
  33. {
  34. struct starpu_task *task;
  35. struct _starpu_task_bundle_entry *next;
  36. };
  37. /** struct _starpu_task_bundle
  38. * ==========================
  39. * Purpose
  40. * =======
  41. * Structure describing a list of tasks that should be scheduled on the same
  42. * worker whenever it's possible.
  43. * It must be considered as a hint given to the scheduler as there is no guarantee that
  44. * they will be executed on the same worker.
  45. *
  46. * Fields
  47. * ======
  48. * mutex Mutex protecting the structure.
  49. *
  50. * list Array of tasks included in the bundle.
  51. *
  52. * closed Used to know if the user is still willing to
  53. * add/remove some tasks in the bundle. Especially useful for
  54. * the runtime to know whether it is safe to destroy a bundle.
  55. */
  56. struct _starpu_task_bundle
  57. {
  58. /** Mutex protecting the bundle */
  59. starpu_pthread_mutex_t mutex;
  60. struct _starpu_task_bundle_entry *list;
  61. int closed;
  62. };
  63. /** struct _starpu_handle_list
  64. * ==========================
  65. * Purpose
  66. * =======
  67. * Structure describing a list of handles sorted by address to speed-up
  68. * when looking for an element.
  69. * The list cannot containes duplicate handles.
  70. *
  71. * Fields
  72. * ======
  73. * handle Pointer to the handle structure.
  74. *
  75. * access_mode Total access mode over the whole bundle.
  76. *
  77. * next Pointer to the next element in the linked list.
  78. */
  79. struct _starpu_handle_list
  80. {
  81. starpu_data_handle_t handle;
  82. enum starpu_data_access_mode mode;
  83. struct _starpu_handle_list *next;
  84. };
  85. /** _starpu_task_bundle_destroy
  86. * ==========================
  87. * Purpose
  88. * =======
  89. * Destroy and deinitialize a bundle,
  90. * memory previoulsy allocated is freed.
  91. *
  92. * Arguments
  93. * =========
  94. * bundle (input)
  95. * Bundle to destroy.
  96. */
  97. void _starpu_task_bundle_destroy(starpu_task_bundle_t bundle);
  98. /** _insertion_handle_sorted
  99. * ========================
  100. * Purpose
  101. * =======
  102. * Insert an handle in a _starpu_handle_list, elements are sorted
  103. * in increasing order, considering their physical address.
  104. * As the list doesn't accept duplicate elements, a handle with the
  105. * same address as an handle contained in the list is not inserted, but
  106. * its mode access is merged with the one of the latter.
  107. *
  108. * Arguments
  109. * =========
  110. * listp (input, output)
  111. * Pointer to the first element of the list.
  112. * In the case of an empty list or an inserted handle with small address,
  113. * it should have changed when the call returns.
  114. *
  115. * handle (input)
  116. * Handle to insert in the list.
  117. *
  118. * mode (input)
  119. * Access mode of the handle.
  120. */
  121. void _insertion_handle_sorted(struct _starpu_handle_list **listp, starpu_data_handle_t handle, enum starpu_data_access_mode mode);
  122. #endif // __CORE_TASK_BUNDLE_H__