starpu_scheduler.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2013 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_SCHEDULER_H__
  18. #define __STARPU_SCHEDULER_H__
  19. #include <starpu.h>
  20. #ifdef __cplusplus
  21. extern "C"
  22. {
  23. #endif
  24. struct starpu_task;
  25. struct starpu_sched_policy
  26. {
  27. void (*init_sched)(unsigned sched_ctx_id);
  28. void (*deinit_sched)(unsigned sched_ctx_id);
  29. int (*push_task)(struct starpu_task *);
  30. void (*push_task_notify)(struct starpu_task *, int workerid, unsigned sched_ctx_id);
  31. struct starpu_task *(*pop_task)(unsigned sched_ctx_id);
  32. struct starpu_task *(*pop_every_task)(unsigned sched_ctx_id);
  33. void (*pre_exec_hook)(struct starpu_task *);
  34. void (*post_exec_hook)(struct starpu_task *);
  35. void (*add_workers)(unsigned sched_ctx_id, int *workerids, unsigned nworkers);
  36. void (*remove_workers)(unsigned sched_ctx_id, int *workerids, unsigned nworkers);
  37. const char *policy_name;
  38. const char *policy_description;
  39. };
  40. struct starpu_sched_policy **starpu_sched_get_predefined_policies();
  41. /* When there is no available task for a worker, StarPU blocks this worker on a
  42. condition variable. This function specifies which condition variable (and the
  43. associated mutex) should be used to block (and to wake up) a worker. Note that
  44. multiple workers may use the same condition variable. For instance, in the case
  45. of a scheduling strategy with a single task queue, the same condition variable
  46. would be used to block and wake up all workers. */
  47. void starpu_worker_get_sched_condition(int workerid, starpu_pthread_mutex_t **sched_mutex, starpu_pthread_cond_t **sched_cond);
  48. /* Check if the worker specified by workerid can execute the codelet. */
  49. int starpu_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl);
  50. /* The scheduling policy may put tasks directly into a worker's local queue so
  51. * that it is not always necessary to create its own queue when the local queue
  52. * is sufficient. If "back" not null, the task is put at the back of the queue
  53. * where the worker will pop tasks first. Setting "back" to 0 therefore ensures
  54. * a FIFO ordering. */
  55. int starpu_push_local_task(int workerid, struct starpu_task *task, int back);
  56. /* Called by scheduler to notify that the task has just been pushed */
  57. int starpu_push_task_end(struct starpu_task *task);
  58. /*
  59. * Parallel tasks
  60. */
  61. /* Register a new combined worker and get its identifier */
  62. int starpu_combined_worker_assign_workerid(int nworkers, int workerid_array[]);
  63. /* Get the description of a combined worker */
  64. int starpu_combined_worker_get_description(int workerid, int *worker_size, int **combined_workerid);
  65. /* Variant of starpu_worker_can_execute_task compatible with combined workers */
  66. int starpu_combined_worker_can_execute_task(unsigned workerid, struct starpu_task *task, unsigned nimpl);
  67. /*
  68. * Data prefetching
  69. */
  70. /* Whether STARPU_PREFETCH was set */
  71. int starpu_get_prefetch_flag(void);
  72. /* Prefetch data for a given task on a given node */
  73. int starpu_prefetch_task_input_on_node(struct starpu_task *task, unsigned node);
  74. /*
  75. * Performance predictions
  76. */
  77. /* Returns the perfmodel footprint for the task */
  78. uint32_t starpu_task_footprint(struct starpu_perfmodel *model, struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl);
  79. /* Returns expected task duration in us */
  80. double starpu_task_expected_length(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl);
  81. /* Returns an estimated speedup factor relative to CPU speed */
  82. double starpu_worker_get_relative_speedup(enum starpu_perfmodel_archtype perf_archtype);
  83. /* Returns expected data transfer time in us */
  84. double starpu_task_expected_data_transfer_time(unsigned memory_node, struct starpu_task *task);
  85. /* Predict the transfer time (in us) to move a handle to a memory node */
  86. double starpu_data_expected_transfer_time(starpu_data_handle_t handle, unsigned memory_node, enum starpu_data_access_mode mode);
  87. /* Returns expected power consumption in J */
  88. double starpu_task_expected_power(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl);
  89. /* Returns expected conversion time in ms (multiformat interface only) */
  90. double starpu_task_expected_conversion_time(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl);
  91. /* Return the expected duration of the entire task bundle in us. */
  92. double starpu_task_bundle_expected_length(starpu_task_bundle_t bundle, enum starpu_perfmodel_archtype arch, unsigned nimpl);
  93. /* Return the time (in us) expected to transfer all data used within the bundle */
  94. double starpu_task_bundle_expected_data_transfer_time(starpu_task_bundle_t bundle, unsigned memory_node);
  95. /* Return the expected power consumption of the entire task bundle in J. */
  96. double starpu_task_bundle_expected_power(starpu_task_bundle_t bundle, enum starpu_perfmodel_archtype arch, unsigned nimpl);
  97. #ifdef __cplusplus
  98. }
  99. #endif
  100. #endif /* __STARPU_SCHEDULER_H__ */