starpu_perfmodel.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2014 Université de Bordeaux 1
  4. * Copyright (C) 2010, 2011, 2012, 2013 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_arch
  32. {
  33. enum starpu_worker_archtype type;
  34. int devid; /* identifier of the precise device */
  35. int ncore; /* number of execution in parallel, minus 1 */
  36. };
  37. struct starpu_perfmodel_history_entry
  38. {
  39. double mean;
  40. double deviation;
  41. double sum;
  42. double sum2;
  43. unsigned nsample;
  44. unsigned nerror;
  45. uint32_t footprint;
  46. #ifdef STARPU_HAVE_WINDOWS
  47. unsigned size;
  48. #else
  49. size_t size;
  50. #endif
  51. double flops;
  52. };
  53. struct starpu_perfmodel_history_list
  54. {
  55. struct starpu_perfmodel_history_list *next;
  56. struct starpu_perfmodel_history_entry *entry;
  57. };
  58. struct starpu_perfmodel_regression_model
  59. {
  60. double sumlny;
  61. double sumlnx;
  62. double sumlnx2;
  63. unsigned long minx;
  64. unsigned long maxx;
  65. double sumlnxlny;
  66. double alpha;
  67. double beta;
  68. unsigned valid;
  69. double a, b, c;
  70. unsigned nl_valid;
  71. unsigned nsample;
  72. };
  73. struct starpu_perfmodel_history_table;
  74. #define starpu_per_arch_perfmodel starpu_perfmodel_per_arch STARPU_DEPRECATED
  75. struct starpu_perfmodel_per_arch
  76. {
  77. double (*cost_model)(struct starpu_data_descr *t) STARPU_DEPRECATED;
  78. double (*cost_function)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  79. size_t (*size_base)(struct starpu_task *, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  80. struct starpu_perfmodel_history_table *history;
  81. struct starpu_perfmodel_history_list *list;
  82. struct starpu_perfmodel_regression_model regression;
  83. #ifdef STARPU_MODEL_DEBUG
  84. char debug_path[256];
  85. #endif
  86. };
  87. enum starpu_perfmodel_type
  88. {
  89. STARPU_PER_ARCH,
  90. STARPU_COMMON,
  91. STARPU_HISTORY_BASED,
  92. STARPU_REGRESSION_BASED,
  93. STARPU_NL_REGRESSION_BASED
  94. };
  95. struct starpu_perfmodel
  96. {
  97. enum starpu_perfmodel_type type;
  98. double (*cost_model)(struct starpu_data_descr *) STARPU_DEPRECATED;
  99. double (*cost_function)(struct starpu_task *, unsigned nimpl);
  100. size_t (*size_base)(struct starpu_task *, unsigned nimpl);
  101. uint32_t (*footprint)(struct starpu_task *);
  102. struct starpu_perfmodel_per_arch**** per_arch; /*STARPU_MAXIMPLEMENTATIONS*/
  103. const char *symbol;
  104. unsigned is_init;
  105. unsigned is_loaded;
  106. unsigned benchmarking;
  107. starpu_pthread_rwlock_t model_rwlock;
  108. };
  109. void starpu_perfmodel_init(struct starpu_perfmodel *model);
  110. void starpu_perfmodel_init_with_file(FILE*f, struct starpu_perfmodel *model);
  111. struct starpu_perfmodel_arch *starpu_worker_get_perf_archtype(int workerid);
  112. int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model);
  113. int starpu_perfmodel_unload_model(struct starpu_perfmodel *model);
  114. void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, char *path, size_t maxlen, unsigned nimpl);
  115. char* starpu_perfmodel_get_archtype_name(enum starpu_worker_archtype archtype);
  116. void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl);
  117. double starpu_permodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, uint32_t footprint);
  118. int starpu_perfmodel_list(FILE *output);
  119. void starpu_perfmodel_print(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output);
  120. int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output);
  121. void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double measured);
  122. void starpu_perfmodel_directory(FILE *output);
  123. void starpu_bus_print_bandwidth(FILE *f);
  124. void starpu_bus_print_affinity(FILE *f);
  125. double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node);
  126. double starpu_transfer_latency(unsigned src_node, unsigned dst_node);
  127. double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size);
  128. #ifdef __cplusplus
  129. }
  130. #endif
  131. #endif /* __STARPU_PERFMODEL_H__ */