starpu_top.h 7.6 KB

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