starpu_perfmodel.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2014, 2016-2017 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. #include <starpu_task.h>
  26. #ifdef __cplusplus
  27. extern "C"
  28. {
  29. #endif
  30. struct starpu_task;
  31. struct starpu_data_descr;
  32. #define STARPU_NARCH STARPU_ANY_WORKER
  33. struct starpu_perfmodel_device
  34. {
  35. enum starpu_worker_archtype type;
  36. int devid;
  37. int ncores;
  38. };
  39. struct starpu_perfmodel_arch
  40. {
  41. int ndevices;
  42. struct starpu_perfmodel_device *devices;
  43. };
  44. struct starpu_perfmodel_history_entry
  45. {
  46. double mean;
  47. double deviation;
  48. double sum;
  49. double sum2;
  50. unsigned nsample;
  51. unsigned nerror;
  52. uint32_t footprint;
  53. size_t size;
  54. double flops;
  55. double duration;
  56. starpu_tag_t tag;
  57. double *parameters;
  58. };
  59. struct starpu_perfmodel_history_list
  60. {
  61. struct starpu_perfmodel_history_list *next;
  62. struct starpu_perfmodel_history_entry *entry;
  63. };
  64. struct starpu_perfmodel_regression_model
  65. {
  66. double sumlny;
  67. double sumlnx;
  68. double sumlnx2;
  69. unsigned long minx;
  70. unsigned long maxx;
  71. double sumlnxlny;
  72. double alpha;
  73. double beta;
  74. unsigned valid;
  75. double a, b, c;
  76. unsigned nl_valid;
  77. unsigned nsample;
  78. double *coeff;
  79. unsigned ncoeff;
  80. unsigned multi_valid;
  81. };
  82. struct starpu_perfmodel_history_table;
  83. #define starpu_per_arch_perfmodel starpu_perfmodel_per_arch STARPU_DEPRECATED
  84. typedef double (*starpu_perfmodel_per_arch_cost_function)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  85. typedef size_t (*starpu_perfmodel_per_arch_size_base)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  86. struct starpu_perfmodel_per_arch
  87. {
  88. starpu_perfmodel_per_arch_cost_function cost_function;
  89. starpu_perfmodel_per_arch_size_base size_base;
  90. struct starpu_perfmodel_history_table *history;
  91. struct starpu_perfmodel_history_list *list;
  92. struct starpu_perfmodel_regression_model regression;
  93. char debug_path[256];
  94. };
  95. enum starpu_perfmodel_type
  96. {
  97. STARPU_PERFMODEL_INVALID=0,
  98. STARPU_PER_ARCH,
  99. STARPU_COMMON,
  100. STARPU_HISTORY_BASED,
  101. STARPU_REGRESSION_BASED,
  102. STARPU_NL_REGRESSION_BASED,
  103. STARPU_MULTIPLE_REGRESSION_BASED
  104. };
  105. struct _starpu_perfmodel_state;
  106. typedef struct _starpu_perfmodel_state* starpu_perfmodel_state_t;
  107. struct starpu_perfmodel
  108. {
  109. enum starpu_perfmodel_type type;
  110. double (*cost_function)(struct starpu_task *, unsigned nimpl);
  111. double (*arch_cost_function)(struct starpu_task *, struct starpu_perfmodel_arch * arch, unsigned nimpl);
  112. size_t (*size_base)(struct starpu_task *, unsigned nimpl);
  113. uint32_t (*footprint)(struct starpu_task *);
  114. const char *symbol;
  115. unsigned is_loaded;
  116. unsigned benchmarking;
  117. unsigned is_init;
  118. void (*parameters)(struct starpu_task * task, double *parameters);
  119. const char **parameters_names;
  120. unsigned nparameters;
  121. unsigned **combinations;
  122. unsigned ncombinations;
  123. starpu_perfmodel_state_t state;
  124. };
  125. void starpu_perfmodel_init(struct starpu_perfmodel *model);
  126. int starpu_perfmodel_load_file(const char *filename, struct starpu_perfmodel *model);
  127. int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model);
  128. int starpu_perfmodel_unload_model(struct starpu_perfmodel *model);
  129. void starpu_perfmodel_get_model_path(const char *symbol, char *path, size_t maxlen);
  130. void starpu_perfmodel_free_sampling_directories(void);
  131. struct starpu_perfmodel_arch *starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id);
  132. int starpu_perfmodel_get_narch_combs();
  133. int starpu_perfmodel_arch_comb_add(int ndevices, struct starpu_perfmodel_device* devices);
  134. int starpu_perfmodel_arch_comb_get(int ndevices, struct starpu_perfmodel_device *devices);
  135. struct starpu_perfmodel_arch *starpu_perfmodel_arch_comb_fetch(int comb);
  136. struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_arch(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned impl);
  137. struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_devices(struct starpu_perfmodel *model, int impl, ...);
  138. int starpu_perfmodel_set_per_devices_cost_function(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_cost_function func, ...);
  139. int starpu_perfmodel_set_per_devices_size_base(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_size_base func, ...);
  140. void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, char *path, size_t maxlen, unsigned nimpl);
  141. char* starpu_perfmodel_get_archtype_name(enum starpu_worker_archtype archtype);
  142. void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl);
  143. double starpu_perfmodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, uint32_t footprint);
  144. void starpu_perfmodel_initialize(void);
  145. int starpu_perfmodel_list(FILE *output);
  146. void starpu_perfmodel_print(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output);
  147. int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output);
  148. int starpu_perfmodel_print_estimations(struct starpu_perfmodel *model, uint32_t footprint, FILE *output);
  149. int starpu_perfmodel_list_combs(FILE *output, struct starpu_perfmodel *model);
  150. void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double measured);
  151. void starpu_perfmodel_directory(FILE *output);
  152. void starpu_bus_print_bandwidth(FILE *f);
  153. void starpu_bus_print_affinity(FILE *f);
  154. void starpu_bus_print_filenames(FILE *f);
  155. double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node);
  156. double starpu_transfer_latency(unsigned src_node, unsigned dst_node);
  157. double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size);
  158. extern struct starpu_perfmodel starpu_nop_perf_model;
  159. #ifdef __cplusplus
  160. }
  161. #endif
  162. #endif /* __STARPU_PERFMODEL_H__ */