starpu_worker.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2013-2017 Inria
  4. * Copyright (C) 2010-2015,2017 CNRS
  5. * Copyright (C) 2009-2014,2016-2017 Université de Bordeaux
  6. * Copyright (C) 2016 Uppsala University
  7. *
  8. * StarPU is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation; either version 2.1 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * StarPU is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  18. */
  19. #ifndef __STARPU_WORKER_H__
  20. #define __STARPU_WORKER_H__
  21. #include <stdlib.h>
  22. #include <starpu_config.h>
  23. #include <starpu_thread.h>
  24. #include <starpu_task.h>
  25. #ifdef STARPU_HAVE_HWLOC
  26. #include <hwloc.h>
  27. #endif
  28. #ifdef __cplusplus
  29. extern "C"
  30. {
  31. #endif
  32. enum starpu_worker_archtype
  33. {
  34. STARPU_CPU_WORKER,
  35. STARPU_CUDA_WORKER,
  36. STARPU_OPENCL_WORKER,
  37. STARPU_MIC_WORKER,
  38. STARPU_SCC_WORKER,
  39. STARPU_MPI_MS_WORKER,
  40. STARPU_ANY_WORKER
  41. };
  42. struct starpu_sched_ctx_iterator
  43. {
  44. int cursor;
  45. void *value;
  46. void *possible_value;
  47. char visited[STARPU_NMAXWORKERS];
  48. int possibly_parallel;
  49. };
  50. enum starpu_worker_collection_type
  51. {
  52. STARPU_WORKER_TREE,
  53. STARPU_WORKER_LIST
  54. };
  55. struct starpu_worker_collection
  56. {
  57. int *workerids;
  58. void *collection_private;
  59. unsigned nworkers;
  60. void *unblocked_workers;
  61. unsigned nunblocked_workers;
  62. void *masters;
  63. unsigned nmasters;
  64. char present[STARPU_NMAXWORKERS];
  65. char is_unblocked[STARPU_NMAXWORKERS];
  66. char is_master[STARPU_NMAXWORKERS];
  67. enum starpu_worker_collection_type type;
  68. unsigned (*has_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  69. int (*get_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  70. int (*add)(struct starpu_worker_collection *workers, int worker);
  71. int (*remove)(struct starpu_worker_collection *workers, int worker);
  72. void (*init)(struct starpu_worker_collection *workers);
  73. void (*deinit)(struct starpu_worker_collection *workers);
  74. void (*init_iterator)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  75. void (*init_iterator_for_parallel_tasks)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it, struct starpu_task *task);
  76. };
  77. extern struct starpu_worker_collection worker_list;
  78. extern struct starpu_worker_collection worker_tree;
  79. unsigned starpu_worker_get_count(void);
  80. unsigned starpu_combined_worker_get_count(void);
  81. unsigned starpu_worker_is_combined_worker(int id);
  82. unsigned starpu_cpu_worker_get_count(void);
  83. unsigned starpu_cuda_worker_get_count(void);
  84. unsigned starpu_opencl_worker_get_count(void);
  85. unsigned starpu_mic_worker_get_count(void);
  86. unsigned starpu_scc_worker_get_count(void);
  87. unsigned starpu_mpi_ms_worker_get_count(void);
  88. unsigned starpu_mic_device_get_count(void);
  89. int starpu_worker_get_id(void);
  90. unsigned _starpu_worker_get_id_check(const char *f, int l);
  91. unsigned starpu_worker_get_id_check(void);
  92. #define starpu_worker_get_id_check() _starpu_worker_get_id_check(__FILE__, __LINE__)
  93. int starpu_worker_get_bindid(int workerid);
  94. int starpu_combined_worker_get_id(void);
  95. int starpu_combined_worker_get_size(void);
  96. int starpu_combined_worker_get_rank(void);
  97. enum starpu_worker_archtype starpu_worker_get_type(int id);
  98. int starpu_worker_get_count_by_type(enum starpu_worker_archtype type);
  99. unsigned starpu_worker_get_ids_by_type(enum starpu_worker_archtype type, int *workerids, unsigned maxsize);
  100. int starpu_worker_get_by_type(enum starpu_worker_archtype type, int num);
  101. int starpu_worker_get_by_devid(enum starpu_worker_archtype type, int devid);
  102. void starpu_worker_get_name(int id, char *dst, size_t maxlen);
  103. void starpu_worker_display_names(FILE *output, enum starpu_worker_archtype type);
  104. int starpu_worker_get_devid(int id);
  105. int starpu_worker_get_mp_nodeid(int id);
  106. struct starpu_tree* starpu_workers_get_tree(void);
  107. unsigned starpu_worker_get_sched_ctx_list(int worker, unsigned **sched_ctx);
  108. unsigned starpu_worker_is_blocked_in_parallel(int workerid);
  109. unsigned starpu_worker_is_slave_somewhere(int workerid);
  110. char *starpu_worker_get_type_as_string(enum starpu_worker_archtype type);
  111. int starpu_bindid_get_workerids(int bindid, int **workerids);
  112. int starpu_worker_get_devids(enum starpu_worker_archtype type, int *devids, int num);
  113. int starpu_worker_get_stream_workerids(unsigned devid, int *workerids, enum starpu_worker_archtype type);
  114. unsigned starpu_worker_get_sched_ctx_id_stream(unsigned stream_workerid);
  115. int starpu_worker_sched_op_pending(void);
  116. void starpu_worker_relax_on(void);
  117. void starpu_worker_relax_off(void);
  118. int starpu_worker_get_relax_state(void);
  119. void starpu_worker_lock(int workerid);
  120. int starpu_worker_trylock(int workerid);
  121. void starpu_worker_unlock(int workerid);
  122. void starpu_worker_lock_self(void);
  123. void starpu_worker_unlock_self(void);
  124. int starpu_wake_worker_relax(int workerid);
  125. #ifdef STARPU_WORKER_CALLBACKS
  126. void starpu_worker_set_going_to_sleep_callback(void (*callback)(unsigned workerid));
  127. void starpu_worker_set_waking_up_callback(void (*callback)(unsigned workerid));
  128. #endif
  129. #ifdef STARPU_HAVE_HWLOC
  130. hwloc_cpuset_t starpu_worker_get_hwloc_cpuset(int workerid);
  131. #endif
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif /* __STARPU_WORKER_H__ */