starpu_top.h 7.8 KB

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