mpi_cholesky_models.c 3.6 KB

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