task_bundle.h 3.8 KB

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