starpurm_private.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2017-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef __STARPURM_PRIVATE_H
  17. #define __STARPURM_PRIVATE_H
  18. enum e_state {
  19. state_uninitialized = 0,
  20. state_init
  21. };
  22. enum e_starpurm_unit_type
  23. {
  24. starpurm_unit_cpu = 0,
  25. starpurm_unit_opencl = 1,
  26. starpurm_unit_cuda = 2,
  27. starpurm_unit_mic = 3,
  28. starpurm_unit_ntypes = 4
  29. };
  30. struct s_starpurm
  31. {
  32. /* Machine topology as detected by hwloc. */
  33. hwloc_topology_t topology;
  34. /* Current upper bound on the number of CPU cores selectable for computing with the runtime system. */
  35. unsigned max_ncpus;
  36. /* Number of currently selected CPU workers */
  37. unsigned selected_ncpus;
  38. /* Number of currently selected workers (CPU+devices) */
  39. unsigned selected_nworkers;
  40. /* Initialization state of the RM instance. */
  41. int state;
  42. /* Boolean indicating the state of the dynamic resource sharing layer.
  43. *
  44. * !0 indicates that dynamic resource sharing is enabled.
  45. * 0 indicates that dynamic resource sharing is disabled.
  46. */
  47. int dynamic_resource_sharing;
  48. /* Id of the StarPU's sched_ctx used by the RM instance. */
  49. unsigned sched_ctx_id;
  50. /* Number of unit types supported by this RM instance. */
  51. int unit_ntypes;
  52. /* Number of unitss available for each type. */
  53. int *nunits_by_type;
  54. /* Number of units. */
  55. int nunits;
  56. /* Offset of unit numbering for each type. */
  57. int *unit_offsets_by_type;
  58. /* Array of units. */
  59. struct s_starpurm_unit *units;
  60. /* Cpuset of all the StarPU's workers (CPU+devices. */
  61. hwloc_cpuset_t global_cpuset;
  62. /* Cpuset of all StarPU CPU workers. */
  63. hwloc_cpuset_t all_cpu_workers_cpuset;
  64. /* Cpuset of all StarPU OpenCL workers. */
  65. hwloc_cpuset_t all_opencl_device_workers_cpuset;
  66. /* Cpuset of all StarPU CUDA workers. */
  67. hwloc_cpuset_t all_cuda_device_workers_cpuset;
  68. /* Cpuset of all StarPU MIC workers. */
  69. hwloc_cpuset_t all_mic_device_workers_cpuset;
  70. /* Cpuset of all StarPU device workers. */
  71. hwloc_cpuset_t all_device_workers_cpuset;
  72. /* Cpuset of all selected workers (CPU+devices). */
  73. hwloc_cpuset_t selected_cpuset;
  74. /* Cpuset mask of initially owned cpuset or full if not used. */
  75. hwloc_cpuset_t initially_owned_cpuset_mask;
  76. /* maximum value among worker ids */
  77. int max_worker_id;
  78. /* worker id to unit id table */
  79. int *worker_unit_ids;
  80. /* Temporary contexts accounting. */
  81. unsigned int max_temporary_ctxs;
  82. unsigned int avail_temporary_ctxs;
  83. pthread_mutex_t temporary_ctxs_mutex;
  84. pthread_cond_t temporary_ctxs_cond;
  85. /* Global StarPU pause state */
  86. int starpu_in_pause;
  87. /* Event list. */
  88. pthread_t event_thread;
  89. pthread_mutex_t event_list_mutex;
  90. pthread_cond_t event_list_cond;
  91. pthread_cond_t event_processing_cond;
  92. int event_processing_enabled;
  93. int event_processing_ended;
  94. struct s_starpurm_event *event_list_head;
  95. struct s_starpurm_event *event_list_tail;
  96. };
  97. #ifdef STARPURM_HAVE_DLB
  98. void starpurm_dlb_init(struct s_starpurm *rm);
  99. void starpurm_dlb_exit(void);
  100. int starpurm_dlb_notify_starpu_worker_mask_going_to_sleep(const hwloc_cpuset_t hwloc_workers_cpuset);
  101. int starpurm_dlb_notify_starpu_worker_mask_waking_up(const hwloc_cpuset_t hwloc_workers_cpuset);
  102. #ifdef STARPURM_STARPU_HAVE_WORKER_CALLBACKS
  103. void starpurm_enqueue_event_cpu_unit_available(int cpuid);
  104. #endif
  105. #endif
  106. #endif /* __STARPURM_PRIVATE_H */