starpu_perfmodel.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2014,2016 Inria
  4. * Copyright (C) 2009-2018 Université de Bordeaux
  5. * Copyright (C) 2010-2017, 2019 CNRS
  6. * Copyright (C) 2013 Thibaut Lambert
  7. * Copyright (C) 2011 Télécom-SudParis
  8. *
  9. * StarPU is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU Lesser General Public License as published by
  11. * the Free Software Foundation; either version 2.1 of the License, or (at
  12. * your option) any later version.
  13. *
  14. * StarPU is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. *
  18. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  19. */
  20. #ifndef __STARPU_PERFMODEL_H__
  21. #define __STARPU_PERFMODEL_H__
  22. /** @defgroup
  23. *
  24. * @{
  25. */
  26. #include <starpu.h>
  27. #include <stdio.h>
  28. #ifdef __cplusplus
  29. extern "C"
  30. {
  31. #endif
  32. struct starpu_task;
  33. struct starpu_data_descr;
  34. #define STARPU_NARCH STARPU_ANY_WORKER
  35. struct starpu_perfmodel_device
  36. {
  37. enum starpu_worker_archtype type;
  38. int devid;
  39. int ncores;
  40. };
  41. struct starpu_perfmodel_arch
  42. {
  43. int ndevices;
  44. struct starpu_perfmodel_device *devices;
  45. };
  46. struct starpu_perfmodel_history_entry
  47. {
  48. double mean;
  49. double deviation;
  50. double sum;
  51. double sum2;
  52. unsigned nsample;
  53. unsigned nerror;
  54. uint32_t footprint;
  55. size_t size;
  56. double flops;
  57. double duration;
  58. starpu_tag_t tag;
  59. double *parameters;
  60. };
  61. struct starpu_perfmodel_history_list
  62. {
  63. struct starpu_perfmodel_history_list *next;
  64. struct starpu_perfmodel_history_entry *entry;
  65. };
  66. struct starpu_perfmodel_regression_model
  67. {
  68. double sumlny;
  69. double sumlnx;
  70. double sumlnx2;
  71. unsigned long minx;
  72. unsigned long maxx;
  73. double sumlnxlny;
  74. double alpha;
  75. double beta;
  76. unsigned valid;
  77. double a, b, c;
  78. unsigned nl_valid;
  79. unsigned nsample;
  80. double *coeff;
  81. unsigned ncoeff;
  82. unsigned multi_valid;
  83. };
  84. struct starpu_perfmodel_history_table;
  85. #define starpu_per_arch_perfmodel starpu_perfmodel_per_arch STARPU_DEPRECATED
  86. typedef double (*starpu_perfmodel_per_arch_cost_function)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  87. typedef size_t (*starpu_perfmodel_per_arch_size_base)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  88. struct starpu_perfmodel_per_arch
  89. {
  90. starpu_perfmodel_per_arch_cost_function cost_function;
  91. starpu_perfmodel_per_arch_size_base size_base;
  92. struct starpu_perfmodel_history_table *history;
  93. struct starpu_perfmodel_history_list *list;
  94. struct starpu_perfmodel_regression_model regression;
  95. char debug_path[256];
  96. };
  97. enum starpu_perfmodel_type
  98. {
  99. STARPU_PERFMODEL_INVALID=0,
  100. STARPU_PER_ARCH,
  101. STARPU_COMMON,
  102. STARPU_HISTORY_BASED,
  103. STARPU_REGRESSION_BASED,
  104. STARPU_NL_REGRESSION_BASED,
  105. STARPU_MULTIPLE_REGRESSION_BASED
  106. };
  107. struct _starpu_perfmodel_state;
  108. typedef struct _starpu_perfmodel_state* starpu_perfmodel_state_t;
  109. struct starpu_perfmodel
  110. {
  111. enum starpu_perfmodel_type type;
  112. double (*cost_function)(struct starpu_task *, unsigned nimpl);
  113. double (*arch_cost_function)(struct starpu_task *, struct starpu_perfmodel_arch * arch, unsigned nimpl);
  114. size_t (*size_base)(struct starpu_task *, unsigned nimpl);
  115. uint32_t (*footprint)(struct starpu_task *);
  116. const char *symbol;
  117. unsigned is_loaded;
  118. unsigned benchmarking;
  119. unsigned is_init;
  120. void (*parameters)(struct starpu_task * task, double *parameters);
  121. const char **parameters_names;
  122. unsigned nparameters;
  123. unsigned **combinations;
  124. unsigned ncombinations;
  125. starpu_perfmodel_state_t state;
  126. };
  127. void starpu_perfmodel_init(struct starpu_perfmodel *model);
  128. int starpu_perfmodel_load_file(const char *filename, struct starpu_perfmodel *model);
  129. int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model);
  130. int starpu_perfmodel_unload_model(struct starpu_perfmodel *model);
  131. void starpu_perfmodel_get_model_path(const char *symbol, char *path, size_t maxlen);
  132. void starpu_perfmodel_free_sampling_directories(void);
  133. struct starpu_perfmodel_arch *starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id);
  134. int starpu_perfmodel_get_narch_combs();
  135. int starpu_perfmodel_arch_comb_add(int ndevices, struct starpu_perfmodel_device* devices);
  136. int starpu_perfmodel_arch_comb_get(int ndevices, struct starpu_perfmodel_device *devices);
  137. struct starpu_perfmodel_arch *starpu_perfmodel_arch_comb_fetch(int comb);
  138. struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_arch(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned impl);
  139. struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_devices(struct starpu_perfmodel *model, int impl, ...);
  140. int starpu_perfmodel_set_per_devices_cost_function(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_cost_function func, ...);
  141. int starpu_perfmodel_set_per_devices_size_base(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_size_base func, ...);
  142. void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, char *path, size_t maxlen, unsigned nimpl);
  143. char* starpu_perfmodel_get_archtype_name(enum starpu_worker_archtype archtype);
  144. void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl);
  145. double starpu_perfmodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, uint32_t footprint);
  146. void starpu_perfmodel_initialize(void);
  147. int starpu_perfmodel_list(FILE *output);
  148. void starpu_perfmodel_print(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output);
  149. int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output);
  150. int starpu_perfmodel_print_estimations(struct starpu_perfmodel *model, uint32_t footprint, FILE *output);
  151. int starpu_perfmodel_list_combs(FILE *output, struct starpu_perfmodel *model);
  152. void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double measured);
  153. void starpu_perfmodel_directory(FILE *output);
  154. void starpu_bus_print_bandwidth(FILE *f);
  155. void starpu_bus_print_affinity(FILE *f);
  156. void starpu_bus_print_filenames(FILE *f);
  157. double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node);
  158. double starpu_transfer_latency(unsigned src_node, unsigned dst_node);
  159. double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size);
  160. extern struct starpu_perfmodel starpu_perfmodel_nop;
  161. /**
  162. Display statistics about the current data handles registered
  163. within StarPU. StarPU must have been configured with the configure
  164. option \ref enable-memory-stats "--enable-memory-stats" (see \ref
  165. MemoryFeedback).
  166. */
  167. void starpu_data_display_memory_stats();
  168. #ifdef __cplusplus
  169. }
  170. #endif
  171. /** @} */
  172. #endif /* __STARPU_PERFMODEL_H__ */