perfmodel.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010, 2011 Université de Bordeaux 1
  4. * Copyright (C) 2010 Centre National de la Recherche Scientifique
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. #ifndef __PERFMODEL_H__
  18. #define __PERFMODEL_H__
  19. #include <common/config.h>
  20. #include <starpu.h>
  21. #include <starpu_perfmodel.h>
  22. //#include <core/jobs.h>
  23. #include <common/htable32.h>
  24. //#include <core/workers.h>
  25. #include <pthread.h>
  26. #include <stdio.h>
  27. struct starpu_buffer_descr_t;
  28. struct starpu_jobq_s;
  29. struct starpu_job_s;
  30. enum starpu_perf_archtype;
  31. struct starpu_history_entry_t {
  32. //double measured;
  33. /* mean_n = 1/n sum */
  34. double mean;
  35. /* n dev_n = sum2 - 1/n (sum)^2 */
  36. double deviation;
  37. /* sum of samples */
  38. double sum;
  39. /* sum of samples^2 */
  40. double sum2;
  41. // /* sum of ln(measured) */
  42. // double sumlny;
  43. //
  44. // /* sum of ln(size) */
  45. // double sumlnx;
  46. // double sumlnx2;
  47. //
  48. // /* sum of ln(size) ln(measured) */
  49. // double sumlnxlny;
  50. //
  51. unsigned nsample;
  52. uint32_t footprint;
  53. #ifdef STARPU_HAVE_WINDOWS
  54. unsigned size; /* in bytes */
  55. #else
  56. size_t size; /* in bytes */
  57. #endif
  58. };
  59. struct starpu_history_list_t {
  60. struct starpu_history_list_t *next;
  61. struct starpu_history_entry_t *entry;
  62. };
  63. struct starpu_model_list_t {
  64. struct starpu_model_list_t *next;
  65. struct starpu_perfmodel_t *model;
  66. };
  67. //
  68. ///* File format */
  69. //struct model_file_format {
  70. // unsigned ncore_entries;
  71. // unsigned ncuda_entries;
  72. // /* contains core entries, then cuda ones */
  73. // struct starpu_history_entry_t entries[];
  74. //}
  75. void _starpu_get_perf_model_dir(char *path, size_t maxlen);
  76. void _starpu_get_perf_model_dir_codelets(char *path, size_t maxlen);
  77. void _starpu_get_perf_model_dir_bus(char *path, size_t maxlen);
  78. void _starpu_get_perf_model_dir_debug(char *path, size_t maxlen);
  79. double _starpu_history_based_job_expected_perf(struct starpu_perfmodel_t *model, enum starpu_perf_archtype arch, struct starpu_job_s *j);
  80. void _starpu_register_model(struct starpu_perfmodel_t *model);
  81. void _starpu_load_history_based_model(struct starpu_perfmodel_t *model, unsigned scan_history);
  82. void _starpu_load_perfmodel(struct starpu_perfmodel_t *model);
  83. void _starpu_initialize_registered_performance_models(void);
  84. void _starpu_deinitialize_registered_performance_models(void);
  85. double _starpu_regression_based_job_expected_perf(struct starpu_perfmodel_t *model,
  86. enum starpu_perf_archtype arch, struct starpu_job_s *j);
  87. double _starpu_non_linear_regression_based_job_expected_perf(struct starpu_perfmodel_t *model,
  88. enum starpu_perf_archtype arch, struct starpu_job_s *j);
  89. void _starpu_update_perfmodel_history(struct starpu_job_s *j, struct starpu_perfmodel_t *model, enum starpu_perf_archtype arch,
  90. unsigned cpuid, double measured);
  91. void _starpu_create_sampling_directory_if_needed(void);
  92. void _starpu_load_bus_performance_files(void);
  93. double _starpu_predict_transfer_time(unsigned src_node, unsigned dst_node, size_t size);
  94. void _starpu_set_calibrate_flag(unsigned val);
  95. unsigned _starpu_get_calibrate_flag(void);
  96. enum starpu_perf_archtype starpu_worker_get_perf_archtype(int workerid);
  97. #if defined(STARPU_USE_CUDA)
  98. int *_starpu_get_cuda_affinity_vector(unsigned gpuid);
  99. #endif
  100. #if defined(STARPU_USE_OPENCL)
  101. int *_starpu_get_opencl_affinity_vector(unsigned gpuid);
  102. #endif
  103. #endif // __PERFMODEL_H__