starpu_worker.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2013, 2016 Université de Bordeaux
  4. * Copyright (C) 2010-2014 CNRS
  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_WORKER_H__
  18. #define __STARPU_WORKER_H__
  19. #include <stdlib.h>
  20. #include <starpu_config.h>
  21. #include <starpu_thread.h>
  22. #ifdef __cplusplus
  23. extern "C"
  24. {
  25. #endif
  26. enum starpu_worker_archtype
  27. {
  28. STARPU_CPU_WORKER,
  29. STARPU_CUDA_WORKER,
  30. STARPU_OPENCL_WORKER,
  31. STARPU_MIC_WORKER,
  32. STARPU_SCC_WORKER,
  33. STARPU_ANY_WORKER
  34. };
  35. struct starpu_sched_ctx_iterator
  36. {
  37. int cursor;
  38. void *value;
  39. void *possible_value;
  40. char visited[STARPU_NMAXWORKERS];
  41. int possibly_parallel;
  42. };
  43. enum starpu_worker_collection_type
  44. {
  45. STARPU_WORKER_TREE,
  46. STARPU_WORKER_LIST
  47. };
  48. struct starpu_worker_collection
  49. {
  50. void *workerids;
  51. unsigned nworkers;
  52. void *unblocked_workers;
  53. unsigned nunblocked_workers;
  54. void *masters;
  55. unsigned nmasters;
  56. char present[STARPU_NMAXWORKERS];
  57. char is_unblocked[STARPU_NMAXWORKERS];
  58. char is_master[STARPU_NMAXWORKERS];
  59. enum starpu_worker_collection_type type;
  60. unsigned (*has_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  61. int (*get_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  62. int (*add)(struct starpu_worker_collection *workers, int worker);
  63. int (*remove)(struct starpu_worker_collection *workers, int worker);
  64. void (*init)(struct starpu_worker_collection *workers);
  65. void (*deinit)(struct starpu_worker_collection *workers);
  66. void (*init_iterator)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  67. void (*init_iterator_for_parallel_tasks)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it, struct starpu_task *task);
  68. };
  69. extern struct starpu_worker_collection worker_list;
  70. extern struct starpu_worker_collection worker_tree;
  71. unsigned starpu_worker_get_count(void);
  72. unsigned starpu_combined_worker_get_count(void);
  73. unsigned starpu_worker_is_combined_worker(int id);
  74. unsigned starpu_cpu_worker_get_count(void);
  75. unsigned starpu_cuda_worker_get_count(void);
  76. unsigned starpu_opencl_worker_get_count(void);
  77. unsigned starpu_mic_worker_get_count(void);
  78. unsigned starpu_scc_worker_get_count(void);
  79. unsigned starpu_mic_device_get_count(void);
  80. int starpu_worker_get_id(void);
  81. unsigned _starpu_worker_get_id_check(const char *f, int l);
  82. unsigned starpu_worker_get_id_check(void);
  83. #define starpu_worker_get_id_check() _starpu_worker_get_id_check(__FILE__, __LINE__)
  84. int starpu_worker_get_bindid(int workerid);
  85. int starpu_combined_worker_get_id(void);
  86. int starpu_combined_worker_get_size(void);
  87. int starpu_combined_worker_get_rank(void);
  88. enum starpu_worker_archtype starpu_worker_get_type(int id);
  89. int starpu_worker_get_count_by_type(enum starpu_worker_archtype type);
  90. int starpu_worker_get_ids_by_type(enum starpu_worker_archtype type, int *workerids, int maxsize);
  91. int starpu_worker_get_by_type(enum starpu_worker_archtype type, int num);
  92. int starpu_worker_get_by_devid(enum starpu_worker_archtype type, int devid);
  93. void starpu_worker_get_name(int id, char *dst, size_t maxlen);
  94. int starpu_worker_get_devid(int id);
  95. int starpu_worker_get_mp_nodeid(int id);
  96. struct starpu_tree* starpu_workers_get_tree(void);
  97. unsigned starpu_worker_get_sched_ctx_list(int worker, unsigned **sched_ctx);
  98. unsigned starpu_worker_is_blocked(int workerid);
  99. unsigned starpu_worker_is_slave_somewhere(int workerid);
  100. char *starpu_worker_get_type_as_string(enum starpu_worker_archtype type);
  101. int starpu_bindid_get_workerids(int bindid, int **workerids);
  102. #ifdef __cplusplus
  103. }
  104. #endif
  105. #endif /* __STARPU_WORKER_H__ */