dw_cholesky_models.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. #include "dw_cholesky_models.h"
  17. /*
  18. * As a convention, in that file, descr[0] is represented by A,
  19. * descr[1] is B ...
  20. */
  21. /*
  22. * Number of flops of Gemm
  23. */
  24. //#define USE_PERTURBATION 1
  25. #ifdef USE_PERTURBATION
  26. #define PERTURBATE(a) ((starpu_drand48()*2.0f*(AMPL) + 1.0f - (AMPL))*(a))
  27. #else
  28. #define PERTURBATE(a) (a)
  29. #endif
  30. static double cpu_chol_task_11_cost(starpu_buffer_descr *descr)
  31. {
  32. uint32_t n;
  33. n = starpu_get_blas_nx(descr[0].handle);
  34. double cost = (((double)(n)*n*n)/1000.0f*0.894/0.79176);
  35. #ifdef MODEL_DEBUG
  36. printf("cpu_chol_task_11_cost n %d cost %e\n", n, cost);
  37. #endif
  38. return PERTURBATE(cost);
  39. }
  40. static double cuda_chol_task_11_cost(starpu_buffer_descr *descr)
  41. {
  42. uint32_t n;
  43. n = starpu_get_blas_nx(descr[0].handle);
  44. double cost = (((double)(n)*n*n)/50.0f/10.75/5.088633/0.9883);
  45. #ifdef MODEL_DEBUG
  46. printf("cuda_chol_task_11_cost n %d cost %e\n", n, cost);
  47. #endif
  48. return PERTURBATE(cost);
  49. }
  50. static double cpu_chol_task_21_cost(starpu_buffer_descr *descr)
  51. {
  52. uint32_t n;
  53. n = starpu_get_blas_nx(descr[0].handle);
  54. double cost = (((double)(n)*n*n)/7706.674/0.95/0.9965);
  55. #ifdef MODEL_DEBUG
  56. printf("cpu_chol_task_21_cost n %d cost %e\n", n, cost);
  57. #endif
  58. return PERTURBATE(cost);
  59. }
  60. static double cuda_chol_task_21_cost(starpu_buffer_descr *descr)
  61. {
  62. uint32_t n;
  63. n = starpu_get_blas_nx(descr[0].handle);
  64. double cost = (((double)(n)*n*n)/50.0f/10.75/87.29520);
  65. #ifdef MODEL_DEBUG
  66. printf("cuda_chol_task_21_cost n %d cost %e\n", n, cost);
  67. #endif
  68. return PERTURBATE(cost);
  69. }
  70. static double cpu_chol_task_22_cost(starpu_buffer_descr *descr)
  71. {
  72. uint32_t n;
  73. n = starpu_get_blas_nx(descr[0].handle);
  74. double cost = (((double)(n)*n*n)/50.0f/10.75/8.0760);
  75. #ifdef MODEL_DEBUG
  76. printf("cpu_chol_task_22_cost n %d cost %e\n", n, cost);
  77. #endif
  78. return PERTURBATE(cost);
  79. }
  80. static double cuda_chol_task_22_cost(starpu_buffer_descr *descr)
  81. {
  82. uint32_t n;
  83. n = starpu_get_blas_nx(descr[0].handle);
  84. double cost = (((double)(n)*n*n)/50.0f/10.75/76.30666);
  85. #ifdef MODEL_DEBUG
  86. printf("cuda_chol_task_22_cost n %d cost %e\n", n, cost);
  87. #endif
  88. return PERTURBATE(cost);
  89. }
  90. struct starpu_perfmodel_t chol_model_11 = {
  91. .per_arch = {
  92. [STARPU_CPU_DEFAULT] = { .cost_model = cpu_chol_task_11_cost },
  93. [STARPU_CUDA_DEFAULT] = { .cost_model = cuda_chol_task_11_cost }
  94. },
  95. .type = STARPU_HISTORY_BASED,
  96. .symbol = "chol_model_11"
  97. };
  98. struct starpu_perfmodel_t chol_model_21 = {
  99. .per_arch = {
  100. [STARPU_CPU_DEFAULT] = { .cost_model = cpu_chol_task_21_cost },
  101. [STARPU_CUDA_DEFAULT] = { .cost_model = cuda_chol_task_21_cost }
  102. },
  103. .type = STARPU_HISTORY_BASED,
  104. .symbol = "chol_model_21"
  105. };
  106. struct starpu_perfmodel_t chol_model_22 = {
  107. .per_arch = {
  108. [STARPU_CPU_DEFAULT] = { .cost_model = cpu_chol_task_22_cost },
  109. [STARPU_CUDA_DEFAULT] = { .cost_model = cuda_chol_task_22_cost }
  110. },
  111. .type = STARPU_HISTORY_BASED,
  112. .symbol = "chol_model_22"
  113. };