starpu_perfmodel.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2014 Université de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012, 2013, 2014 Centre National de la Recherche Scientifique
  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; /* identifier of the precise device */
  35. int ncores; /* number of execution in parallel, minus 1 */
  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. #ifdef STARPU_HAVE_WINDOWS
  52. unsigned size;
  53. #else
  54. size_t size;
  55. #endif
  56. double flops;
  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. };
  78. struct starpu_perfmodel_history_table;
  79. #define starpu_per_arch_perfmodel starpu_perfmodel_per_arch STARPU_DEPRECATED
  80. typedef double (*starpu_perfmodel_per_arch_cost_function)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  81. typedef size_t (*starpu_perfmodel_per_arch_size_base)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  82. struct starpu_perfmodel_per_arch
  83. {
  84. starpu_perfmodel_per_arch_cost_function cost_function;
  85. starpu_perfmodel_per_arch_size_base size_base;
  86. struct starpu_perfmodel_history_table *history;
  87. struct starpu_perfmodel_history_list *list;
  88. struct starpu_perfmodel_regression_model regression;
  89. #ifdef STARPU_MODEL_DEBUG
  90. char debug_path[256];
  91. #endif
  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. };
  102. struct _starpu_perfmodel_state;
  103. typedef struct _starpu_perfmodel_state* starpu_perfmodel_state_t;
  104. struct starpu_perfmodel
  105. {
  106. enum starpu_perfmodel_type type;
  107. double (*cost_function)(struct starpu_task *, unsigned nimpl);
  108. size_t (*size_base)(struct starpu_task *, unsigned nimpl);
  109. uint32_t (*footprint)(struct starpu_task *);
  110. const char *symbol;
  111. unsigned is_loaded;
  112. unsigned benchmarking;
  113. unsigned is_init;
  114. starpu_perfmodel_state_t state;
  115. };
  116. void starpu_perfmodel_init(FILE *f, struct starpu_perfmodel *model);
  117. //void starpu_perfmodel_init_with_file(FILE*f, struct starpu_perfmodel *model);
  118. struct starpu_perfmodel_arch *starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id);
  119. int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model);
  120. int starpu_perfmodel_unload_model(struct starpu_perfmodel *model);
  121. int starpu_get_narch_combs();
  122. int starpu_perfmodel_arch_comb_add(int ndevices, struct starpu_perfmodel_device* devices);
  123. int starpu_perfmodel_arch_comb_get(int ndevices, struct starpu_perfmodel_device *devices);
  124. struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_arch(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned impl);
  125. struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_devices(struct starpu_perfmodel *model, int impl, ...);
  126. int starpu_perfmodel_set_per_devices_cost_function(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_cost_function func, ...);
  127. int starpu_perfmodel_set_per_devices_size_base(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_size_base func, ...);
  128. void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, char *path, size_t maxlen, unsigned nimpl);
  129. char* starpu_perfmodel_get_archtype_name(enum starpu_worker_archtype archtype);
  130. void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl);
  131. double starpu_permodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, uint32_t footprint);
  132. int starpu_perfmodel_list(FILE *output);
  133. void starpu_perfmodel_print(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output);
  134. int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output);
  135. int starpu_perfmodel_list_combs(FILE *output, struct starpu_perfmodel *model);
  136. void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double measured);
  137. void starpu_perfmodel_directory(FILE *output);
  138. void starpu_bus_print_bandwidth(FILE *f);
  139. void starpu_bus_print_affinity(FILE *f);
  140. double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node);
  141. double starpu_transfer_latency(unsigned src_node, unsigned dst_node);
  142. double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size);
  143. #ifdef __cplusplus
  144. }
  145. #endif
  146. #endif /* __STARPU_PERFMODEL_H__ */