starpu_perfmodel.h 4.7 KB

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