starpurm_private.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2017-2021 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. /** @file */
  19. enum e_state
  20. {
  21. state_uninitialized = 0,
  22. state_init
  23. };
  24. enum e_starpurm_unit_type
  25. {
  26. starpurm_unit_cpu = 0,
  27. starpurm_unit_opencl = 1,
  28. starpurm_unit_cuda = 2,
  29. starpurm_unit_mic = 3,
  30. starpurm_unit_ntypes = 4
  31. };
  32. struct s_starpurm
  33. {
  34. /** Machine topology as detected by hwloc. */
  35. hwloc_topology_t topology;
  36. /** Current upper bound on the number of CPU cores selectable for computing with the runtime system. */
  37. unsigned max_ncpus;
  38. /** Number of currently selected CPU workers */
  39. unsigned selected_ncpus;
  40. /** Number of currently selected workers (CPU+devices) */
  41. unsigned selected_nworkers;
  42. /** Initialization state of the RM instance. */
  43. int state;
  44. /** Boolean indicating the state of the dynamic resource sharing layer.
  45. *
  46. * !0 indicates that dynamic resource sharing is enabled.
  47. * 0 indicates that dynamic resource sharing is disabled.
  48. */
  49. int dynamic_resource_sharing;
  50. /** Id of the StarPU's sched_ctx used by the RM instance. */
  51. unsigned sched_ctx_id;
  52. /** Number of unit types supported by this RM instance. */
  53. int unit_ntypes;
  54. /** Number of unitss available for each type. */
  55. int *nunits_by_type;
  56. /** Number of units. */
  57. int nunits;
  58. /** Offset of unit numbering for each type. */
  59. int *unit_offsets_by_type;
  60. /** Array of units. */
  61. struct s_starpurm_unit *units;
  62. /** Cpuset of all the StarPU's workers (CPU+devices. */
  63. hwloc_cpuset_t global_cpuset;
  64. /** Cpuset of all StarPU CPU workers. */
  65. hwloc_cpuset_t all_cpu_workers_cpuset;
  66. /** Cpuset of all StarPU OpenCL workers. */
  67. hwloc_cpuset_t all_opencl_device_workers_cpuset;
  68. /** Cpuset of all StarPU CUDA workers. */
  69. hwloc_cpuset_t all_cuda_device_workers_cpuset;
  70. /** Cpuset of all StarPU MIC workers. */
  71. hwloc_cpuset_t all_mic_device_workers_cpuset;
  72. /** Cpuset of all StarPU device workers. */
  73. hwloc_cpuset_t all_device_workers_cpuset;
  74. /** Cpuset of all selected workers (CPU+devices). */
  75. hwloc_cpuset_t selected_cpuset;
  76. /** Cpuset mask of initially owned cpuset or full if not used. */
  77. hwloc_cpuset_t initially_owned_cpuset_mask;
  78. /** maximum value among worker ids */
  79. int max_worker_id;
  80. /** worker id to unit id table */
  81. int *worker_unit_ids;
  82. /** Temporary contexts accounting. */
  83. unsigned int max_temporary_ctxs;
  84. unsigned int avail_temporary_ctxs;
  85. pthread_mutex_t temporary_ctxs_mutex;
  86. pthread_cond_t temporary_ctxs_cond;
  87. /** Global StarPU pause state */
  88. int starpu_in_pause;
  89. /** Event list. */
  90. pthread_t event_thread;
  91. pthread_mutex_t event_list_mutex;
  92. pthread_cond_t event_list_cond;
  93. pthread_cond_t event_processing_cond;
  94. int event_processing_enabled;
  95. int event_processing_ended;
  96. struct s_starpurm_event *event_list_head;
  97. struct s_starpurm_event *event_list_tail;
  98. };
  99. #ifdef STARPURM_HAVE_DLB
  100. void starpurm_dlb_init(struct s_starpurm *rm);
  101. void starpurm_dlb_exit(void);
  102. int starpurm_dlb_notify_starpu_worker_mask_going_to_sleep(const hwloc_cpuset_t hwloc_workers_cpuset);
  103. int starpurm_dlb_notify_starpu_worker_mask_waking_up(const hwloc_cpuset_t hwloc_workers_cpuset);
  104. #ifdef STARPURM_STARPU_HAVE_WORKER_CALLBACKS
  105. void starpurm_enqueue_event_cpu_unit_available(int cpuid);
  106. #endif
  107. #endif
  108. #endif /* __STARPURM_PRIVATE_H */