cholesky_models.c 3.8 KB

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