starpu_top.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011 Inria
  4. * Copyright (C) 2011-2013,2017,2019 CNRS
  5. * Copyright (C) 2011-2013 Université de Bordeaux
  6. * Copyright (C) 2011 William Braik, Yann Courtois, Jean-Marie Couteyen, Anthony
  7. *
  8. * StarPU is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation; either version 2.1 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * StarPU is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  18. */
  19. #ifndef __STARPU_TOP_H__
  20. #define __STARPU_TOP_H__
  21. #include <starpu.h>
  22. #include <stdlib.h>
  23. #include <time.h>
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. /**
  29. @defgroup API_StarPUTop_Interface StarPU-Top Interface
  30. @{
  31. */
  32. /**
  33. StarPU-Top Data type
  34. */
  35. enum starpu_top_data_type
  36. {
  37. STARPU_TOP_DATA_BOOLEAN,
  38. STARPU_TOP_DATA_INTEGER,
  39. STARPU_TOP_DATA_FLOAT
  40. };
  41. struct starpu_top_data
  42. {
  43. unsigned int id;
  44. const char *name;
  45. int int_min_value;
  46. int int_max_value;
  47. double double_min_value;
  48. double double_max_value;
  49. int active;
  50. enum starpu_top_data_type type;
  51. struct starpu_top_data *next;
  52. };
  53. /**
  54. StarPU-Top Parameter type
  55. */
  56. enum starpu_top_param_type
  57. {
  58. STARPU_TOP_PARAM_BOOLEAN,
  59. STARPU_TOP_PARAM_INTEGER,
  60. STARPU_TOP_PARAM_FLOAT,
  61. STARPU_TOP_PARAM_ENUM
  62. };
  63. struct starpu_top_param
  64. {
  65. unsigned int id;
  66. const char *name;
  67. enum starpu_top_param_type type;
  68. void *value;
  69. char **enum_values; /**< only for enum type can be <c>NULL</c> */
  70. int nb_values;
  71. void (*callback)(struct starpu_top_param*);
  72. int int_min_value; /**< only for integer type */
  73. int int_max_value;
  74. double double_min_value; /**< only for double type */
  75. double double_max_value;
  76. struct starpu_top_param *next;
  77. };
  78. /**
  79. StarPU-Top Message type
  80. */
  81. enum starpu_top_message_type
  82. {
  83. TOP_TYPE_GO,
  84. TOP_TYPE_SET,
  85. TOP_TYPE_CONTINUE,
  86. TOP_TYPE_ENABLE,
  87. TOP_TYPE_DISABLE,
  88. TOP_TYPE_DEBUG,
  89. TOP_TYPE_UNKNOW
  90. };
  91. /**
  92. @name Functions to call before the initialisation
  93. @{
  94. */
  95. /**
  96. Register a data named \p data_name of type boolean. If \p active is
  97. 0, the value will NOT be displayed to users. Any other value will
  98. make the value displayed.
  99. */
  100. struct starpu_top_data *starpu_top_add_data_boolean(const char *data_name, int active);
  101. /**
  102. Register a data named \p data_name of type integer. \p
  103. minimum_value and \p maximum_value will be used to define the scale
  104. in the UI. If \p active is 0, the value will NOT be displayed to
  105. users. Any other value will make the value displayed.
  106. */
  107. struct starpu_top_data *starpu_top_add_data_integer(const char *data_name, int minimum_value, int maximum_value, int active);
  108. /**
  109. Register a data named \p data_name of type float. \p minimum_value
  110. and \p maximum_value will be used to define the scale in the UI. If
  111. \p active is 0, the value will NOT be displayed to users. Any other
  112. value will make the value displayed.
  113. */
  114. struct starpu_top_data *starpu_top_add_data_float(const char *data_name, double minimum_value, double maximum_value, int active);
  115. /**
  116. Register a parameter named \p parameter_name, of type boolean. If
  117. not \c NULL, the \p callback function will be called when the
  118. parameter is modified by the UI.
  119. */
  120. struct starpu_top_param *starpu_top_register_parameter_boolean(const char *param_name, int *parameter_field, void (*callback)(struct starpu_top_param*));
  121. /**
  122. Register a parameter named \p param_name, of type integer. \p
  123. minimum_value and \p maximum_value will be used to prevent users
  124. from setting incorrect value. If not \c NULL, the \p callback
  125. function will be called when the parameter is modified by the UI.
  126. */
  127. struct starpu_top_param *starpu_top_register_parameter_integer(const char *param_name, int *parameter_field, int minimum_value, int maximum_value, void (*callback)(struct starpu_top_param*));
  128. /**
  129. Register a parameter named \p param_name, of type float. \p
  130. minimum_value and \p maximum_value will be used to prevent users
  131. from setting incorrect value. If not \c NULL, the \p callback
  132. function will be called when the parameter is modified by the UI.
  133. */
  134. struct starpu_top_param *starpu_top_register_parameter_float(const char *param_name, double *parameter_field, double minimum_value, double maximum_value, void (*callback)(struct starpu_top_param*));
  135. /**
  136. Register a parameter named \p param_name, of type enum. \p values
  137. and \p nb_values will be used to prevent users from setting
  138. incorrect value. If not \c NULL, the \p callback function will be
  139. called when the parameter is modified by the UI.
  140. */
  141. struct starpu_top_param *starpu_top_register_parameter_enum(const char *param_name, int *parameter_field, char **values, int nb_values, void (*callback)(struct starpu_top_param*));
  142. /** @} */
  143. /**
  144. @name Initialisation
  145. @{
  146. */
  147. /**
  148. Must be called when all parameters and data have been registered
  149. AND initialised (for parameters). It will wait for a TOP to
  150. connect, send initialisation sentences, and wait for the GO
  151. message.
  152. */
  153. void starpu_top_init_and_wait(const char *server_name);
  154. /** @} */
  155. /**
  156. @name To call after initialisation
  157. @{
  158. */
  159. /**
  160. Should be called after every modification of a parameter from
  161. something other than starpu_top. It notices the UI that the
  162. configuration has changed.
  163. */
  164. void starpu_top_update_parameter(const struct starpu_top_param *param);
  165. /**
  166. Update the boolean value of \p data to \p value the UI.
  167. */
  168. void starpu_top_update_data_boolean(const struct starpu_top_data *data, int value);
  169. /**
  170. Update the integer value of \p data to \p value the UI.
  171. */
  172. void starpu_top_update_data_integer(const struct starpu_top_data *data, int value);
  173. /**
  174. Update the float value of \p data to \p value the UI.
  175. */
  176. void starpu_top_update_data_float(const struct starpu_top_data *data, double value);
  177. /**
  178. Notify the UI that \p task is planned to run from \p start to \p
  179. end, on computation-core.
  180. */
  181. void starpu_top_task_prevision(struct starpu_task *task, int devid, unsigned long long start, unsigned long long end);
  182. /**
  183. When running in debug mode, display \p message in the UI.
  184. */
  185. void starpu_top_debug_log(const char *message);
  186. /**
  187. When running in debug mode, send \p message to the UI and wait for
  188. a continue message to return. The lock (which creates a stop-point)
  189. should be called only by the main thread. Calling it from more than
  190. one thread is not supported.
  191. */
  192. void starpu_top_debug_lock(const char *message);
  193. /** @} */
  194. #ifdef __cplusplus
  195. }
  196. #endif
  197. #endif /* __STARPU_TOP_H__ */