starpu_worker.h 3.4 KB

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