task_bundle.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010-2012 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2013 Centre National de la Recherche Scientifique
  5. * Copyright (C) 2012 Inria
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #ifndef __CORE_TASK_BUNDLE_H__
  19. #define __CORE_TASK_BUNDLE_H__
  20. #include <starpu_thread.h>
  21. /* struct _starpu_task_bundle_entry
  22. * ================================
  23. * Purpose
  24. * =======
  25. * Structure used to describe a linked list containing tasks in _starpu_task_bundle.
  26. *
  27. * Fields
  28. * ======
  29. * task Pointer to the task structure.
  30. *
  31. * next Pointer to the next element in the linked list.
  32. */
  33. struct _starpu_task_bundle_entry
  34. {
  35. struct starpu_task *task;
  36. struct _starpu_task_bundle_entry *next;
  37. };
  38. /* struct _starpu_task_bundle
  39. * ==========================
  40. * Purpose
  41. * =======
  42. * Structure describing a list of tasks that should be scheduled on the same
  43. * worker whenever it's possible.
  44. * It must be considered as a hint given to the scheduler as there is no guarantee that
  45. * they will be executed on the same worker.
  46. *
  47. * Fields
  48. * ======
  49. * mutex Mutex protecting the structure.
  50. *
  51. * list Array of tasks included in the bundle.
  52. *
  53. * closed Used to know if the user is still willing to
  54. * add/remove some tasks in the bundle. Especially useful for
  55. * the runtime to know whether it is safe to destroy a bundle.
  56. */
  57. struct _starpu_task_bundle
  58. {
  59. /* Mutex protecting the bundle */
  60. starpu_pthread_mutex_t mutex;
  61. struct _starpu_task_bundle_entry *list;
  62. int closed;
  63. };
  64. /* struct _starpu_handle_list
  65. * ==========================
  66. * Purpose
  67. * =======
  68. * Structure describing a list of handles sorted by address to speed-up
  69. * when looking for an element.
  70. * The list cannot containes duplicate handles.
  71. *
  72. * Fields
  73. * ======
  74. * handle Pointer to the handle structure.
  75. *
  76. * access_mode Total access mode over the whole bundle.
  77. *
  78. * next Pointer to the next element in the linked list.
  79. */
  80. struct _starpu_handle_list
  81. {
  82. starpu_data_handle_t handle;
  83. enum starpu_data_access_mode mode;
  84. struct _starpu_handle_list *next;
  85. };
  86. /* _starpu_task_bundle_destroy
  87. * ==========================
  88. * Purpose
  89. * =======
  90. * Destroy and deinitialize a bundle,
  91. * memory previoulsy allocated is freed.
  92. *
  93. * Arguments
  94. * =========
  95. * bundle (input)
  96. * Bundle to destroy.
  97. */
  98. void _starpu_task_bundle_destroy(starpu_task_bundle_t bundle);
  99. /* _insertion_handle_sorted
  100. * ========================
  101. * Purpose
  102. * =======
  103. * Insert an handle in a _starpu_handle_list, elements are sorted
  104. * in increasing order, considering their physical address.
  105. * As the list doesn't accept duplicate elements, a handle with the
  106. * same address as an handle contained in the list is not inserted, but
  107. * its mode access is merged with the one of the latter.
  108. *
  109. * Arguments
  110. * =========
  111. * listp (input, output)
  112. * Pointer to the first element of the list.
  113. * In the case of an empty list or an inserted handle with small address,
  114. * it should have changed when the call returns.
  115. *
  116. * handle (input)
  117. * Handle to insert in the list.
  118. *
  119. * mode (input)
  120. * Access mode of the handle.
  121. */
  122. void _insertion_handle_sorted(struct _starpu_handle_list **listp, starpu_data_handle_t handle, enum starpu_data_access_mode mode);
  123. #endif // __CORE_TASK_BUNDLE_H__