starpu_sched_ctx.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010 - 2012 INRIA
  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_SCHED_CTX_H__
  17. #define __STARPU_SCHED_CTX_H__
  18. #include <starpu.h>
  19. /* generic structure used by the scheduling contexts to iterated the workers */
  20. struct worker_collection {
  21. /* hidden data structure used to memorize the workers */
  22. void *workerids;
  23. /* the number of workers in the collection */
  24. unsigned nworkers;
  25. /* the current cursor of the collection*/
  26. pthread_key_t cursor_key;
  27. /* the type of structure (WORKER_LIST,...) */
  28. int type;
  29. /* checks if there is another element in collection */
  30. unsigned (*has_next)(struct worker_collection *workers);
  31. /* return the next element in the collection */
  32. int (*get_next)(struct worker_collection *workers);
  33. /* add a new element in the collection */
  34. int (*add)(struct worker_collection *workers, int worker);
  35. /* remove an element from the collection */
  36. int (*remove)(struct worker_collection *workers, int worker);
  37. /* initialize the structure */
  38. void* (*init)(struct worker_collection *workers);
  39. /* free the structure */
  40. void (*deinit)(struct worker_collection *workers);
  41. /* initialize the cursor if there is one */
  42. void (*init_cursor)(struct worker_collection *workers);
  43. /* free the cursor if there is one */
  44. void (*deinit_cursor)(struct worker_collection *workers);
  45. };
  46. /* types of structures the worker collection can implement */
  47. #define WORKER_LIST 0
  48. struct starpu_performance_counters {
  49. void (*notify_idle_cycle)(unsigned sched_ctx, int worker, double idle_time);
  50. void (*notify_idle_end)(unsigned sched_ctx, int worker);
  51. void (*notify_pushed_task)(unsigned sched_ctx, int worker);
  52. void (*notify_poped_task)(unsigned sched_ctx, int worker, double flops);
  53. void (*notify_post_exec_hook)(unsigned sched_ctx, int taskid);
  54. void (*notify_submitted_job)(struct starpu_task *task, uint32_t footprint);
  55. };
  56. #ifdef STARPU_USE_SCHED_CTX_HYPERVISOR
  57. void starpu_set_perf_counters(unsigned sched_ctx_id, struct starpu_performance_counters *perf_counters);
  58. void starpu_call_poped_task_cb(int workerid, unsigned sched_ctx_id, double flops);
  59. void starpu_call_pushed_task_cb(int workerid, unsigned sched_ctx_id);
  60. #endif //STARPU_USE_SCHED_CTX_HYPERVISOR
  61. unsigned starpu_create_sched_ctx(const char *policy_name, int *workerids_ctx, int nworkers_ctx, const char *sched_name);
  62. unsigned starpu_create_sched_ctx_inside_interval(const char *policy_name, const char *sched_name,
  63. int min_ncpus, int max_ncpus, int min_ngpus, int max_ngpus,
  64. unsigned allow_overlap);
  65. void starpu_delete_sched_ctx(unsigned sched_ctx_id, unsigned inheritor_sched_ctx_id);
  66. void starpu_add_workers_to_sched_ctx(int *workerids_ctx, int nworkers_ctx, unsigned sched_ctx);
  67. void starpu_remove_workers_from_sched_ctx(int *workerids_ctx, int nworkers_ctx, unsigned sched_ctx);
  68. void starpu_set_sched_ctx_policy_data(unsigned sched_ctx, void* policy_data);
  69. void* starpu_get_sched_ctx_policy_data(unsigned sched_ctx);
  70. void starpu_worker_set_sched_condition(unsigned sched_ctx, int workerid, pthread_mutex_t *sched_mutex, pthread_cond_t *sched_cond);
  71. void starpu_worker_get_sched_condition(unsigned sched_ctx, int workerid, pthread_mutex_t **sched_mutex, pthread_cond_t **sched_cond);
  72. void starpu_worker_init_sched_condition(unsigned sched_ctx, int workerid);
  73. void starpu_worker_deinit_sched_condition(unsigned sched_ctx, int workerid);
  74. struct worker_collection* starpu_create_worker_collection_for_sched_ctx(unsigned sched_ctx_id, int type);
  75. void starpu_delete_worker_collection_for_sched_ctx(unsigned sched_ctx_id);
  76. struct worker_collection* starpu_get_worker_collection_of_sched_ctx(unsigned sched_ctx_id);
  77. pthread_mutex_t* starpu_get_changing_ctx_mutex(unsigned sched_ctx_id);
  78. void starpu_set_sched_ctx(unsigned *sched_ctx);
  79. unsigned starpu_get_sched_ctx(void);
  80. void starpu_notify_hypervisor_exists(void);
  81. unsigned starpu_check_if_hypervisor_exists(void);
  82. unsigned starpu_get_nworkers_of_sched_ctx(unsigned sched_ctx);
  83. unsigned starpu_get_nshared_workers(unsigned sched_ctx_id, unsigned sched_ctx_id2);
  84. unsigned starpu_worker_belongs_to_sched_ctx(int workerid, unsigned sched_ctx_id);
  85. unsigned starpu_are_overlapping_ctxs_on_worker(int workerid);
  86. unsigned starpu_is_ctxs_turn(int workerid, unsigned sched_ctx_id);
  87. void starpu_set_turn_to_other_ctx(int workerid, unsigned sched_ctx_id);
  88. double starpu_get_max_time_worker_on_ctx(void);
  89. void starpu_stop_task_submission(void);
  90. void starpu_sched_ctx_set_inheritor(unsigned sched_ctx, unsigned inheritor);
  91. void starpu_sched_ctx_finished_submit(unsigned sched_ctx_id);
  92. #endif /* __STARPU_SCHED_CTX_H__ */