starpu_clusters_create.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2015-2017, 2019 CNRS
  4. * Copyright (C) 2015,2016 Inria
  5. * Copyright (C) 2015 Université de Bordeaux
  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_CLUSTERS_CREATE_H__
  19. #define __STARPU_CLUSTERS_CREATE_H__
  20. #include <starpu.h>
  21. #include <core/workers.h>
  22. #include <common/list.h>
  23. #include <string.h>
  24. #include <omp.h>
  25. #ifdef STARPU_MKL
  26. #include <mkl_service.h>
  27. #endif
  28. #ifdef __cplusplus
  29. extern
  30. #endif
  31. struct starpu_cluster_machine
  32. {
  33. unsigned id;
  34. hwloc_topology_t topology;
  35. unsigned nclusters;
  36. unsigned ngroups;
  37. struct _starpu_cluster_group_list* groups;
  38. struct _starpu_cluster_parameters* params;
  39. };
  40. struct _starpu_cluster_parameters
  41. {
  42. int min_nb;
  43. int max_nb;
  44. int nb;
  45. char* sched_policy_name;
  46. struct starpu_sched_policy* sched_policy_struct;
  47. unsigned keep_homogeneous;
  48. unsigned prefere_min;
  49. void (*create_func)(void*);
  50. void* create_func_arg;
  51. int type;
  52. unsigned awake_workers;
  53. };
  54. LIST_TYPE(_starpu_cluster_group,
  55. unsigned id;
  56. hwloc_obj_t group_obj;
  57. int nclusters;
  58. struct _starpu_cluster_list* clusters;
  59. struct starpu_cluster_machine* father;
  60. struct _starpu_cluster_parameters* params;
  61. )
  62. LIST_TYPE(_starpu_cluster,
  63. unsigned id;
  64. hwloc_cpuset_t cpuset;
  65. int ncores;
  66. int* cores;
  67. int* workerids;
  68. struct _starpu_cluster_group* father;
  69. struct _starpu_cluster_parameters* params;
  70. )
  71. /* Machine discovery and cluster creation main funcitons */
  72. int _starpu_cluster_machine(hwloc_obj_type_t cluster_level,
  73. struct starpu_cluster_machine* machine);
  74. int _starpu_cluster_topology(hwloc_obj_type_t cluster_level,
  75. struct starpu_cluster_machine* machine);
  76. void _starpu_cluster_group(hwloc_obj_type_t cluster_level,
  77. struct starpu_cluster_machine* machine);
  78. void _starpu_cluster(struct _starpu_cluster_group* group);
  79. /* Parameter functions */
  80. void _starpu_cluster_init_parameters(struct _starpu_cluster_parameters* globals);
  81. void _starpu_cluster_copy_parameters(struct _starpu_cluster_parameters* src,
  82. struct _starpu_cluster_parameters* dst);
  83. int _starpu_cluster_analyze_parameters(struct _starpu_cluster_parameters* params, int npus);
  84. /* Cluster helper functions */
  85. void _starpu_cluster_init(struct _starpu_cluster* cluster, struct _starpu_cluster_group* father);
  86. void _starpu_cluster_create(struct _starpu_cluster* cluster);
  87. int _starpu_cluster_bind(struct _starpu_cluster* cluster);
  88. int _starpu_cluster_remove(struct _starpu_cluster_list* cluster_list,
  89. struct _starpu_cluster* cluster);
  90. /* Cluster group helper function */
  91. void _starpu_cluster_group_init(struct _starpu_cluster_group* group,
  92. struct starpu_cluster_machine* father);
  93. void _starpu_cluster_group_create(struct _starpu_cluster_group* group);
  94. int _starpu_cluster_group_remove(struct _starpu_cluster_group_list* group_list,
  95. struct _starpu_cluster_group* group);
  96. /* Binding helpers */
  97. void _starpu_cluster_noop(void* buffers[], void* cl_arg)
  98. {
  99. (void) buffers;
  100. (void) cl_arg;
  101. }
  102. static struct starpu_codelet _starpu_cluster_bind_cl=
  103. {
  104. .cpu_funcs = {_starpu_cluster_noop},
  105. .nbuffers = 0,
  106. .name = "cluster_internal_runtime_init"
  107. };
  108. typedef void (*starpu_binding_function)(void*);
  109. starpu_binding_function _starpu_cluster_type_get_func(enum starpu_cluster_types type);
  110. #endif /* __STARPU_CLUSTERS_CREATE_H__ */