starpu_top.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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 <starpu.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. **** Functions to call BEFORE initialisation *****
  78. *****************************************************/
  79. /*
  80. * This fonction register a data named data_name of type boolean
  81. * If active=0, the value will NOT be displayed to user by default.
  82. * Any other value will make the value displayed by default.
  83. */
  84. struct starpu_top_data *starpu_top_add_data_boolean(const char* data_name,
  85. int active);
  86. /*
  87. * This fonction register a data named data_name of type integer
  88. * The minimum and maximum value will be usefull to define the scale in UI
  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. struct starpu_top_data * starpu_top_add_data_integer(const char* data_name,
  93. int minimum_value,
  94. int maximum_value,
  95. int active);
  96. /*
  97. * This fonction register a data named data_name of type float
  98. * The minimum and maximum value will be usefull to define the scale in UI
  99. * If active=0, the value will NOT be displayed to user by default.
  100. * Any other value will make the value displayed by default.
  101. */
  102. struct starpu_top_data* starpu_top_add_data_float(const char* data_name,
  103. double minimum_value,
  104. double maximum_value,
  105. int active);
  106. /*
  107. * This fonction register a parameter named parameter_name, of type boolean.
  108. * The callback fonction will be called when the parameter is modified by UI,
  109. * and can be null.
  110. */
  111. struct starpu_top_param* starpu_top_register_parameter_boolean(const char* param_name,
  112. int* parameter_field,
  113. void (*callback)(struct starpu_top_param*));
  114. /*
  115. * This fonction register a parameter named param_name, of type integer.
  116. * Minimum and maximum value will be used to prevent user seting incorrect
  117. * value.
  118. * The callback fonction will be called when the parameter is modified by UI,
  119. * and can be null.
  120. */
  121. struct starpu_top_param* starpu_top_register_parameter_integer(const char* param_name,
  122. int* parameter_field,
  123. int minimum_value,
  124. int maximum_value,
  125. void (*callback)(struct starpu_top_param*));
  126. /*
  127. * This fonction register a parameter named param_name, of type float.
  128. * Minimum and maximum value will be used to prevent user seting incorrect
  129. * value.
  130. * The callback fonction will be called when the parameter is modified by UI,
  131. * and can be null.
  132. */
  133. struct starpu_top_param* starpu_top_register_parameter_float(const char* param_name,
  134. double* parameter_field,
  135. double minimum_value,
  136. double maximum_value,
  137. void (*callback)(struct starpu_top_param*));
  138. /*
  139. * This fonction register a parameter named param_name, of type enum.
  140. * Minimum and maximum value will be used to prevent user seting incorrect
  141. * value.
  142. * The callback fonction will be called when the parameter is modified by UI,
  143. * and can be null.
  144. */
  145. struct starpu_top_param* starpu_top_register_parameter_enum(const char* param_name,
  146. int* parameter_field,
  147. char** values,
  148. int nb_values,
  149. void (*callback)(struct starpu_top_param*));
  150. /****************************************************
  151. ******************* Initialisation ******************
  152. *****************************************************/
  153. /*
  154. * This function must be called when all parameters and
  155. * data have been registered AND initialised (for parameters).
  156. * This function will wait for a TOP to connect, send initialisation
  157. * sentences, and wait for the GO message.
  158. */
  159. void starpu_top_init_and_wait(const char* server_name);
  160. /****************************************************
  161. ************ To call after initialisation************
  162. *****************************************************/
  163. /*
  164. * This function should be called after every modification
  165. * of a parameter from something other than starpu_top.
  166. * This fonction notice UI that the configuration changed
  167. */
  168. void starpu_top_update_parameter(const struct starpu_top_param* param);
  169. /*
  170. * This functions update the value of the starpu_top_data on UI
  171. */
  172. void starpu_top_update_data_boolean(const struct starpu_top_data* data,
  173. int value);
  174. void starpu_top_update_data_integer(const struct starpu_top_data* data,
  175. int value);
  176. void starpu_top_update_data_float(const struct starpu_top_data* data,
  177. double value);
  178. /*
  179. * This functions are usefull in debug mode. The starpu developper doesn't need
  180. * to check if the debug mode is active.
  181. * This is checked by starpu_top itsefl.
  182. *
  183. * top_debug_log just send a message to display by UI
  184. * top_debug_lock send a message and wait for a continue message from UI
  185. * to return
  186. *
  187. * The lock (wich create a stop-point) should be called only by the main thread.
  188. * Calling it from more than one thread is not supported.
  189. */
  190. void starpu_top_debug_log(const char* message);
  191. void starpu_top_debug_lock(const char* message);
  192. #ifdef __cplusplus
  193. }
  194. #endif
  195. #endif /* __STARPU_TOP_H__ */