cholesky_models.c 3.7 KB

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