starpu_task_bundle.h 3.0 KB

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