starpu-perfmodel.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. #ifndef __STARPU_PERFMODEL_H__
  17. #define __STARPU_PERFMODEL_H__
  18. #include <stdio.h>
  19. #include <pthread.h>
  20. #include <starpu_config.h>
  21. struct starpu_htbl32_node_s;
  22. struct starpu_history_list_t;
  23. struct starpu_buffer_descr_t;
  24. /*
  25. it is possible that we have multiple versions of the same kind of workers,
  26. for instance multiple GPUs or even different CPUs within the same machine
  27. so we do not use the archtype enum type directly for performance models
  28. */
  29. /* on most system we will consider one or two architectures as all accelerators
  30. are likely to be identical */
  31. #define NARCH_VARIATIONS 3
  32. enum starpu_perf_archtype {
  33. STARPU_CORE_DEFAULT = 0,
  34. STARPU_CUDA_DEFAULT = 1,
  35. STARPU_GORDON_DEFAULT = 2
  36. };
  37. struct starpu_regression_model_t {
  38. /* sum of ln(measured) */
  39. double sumlny;
  40. /* sum of ln(size) */
  41. double sumlnx;
  42. double sumlnx2;
  43. /* sum of ln(size) ln(measured) */
  44. double sumlnxlny;
  45. /* y = alpha size ^ beta */
  46. double alpha;
  47. double beta;
  48. /* y = a size ^b + c */
  49. double a, b, c;
  50. unsigned valid;
  51. unsigned nsample;
  52. };
  53. struct starpu_per_arch_perfmodel_t {
  54. double (*cost_model)(struct starpu_buffer_descr_t *t);
  55. double alpha;
  56. struct starpu_htbl32_node_s *history;
  57. struct starpu_history_list_t *list;
  58. struct starpu_regression_model_t regression;
  59. #ifdef MODEL_DEBUG
  60. FILE *debug_file;
  61. #endif
  62. };
  63. struct starpu_perfmodel_t {
  64. /* which model is used for that task ? */
  65. enum {PER_ARCH, COMMON, HISTORY_BASED, REGRESSION_BASED} type;
  66. /* single cost model */
  67. double (*cost_model)(struct starpu_buffer_descr_t *);
  68. /* per-architecture model */
  69. struct starpu_per_arch_perfmodel_t per_arch[NARCH_VARIATIONS];
  70. const char *symbol;
  71. unsigned is_loaded;
  72. unsigned benchmarking;
  73. pthread_spinlock_t model_mutex;
  74. };
  75. #endif // __STARPU_PERFMODEL_H__