starpu_perfmodel.h 6.4 KB

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