starpu_task_bundle.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010, 2011 Université de Bordeaux 1
  4. * Copyright (C) 2011 Télécom-SudParis
  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. #ifndef __STARPU_TASK_BUNDLE_H__
  18. #define __STARPU_TASK_BUNDLE_H__
  19. #include <starpu.h>
  20. #include <starpu_config.h>
  21. #if ! defined(_MSC_VER)
  22. # include <pthread.h>
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. struct starpu_task_bundle_entry {
  28. struct starpu_task *task;
  29. struct starpu_task_bundle_entry *next;
  30. };
  31. /* The task bundle structure describes a list of tasks that should be scheduled
  32. * together whenever possible. */
  33. struct starpu_task_bundle {
  34. /* Mutex protecting the bundle */
  35. #if defined(_MSC_VER)
  36. void *mutex;
  37. #else
  38. pthread_mutex_t mutex;
  39. #endif
  40. /* last worker previously assigned a task from the bundle (-1 if none) .*/
  41. int previous_workerid;
  42. /* list of tasks */
  43. struct starpu_task_bundle_entry *list;
  44. /* If this flag is set, the bundle structure is automatically free'd
  45. * when the bundle is deinitialized. */
  46. int destroy;
  47. /* Is the bundle closed ? */
  48. int closed;
  49. /* TODO retain bundle (do not schedule until closed) */
  50. };
  51. /* Initialize a task bundle */
  52. void starpu_task_bundle_init(struct starpu_task_bundle *bundle);
  53. /* Deinitialize a bundle. In case the destroy flag is set, the bundle structure
  54. * is freed too. */
  55. void starpu_task_bundle_deinit(struct starpu_task_bundle *bundle);
  56. /* Insert a task into a bundle. */
  57. int starpu_task_bundle_insert(struct starpu_task_bundle *bundle, struct starpu_task *task);
  58. /* Remove a task from a bundle. This method must be called with bundle->mutex
  59. * hold. This function returns 0 if the task was found, -ENOENT if the element
  60. * was not found, 1 if the element is found and if the list was deinitialized
  61. * because it became empty. */
  62. int starpu_task_bundle_remove(struct starpu_task_bundle *bundle, struct starpu_task *task);
  63. /* Close a bundle. No task can be added to a closed bundle. A closed bundle
  64. * automatically gets deinitialized when it becomes empty. */
  65. void starpu_task_bundle_close(struct starpu_task_bundle *bundle);
  66. /* Return the expected duration of the entire task bundle in µs. */
  67. double starpu_task_bundle_expected_length(struct starpu_task_bundle *bundle, enum starpu_perf_archtype arch, unsigned nimpl);
  68. /* Return the time (in µs) expected to transfer all data used within the bundle */
  69. double starpu_task_bundle_expected_data_transfer_time(struct starpu_task_bundle *bundle, unsigned memory_node);
  70. /* Return the expected power consumption of the entire task bundle in J. */
  71. double starpu_task_bundle_expected_power(struct starpu_task_bundle *bundle, enum starpu_perf_archtype arch, unsigned nimpl);
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif // __STARPU_TASK_BUNDLE_H__