starpu_worker.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2013 Université de Bordeaux
  4. * Copyright (C) 2010-2014 Centre National de la Recherche Scientifique
  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. int visited[STARPU_NMAXWORKERS];
  41. };
  42. enum starpu_worker_collection_type
  43. {
  44. STARPU_WORKER_TREE,
  45. STARPU_WORKER_LIST
  46. };
  47. struct starpu_worker_collection
  48. {
  49. void *workerids;
  50. unsigned nworkers;
  51. void *masters;
  52. unsigned nmasters;
  53. int present[STARPU_NMAXWORKERS];
  54. int is_master[STARPU_NMAXWORKERS];
  55. enum starpu_worker_collection_type type;
  56. unsigned (*has_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  57. int (*get_next)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  58. unsigned (*has_next_master)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  59. int (*get_next_master)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  60. int (*add)(struct starpu_worker_collection *workers, int worker);
  61. int (*remove)(struct starpu_worker_collection *workers, int worker);
  62. void (*init)(struct starpu_worker_collection *workers);
  63. void (*deinit)(struct starpu_worker_collection *workers);
  64. void (*init_iterator)(struct starpu_worker_collection *workers, struct starpu_sched_ctx_iterator *it);
  65. };
  66. extern struct starpu_worker_collection worker_list;
  67. extern struct starpu_worker_collection worker_tree;
  68. unsigned starpu_worker_get_count(void);
  69. unsigned starpu_combined_worker_get_count(void);
  70. unsigned starpu_worker_is_combined_worker(int id);
  71. unsigned starpu_cpu_worker_get_count(void);
  72. unsigned starpu_cuda_worker_get_count(void);
  73. unsigned starpu_opencl_worker_get_count(void);
  74. unsigned starpu_mic_worker_get_count(void);
  75. unsigned starpu_scc_worker_get_count(void);
  76. unsigned starpu_mic_device_get_count(void);
  77. int starpu_worker_get_id(void);
  78. int starpu_worker_get_bindid(int workerid);
  79. int starpu_combined_worker_get_id(void);
  80. int starpu_combined_worker_get_size(void);
  81. int starpu_combined_worker_get_rank(void);
  82. enum starpu_worker_archtype starpu_worker_get_type(int id);
  83. int starpu_worker_get_count_by_type(enum starpu_worker_archtype type);
  84. int starpu_worker_get_ids_by_type(enum starpu_worker_archtype type, int *workerids, int maxsize);
  85. int starpu_worker_get_by_type(enum starpu_worker_archtype type, int num);
  86. int starpu_worker_get_by_devid(enum starpu_worker_archtype type, int devid);
  87. void starpu_worker_get_name(int id, char *dst, size_t maxlen);
  88. int starpu_worker_get_devid(int id);
  89. int starpu_worker_get_mp_nodeid(int id);
  90. struct starpu_tree* starpu_workers_get_tree(void);
  91. unsigned starpu_worker_get_sched_ctx_list(int worker, unsigned **sched_ctx);
  92. unsigned starpu_worker_is_slave(int workerid);
  93. char *starpu_worker_get_type_as_string(enum starpu_worker_archtype type);
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #endif /* __STARPU_WORKER_H__ */