task_bundle.h 3.8 KB

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