starpu_top.h 7.8 KB

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