starpu_worker.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. * Copyright (C) 2016 INRIA
  6. *
  7. * StarPU is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * StarPU is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. *
  16. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. */
  18. #ifndef __STARPU_WORKER_H__
  19. #define __STARPU_WORKER_H__
  20. #include <stdlib.h>
  21. #include <starpu_config.h>
  22. #include <starpu_thread.h>
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. enum starpu_worker_archtype
  28. {
  29. STARPU_CPU_WORKER,
  30. STARPU_CUDA_WORKER,
  31. STARPU_OPENCL_WORKER,
  32. STARPU_MIC_WORKER,
  33. STARPU_SCC_WORKER,
  34. STARPU_MPI_WORKER,
  35. STARPU_ANY_WORKER
  36. };
  37. struct starpu_sched_ctx_iterator
  38. {
  39. int cursor;
  40. void *value;
  41. void *possible_value;
  42. char visited[STARPU_NMAXWORKERS];
  43. int possibly_parallel;
  44. };
  45. enum starpu_worker_collection_type
  46. {
  47. STARPU_WORKER_TREE,
  48. STARPU_WORKER_LIST
  49. };
  50. struct starpu_worker_collection
  51. {
  52. int *workerids;
  53. void *collection_private;
  54. unsigned nworkers;
  55. void *unblocked_workers;
  56. unsigned nunblocked_workers;
  57. void *masters;
  58. unsigned nmasters;
  59. char present[STARPU_NMAXWORKERS];
  60. char is_unblocked[STARPU_NMAXWORKERS];
  61. char is_master[STARPU_NMAXWORKERS];
  62. enum starpu_worker_collection_type type;
  63. unsigned (*has_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  64. int (*get_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  65. int (*add)(struct starpu_worker_collection *workers, int worker);
  66. int (*remove)(struct starpu_worker_collection *workers, int worker);
  67. void (*init)(struct starpu_worker_collection *workers);
  68. void (*deinit)(struct starpu_worker_collection *workers);
  69. void (*init_iterator)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  70. void (*init_iterator_for_parallel_tasks)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it, struct starpu_task *task);
  71. };
  72. extern struct starpu_worker_collection worker_list;
  73. extern struct starpu_worker_collection worker_tree;
  74. unsigned starpu_worker_get_count(void);
  75. unsigned starpu_combined_worker_get_count(void);
  76. unsigned starpu_worker_is_combined_worker(int id);
  77. unsigned starpu_cpu_worker_get_count(void);
  78. unsigned starpu_cuda_worker_get_count(void);
  79. unsigned starpu_opencl_worker_get_count(void);
  80. unsigned starpu_mic_worker_get_count(void);
  81. unsigned starpu_scc_worker_get_count(void);
  82. unsigned starpu_mic_device_get_count(void);
  83. int starpu_worker_get_id(void);
  84. unsigned _starpu_worker_get_id_check(const char *f, int l);
  85. unsigned starpu_worker_get_id_check(void);
  86. #define starpu_worker_get_id_check() _starpu_worker_get_id_check(__FILE__, __LINE__)
  87. int starpu_worker_get_bindid(int workerid);
  88. int starpu_combined_worker_get_id(void);
  89. int starpu_combined_worker_get_size(void);
  90. int starpu_combined_worker_get_rank(void);
  91. enum starpu_worker_archtype starpu_worker_get_type(int id);
  92. int starpu_worker_get_count_by_type(enum starpu_worker_archtype type);
  93. int starpu_worker_get_ids_by_type(enum starpu_worker_archtype type, int *workerids, int maxsize);
  94. int starpu_worker_get_by_type(enum starpu_worker_archtype type, int num);
  95. int starpu_worker_get_by_devid(enum starpu_worker_archtype type, int devid);
  96. void starpu_worker_get_name(int id, char *dst, size_t maxlen);
  97. int starpu_worker_get_devid(int id);
  98. int starpu_worker_get_mp_nodeid(int id);
  99. struct starpu_tree* starpu_workers_get_tree(void);
  100. unsigned starpu_worker_get_sched_ctx_list(int worker, unsigned **sched_ctx);
  101. unsigned starpu_worker_is_blocked(int workerid);
  102. unsigned starpu_worker_is_slave_somewhere(int workerid);
  103. char *starpu_worker_get_type_as_string(enum starpu_worker_archtype type);
  104. int starpu_bindid_get_workerids(int bindid, int **workerids);
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif /* __STARPU_WORKER_H__ */