starpu_sched_ctx.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. #ifdef __cplusplus
  20. extern "C"
  21. {
  22. #endif
  23. #ifdef STARPU_DEVEL
  24. # warning rename all objects to start with starpu_sched_ctx
  25. #endif
  26. //struct starpu_iterator;
  27. struct starpu_iterator
  28. {
  29. int cursor;
  30. };
  31. /* generic structure used by the scheduling contexts to iterate the workers */
  32. struct starpu_sched_ctx_worker_collection
  33. {
  34. /* hidden data structure used to memorize the workers */
  35. void *workerids;
  36. /* the number of workers in the collection */
  37. unsigned nworkers;
  38. /* the type of structure (STARPU_WORKER_LIST,...) */
  39. int type;
  40. /* checks if there is another element in collection */
  41. unsigned (*has_next)(struct starpu_sched_ctx_worker_collection *workers, struct starpu_iterator *it);
  42. /* return the next element in the collection */
  43. int (*get_next)(struct starpu_sched_ctx_worker_collection *workers, struct starpu_iterator *it);
  44. /* add a new element in the collection */
  45. int (*add)(struct starpu_sched_ctx_worker_collection *workers, int worker);
  46. /* remove an element from the collection */
  47. int (*remove)(struct starpu_sched_ctx_worker_collection *workers, int worker);
  48. /* initialize the structure */
  49. void (*init)(struct starpu_sched_ctx_worker_collection *workers);
  50. /* free the structure */
  51. void (*deinit)(struct starpu_sched_ctx_worker_collection *workers);
  52. /* initialize the cursor if there is one */
  53. void (*init_iterator)(struct starpu_sched_ctx_worker_collection *workers, struct starpu_iterator *it);
  54. };
  55. /* types of structures the worker collection can implement */
  56. #define STARPU_WORKER_LIST 0
  57. struct starpu_performance_counters
  58. {
  59. void (*notify_idle_cycle)(unsigned sched_ctx_id, int worker, double idle_time);
  60. void (*notify_idle_end)(unsigned sched_ctx_id, int worker);
  61. void (*notify_pushed_task)(unsigned sched_ctx_id, int worker);
  62. void (*notify_poped_task)(unsigned sched_ctx_id, int worker, double flops);
  63. void (*notify_post_exec_hook)(unsigned sched_ctx_id, int taskid);
  64. void (*notify_submitted_job)(struct starpu_task *task, uint32_t footprint);
  65. };
  66. #ifdef STARPU_USE_SCHED_CTX_HYPERVISOR
  67. void starpu_set_perf_counters(unsigned sched_ctx_id, struct starpu_performance_counters *perf_counters);
  68. void starpu_call_poped_task_cb(int workerid, unsigned sched_ctx_id, double flops);
  69. void starpu_call_pushed_task_cb(int workerid, unsigned sched_ctx_id);
  70. #endif //STARPU_USE_SCHED_CTX_HYPERVISOR
  71. unsigned starpu_sched_ctx_create(const char *policy_name, int *workerids_ctx, int nworkers_ctx, const char *sched_ctx_name);
  72. unsigned starpu_sched_ctx_create_inside_interval(const char *policy_name, const char *sched_name,
  73. int min_ncpus, int max_ncpus, int min_ngpus, int max_ngpus,
  74. unsigned allow_overlap);
  75. void starpu_sched_ctx_delete(unsigned sched_ctx_id);
  76. void starpu_sched_ctx_add_workers(int *workerids_ctx, int nworkers_ctx, unsigned sched_ctx_id);
  77. void starpu_sched_ctx_remove_workers(int *workerids_ctx, int nworkers_ctx, unsigned sched_ctx_id);
  78. void starpu_sched_ctx_set_policy_data(unsigned sched_ctx_id, void *policy_data);
  79. void* starpu_sched_ctx_get_policy_data(unsigned sched_ctx_id);
  80. struct starpu_sched_ctx_worker_collection* starpu_sched_ctx_create_worker_collection(unsigned sched_ctx_id, int type);
  81. void starpu_sched_ctx_delete_worker_collection(unsigned sched_ctx_id);
  82. struct starpu_sched_ctx_worker_collection* starpu_sched_ctx_get_worker_collection(unsigned sched_ctx_id);
  83. #if !defined(_MSC_VER) && !defined(STARPU_SIMGRID)
  84. pthread_mutex_t* starpu_get_changing_ctx_mutex(unsigned sched_ctx_id);
  85. #endif
  86. void starpu_task_set_context(unsigned *sched_ctx_id);
  87. unsigned starpu_task_get_context(void);
  88. void starpu_notify_hypervisor_exists(void);
  89. unsigned starpu_check_if_hypervisor_exists(void);
  90. unsigned starpu_sched_ctx_get_nworkers(unsigned sched_ctx_id);
  91. unsigned starpu_sched_ctx_get_nshared_workers(unsigned sched_ctx_id, unsigned sched_ctx_id2);
  92. unsigned starpu_sched_ctx_contains_worker(int workerid, unsigned sched_ctx_id);
  93. unsigned starpu_sched_ctx_overlapping_ctxs_on_worker(int workerid);
  94. unsigned starpu_is_ctxs_turn(int workerid, unsigned sched_ctx_id);
  95. void starpu_set_turn_to_other_ctx(int workerid, unsigned sched_ctx_id);
  96. double starpu_get_max_time_worker_on_ctx(void);
  97. void starpu_stop_task_submission(void);
  98. void starpu_sched_ctx_set_inheritor(unsigned sched_ctx_id, unsigned inheritor);
  99. void starpu_sched_ctx_finished_submit(unsigned sched_ctx_id);
  100. #ifdef __cplusplus
  101. }
  102. #endif
  103. #endif /* __STARPU_SCHED_CTX_H__ */