starpu_worker.h 6.3 KB

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