starpu_perfmodel.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 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; /* 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. size_t size;
  52. double flops;
  53. };
  54. struct starpu_perfmodel_history_list
  55. {
  56. struct starpu_perfmodel_history_list *next;
  57. struct starpu_perfmodel_history_entry *entry;
  58. };
  59. struct starpu_perfmodel_regression_model
  60. {
  61. double sumlny;
  62. double sumlnx;
  63. double sumlnx2;
  64. unsigned long minx;
  65. unsigned long maxx;
  66. double sumlnxlny;
  67. double alpha;
  68. double beta;
  69. unsigned valid;
  70. double a, b, c;
  71. unsigned nl_valid;
  72. unsigned nsample;
  73. };
  74. struct starpu_perfmodel_history_table;
  75. #define starpu_per_arch_perfmodel starpu_perfmodel_per_arch STARPU_DEPRECATED
  76. typedef double (*starpu_perfmodel_per_arch_cost_function)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  77. typedef size_t (*starpu_perfmodel_per_arch_size_base)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  78. struct starpu_perfmodel_per_arch
  79. {
  80. starpu_perfmodel_per_arch_cost_function cost_function;
  81. starpu_perfmodel_per_arch_size_base size_base;
  82. struct starpu_perfmodel_history_table *history;
  83. struct starpu_perfmodel_history_list *list;
  84. struct starpu_perfmodel_regression_model regression;
  85. char debug_path[256];
  86. };
  87. enum starpu_perfmodel_type
  88. {
  89. STARPU_PERFMODEL_INVALID=0,
  90. STARPU_PER_ARCH,
  91. STARPU_COMMON,
  92. STARPU_HISTORY_BASED,
  93. STARPU_REGRESSION_BASED,
  94. STARPU_NL_REGRESSION_BASED
  95. };
  96. struct _starpu_perfmodel_state;
  97. typedef struct _starpu_perfmodel_state* starpu_perfmodel_state_t;
  98. struct starpu_perfmodel
  99. {
  100. enum starpu_perfmodel_type type;
  101. double (*cost_function)(struct starpu_task *, unsigned nimpl);
  102. double (*arch_cost_function)(struct starpu_task *, struct starpu_perfmodel_arch * arch, unsigned nimpl);
  103. size_t (*size_base)(struct starpu_task *, unsigned nimpl);
  104. uint32_t (*footprint)(struct starpu_task *);
  105. const char *symbol;
  106. unsigned is_loaded;
  107. unsigned benchmarking;
  108. unsigned is_init;
  109. starpu_perfmodel_state_t state;
  110. };
  111. void starpu_perfmodel_init(struct starpu_perfmodel *model);
  112. int starpu_perfmodel_load_file(const char *filename, struct starpu_perfmodel *model);
  113. int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model);
  114. int starpu_perfmodel_unload_model(struct starpu_perfmodel *model);
  115. void starpu_perfmodel_get_model_path(const char *symbol, char *path, size_t maxlen);
  116. void starpu_perfmodel_free_sampling_directories(void);
  117. struct starpu_perfmodel_arch *starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id);
  118. int starpu_perfmodel_get_narch_combs();
  119. int starpu_perfmodel_arch_comb_add(int ndevices, struct starpu_perfmodel_device* devices);
  120. int starpu_perfmodel_arch_comb_get(int ndevices, struct starpu_perfmodel_device *devices);
  121. struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_arch(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned impl);
  122. struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_devices(struct starpu_perfmodel *model, int impl, ...);
  123. int starpu_perfmodel_set_per_devices_cost_function(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_cost_function func, ...);
  124. int starpu_perfmodel_set_per_devices_size_base(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_size_base func, ...);
  125. void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, char *path, size_t maxlen, unsigned nimpl);
  126. char* starpu_perfmodel_get_archtype_name(enum starpu_worker_archtype archtype);
  127. void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl);
  128. double starpu_perfmodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, uint32_t footprint);
  129. int starpu_perfmodel_list(FILE *output);
  130. void starpu_perfmodel_print(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output);
  131. int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output);
  132. int starpu_perfmodel_list_combs(FILE *output, struct starpu_perfmodel *model);
  133. void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double measured);
  134. void starpu_perfmodel_directory(FILE *output);
  135. void starpu_bus_print_bandwidth(FILE *f);
  136. void starpu_bus_print_affinity(FILE *f);
  137. double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node);
  138. double starpu_transfer_latency(unsigned src_node, unsigned dst_node);
  139. double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size);
  140. #ifdef __cplusplus
  141. }
  142. #endif
  143. #endif /* __STARPU_PERFMODEL_H__ */