starpu_top.h 7.7 KB

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