starpu_task_bundle.h 3.1 KB

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