starpu_perfmodel.h 6.5 KB

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