starpu_perf_monitoring.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2019-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 __STARPU_PERF_MONITORING_H__
  17. #define __STARPU_PERF_MONITORING_H__
  18. #include <starpu.h>
  19. #ifdef __cplusplus
  20. extern "C"
  21. {
  22. #endif
  23. /**
  24. @defgroup API_Perf_Monitoring Performance Monitoring Counters
  25. @brief This section describes the interface to access performance monitoring counters.
  26. @{
  27. */
  28. /**
  29. @name API
  30. \anchor PM_API
  31. @{
  32. */
  33. /**
  34. Enum of all possible performance counter scopes.
  35. */
  36. enum starpu_perf_counter_scope
  37. {
  38. starpu_perf_counter_scope_undefined = 0, /**< undefined scope */
  39. starpu_perf_counter_scope_global = 2, /**< global scope */
  40. starpu_perf_counter_scope_per_worker = 4, /**< per-worker scope */
  41. starpu_perf_counter_scope_per_codelet = 6 /**< per-codelet scope */
  42. };
  43. /**
  44. Enum of all possible performance counter value type.
  45. */
  46. enum starpu_perf_counter_type
  47. {
  48. starpu_perf_counter_type_undefined = 0, /**< underfined value type */
  49. starpu_perf_counter_type_int32 = 1, /**< signed 32-bit integer value */
  50. starpu_perf_counter_type_int64 = 2, /**< signed 64-bit integer value */
  51. starpu_perf_counter_type_float = 3, /**< 32-bit single precision floating-point value */
  52. starpu_perf_counter_type_double = 4 /**< 64-bit double precision floating-point value */
  53. };
  54. struct starpu_perf_counter_listener;
  55. struct starpu_perf_counter_sample;
  56. struct starpu_perf_counter_set;
  57. /**
  58. Start collecting performance counter values.
  59. */
  60. void starpu_perf_counter_collection_start(void);
  61. /**
  62. Stop collecting performance counter values.
  63. */
  64. void starpu_perf_counter_collection_stop(void);
  65. /**
  66. Translate scope name constant string to scope id.
  67. */
  68. int starpu_perf_counter_scope_name_to_id(const char *name);
  69. /**
  70. Translate scope id to scope name constant string.
  71. */
  72. const char *starpu_perf_counter_scope_id_to_name(enum starpu_perf_counter_scope scope);
  73. /**
  74. Translate type name constant string to type id.
  75. */
  76. int starpu_perf_counter_type_name_to_id(const char *name);
  77. /**
  78. Translate type id to type name constant string.
  79. */
  80. const char *starpu_perf_counter_type_id_to_name(enum starpu_perf_counter_type type);
  81. /**
  82. Return the number of performance counters for the given scope.
  83. */
  84. int starpu_perf_counter_nb(enum starpu_perf_counter_scope scope);
  85. /**
  86. Translate a performance counter name to its id.
  87. */
  88. int starpu_perf_counter_name_to_id(enum starpu_perf_counter_scope scope, const char *name);
  89. /**
  90. Translate a performance counter rank in its scope to its counter id.
  91. */
  92. int starpu_perf_counter_nth_to_id(enum starpu_perf_counter_scope scope, int nth);
  93. /**
  94. Translate a counter id to its name constant string.
  95. */
  96. const char *starpu_perf_counter_id_to_name(int id);
  97. /**
  98. Return the counter's type id.
  99. */
  100. int starpu_perf_counter_get_type_id(int id);
  101. /**
  102. Return the counter's help string.
  103. */
  104. const char *starpu_perf_counter_get_help_string(int id);
  105. /**
  106. Display the list of counters defined in the given scope.
  107. */
  108. void starpu_perf_counter_list_avail(enum starpu_perf_counter_scope scope);
  109. /**
  110. Display the list of counters defined in all scopes.
  111. */
  112. void starpu_perf_counter_list_all_avail(void);
  113. /**
  114. Allocate a new performance counter set.
  115. */
  116. struct starpu_perf_counter_set *starpu_perf_counter_set_alloc(enum starpu_perf_counter_scope scope);
  117. /**
  118. Free a performance counter set.
  119. */
  120. void starpu_perf_counter_set_free(struct starpu_perf_counter_set *set);
  121. /**
  122. Enable a given counter in the set.
  123. */
  124. void starpu_perf_counter_set_enable_id(struct starpu_perf_counter_set *set, int id);
  125. /**
  126. Disable a given counter in the set.
  127. */
  128. void starpu_perf_counter_set_disable_id(struct starpu_perf_counter_set *set, int id);
  129. /**
  130. Initialize a new performance counter listener.
  131. */
  132. struct starpu_perf_counter_listener *starpu_perf_counter_listener_init(struct starpu_perf_counter_set *set, void (*callback)(struct starpu_perf_counter_listener *listener, struct starpu_perf_counter_sample *sample, void *context), void *user_arg);
  133. /**
  134. End a performance counter listener.
  135. */
  136. void starpu_perf_counter_listener_exit(struct starpu_perf_counter_listener *listener);
  137. /**
  138. Set a listener for the global scope.
  139. */
  140. void starpu_perf_counter_set_global_listener(struct starpu_perf_counter_listener *listener);
  141. /**
  142. Set a listener for the per_worker scope on a given worker.
  143. */
  144. void starpu_perf_counter_set_per_worker_listener(unsigned workerid, struct starpu_perf_counter_listener *listener);
  145. /**
  146. Set a common listener for all workers.
  147. */
  148. void starpu_perf_counter_set_all_per_worker_listeners(struct starpu_perf_counter_listener *listener);
  149. /**
  150. Set a per_codelet listener for a codelet.
  151. */
  152. void starpu_perf_counter_set_per_codelet_listener(struct starpu_codelet *cl, struct starpu_perf_counter_listener *listener);
  153. /**
  154. Unset the global listener.
  155. */
  156. void starpu_perf_counter_unset_global_listener(void);
  157. /**
  158. Unset the per_worker listener.
  159. */
  160. void starpu_perf_counter_unset_per_worker_listener(unsigned workerid);
  161. /**
  162. Unset all per_worker listeners.
  163. */
  164. void starpu_perf_counter_unset_all_per_worker_listeners(void);
  165. /**
  166. Unset a per_codelet listener.
  167. */
  168. void starpu_perf_counter_unset_per_codelet_listener(struct starpu_codelet *cl);
  169. /**
  170. Read an int32 counter value from a sample.
  171. */
  172. int32_t starpu_perf_counter_sample_get_int32_value(struct starpu_perf_counter_sample *sample, const int counter_id);
  173. /**
  174. Read an int64 counter value from a sample.
  175. */
  176. int64_t starpu_perf_counter_sample_get_int64_value(struct starpu_perf_counter_sample *sample, const int counter_id);
  177. /**
  178. Read a float counter value from a sample.
  179. */
  180. float starpu_perf_counter_sample_get_float_value(struct starpu_perf_counter_sample *sample, const int counter_id);
  181. /**
  182. Read a double counter value from a sample.
  183. */
  184. double starpu_perf_counter_sample_get_double_value(struct starpu_perf_counter_sample *sample, const int counter_id);
  185. /** @} */
  186. /** @} */
  187. #ifdef __cplusplus
  188. }
  189. #endif
  190. #endif /* __STARPU_PERF_MONITORING_H__ */