starpu_top.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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. #ifndef __STARPU_TOP_H__
  18. #define __STARPU_TOP_H__
  19. #include <stdlib.h>
  20. #include <time.h>
  21. #include <starpu.h>
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. typedef enum
  26. {
  27. STARPUTOP_DATA_BOOLEAN,
  28. STARPUTOP_DATA_INTEGER,
  29. STARPUTOP_DATA_FLOAT
  30. } starputop_data_type;
  31. typedef struct starputop_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. starputop_data_type type;
  41. struct starputop_data_t * next;
  42. } starputop_data;
  43. typedef enum
  44. {
  45. STARPUTOP_PARAM_BOOLEAN,
  46. STARPUTOP_PARAM_INTEGER,
  47. STARPUTOP_PARAM_FLOAT,
  48. STARPUTOP_PARAM_ENUM
  49. } starputop_param_type;
  50. typedef struct starputop_param_t
  51. {
  52. unsigned int id;
  53. const char* name;
  54. starputop_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 starputop_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 starputop_param_t * next;
  64. } starputop_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. } starputop_message_type;
  75. /*
  76. * This function returns 1 if starpu_top is initialized. 0 otherwise.
  77. */
  78. int starpu_top_status_get();
  79. /*
  80. * Convert timespec to ms
  81. */
  82. unsigned long long starpu_timing_timespec_to_ms(const struct timespec *ts);
  83. /*****************************************************
  84. **** Functions to call BEFORE initialisation *****
  85. *****************************************************/
  86. /*
  87. * This fonction register a data named data_name of type boolean
  88. * If active=0, the value will NOT be displayed to user by default.
  89. * Any other value will make the value displayed by default.
  90. */
  91. starputop_data * starputop_add_data_boolean(
  92. const char* data_name,
  93. int active);
  94. /*
  95. * This fonction register a data named data_name of type integer
  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. starputop_data * starputop_add_data_integer(
  101. const char* data_name,
  102. int minimum_value,
  103. int maximum_value,
  104. int active);
  105. /*
  106. * This fonction register a data named data_name of type float
  107. * The minimum and maximum value will be usefull to define the scale in UI
  108. * If active=0, the value will NOT be displayed to user by default.
  109. * Any other value will make the value displayed by default.
  110. */
  111. starputop_data* starputop_add_data_float(const char* data_name,
  112. double minimum_value,
  113. double maximum_value,
  114. int active);
  115. /*
  116. * This fonction register a parameter named parameter_name, of type boolean.
  117. * The callback fonction will be called when the parameter is modified by UI,
  118. * and can be null.
  119. */
  120. starputop_param* starputop_register_parameter_boolean(
  121. const char* param_name,
  122. int* parameter_field,
  123. void (*callback)(struct starputop_param_t*));
  124. /*
  125. * This fonction register a parameter named param_name, of type integer.
  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. starputop_param* starputop_register_parameter_integer(const char* param_name,
  132. int* parameter_field,
  133. int minimum_value,
  134. int maximum_value,
  135. void (*callback)(struct starputop_param_t*));
  136. /*
  137. * This fonction register a parameter named param_name, of type float.
  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. starputop_param* starputop_register_parameter_float(
  144. const char* param_name,
  145. double* parameter_field,
  146. double minimum_value,
  147. double maximum_value,
  148. void (*callback)(struct starputop_param_t*));
  149. /*
  150. * This fonction register a parameter named param_name, of type enum.
  151. * Minimum and maximum value will be used to prevent user seting incorrect
  152. * value.
  153. * The callback fonction will be called when the parameter is modified by UI,
  154. * and can be null.
  155. */
  156. starputop_param* starputop_register_parameter_enum(
  157. const char* param_name,
  158. int* parameter_field,
  159. char** values,
  160. int nb_values,
  161. void (*callback)(struct starputop_param_t*));
  162. /****************************************************
  163. ******************* Initialisation ******************
  164. *****************************************************/
  165. /*
  166. * This function must be called when all parameters and
  167. * data have been registered AND initialised (for parameters).
  168. * This function will wait for a TOP to connect, send initialisation
  169. * sentences, and wait for the GO message.
  170. */
  171. void starputop_init_and_wait(const char* server_name);
  172. /****************************************************
  173. ************ To call after initialisation************
  174. *****************************************************/
  175. /*
  176. * This function should be called after every modification
  177. * of a parameter from something other than starpu_top.
  178. * This fonction notice UI that the configuration changed
  179. */
  180. void starputop_update_parameter(const starputop_param* param);
  181. /*
  182. * This functions update the value of the starputop_data on UI
  183. */
  184. void starputop_update_data_boolean(
  185. const starputop_data* data,
  186. int value);
  187. void starputop_update_data_integer(
  188. const starputop_data* data,
  189. int value);
  190. void starputop_update_data_float(
  191. const starputop_data* data,
  192. double value);
  193. /*
  194. * This functions notify UI than the task has started or ended
  195. */
  196. void starputop_task_started(
  197. struct starpu_task *task,
  198. int devid,
  199. const struct timespec* ts);
  200. void starputop_task_ended(
  201. struct starpu_task *task,
  202. int devid,
  203. const struct timespec* ts );
  204. /*
  205. * This functions notify UI than the task have been planed to
  206. * run from timestamp_begin to timestamp_end, on computation-core
  207. */
  208. void starputop_task_prevision_timespec(
  209. struct starpu_task *task,
  210. int devid,
  211. const struct timespec* start,
  212. const struct timespec* end);
  213. void starputop_task_prevision(
  214. struct starpu_task *task,
  215. int devid, unsigned long long start,
  216. unsigned long long end);
  217. /*
  218. * This functions are usefull in debug mode. The starpu developper doesn't need
  219. * to check if the debug mode is active.
  220. * This is checked by starputop itsefl.
  221. *
  222. * top_debug_log just send a message to display by UI
  223. * top_debug_lock send a message and wait for a continue message from UI
  224. * to return
  225. *
  226. * The lock (wich create a stop-point) should be called only by the main thread.
  227. * Calling it from more than one thread is not supported.
  228. */
  229. void starputop_debug_log(const char* message);
  230. void starputop_debug_lock(const char* message);
  231. /****************************************************
  232. ***************** Callback function *****************
  233. *****************************************************/
  234. void starputop_process_input_message(char *message);
  235. #ifdef __cplusplus
  236. }
  237. #endif
  238. #endif /* __STARPU_TOP_H__ */