starpu_task_bundle.h 3.1 KB

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