lu_kernels_model.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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 "lu_kernels_model.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. /*
  31. *
  32. * Generic models
  33. *
  34. */
  35. double task_11_cost(starpu_buffer_descr *descr)
  36. {
  37. uint32_t n;
  38. n = starpu_matrix_get_nx(descr[0].handle);
  39. double cost = ((n*n*n)/537.5);
  40. return PERTURBATE(cost);
  41. }
  42. double task_12_cost(starpu_buffer_descr *descr)
  43. {
  44. uint32_t n;
  45. n = starpu_matrix_get_nx(descr[0].handle);
  46. // double cost = ((n*n*n)/1744.695);
  47. double cost = ((n*n*n)/3210.80);
  48. //fprintf(stderr, "task 12 predicts %e\n", cost);
  49. return PERTURBATE(cost);
  50. }
  51. double task_21_cost(starpu_buffer_descr *descr)
  52. {
  53. uint32_t n;
  54. n = starpu_matrix_get_nx(descr[0].handle);
  55. // double cost = ((n*n*n)/1744.695);
  56. double cost = ((n*n*n)/3691.53);
  57. //fprintf(stderr, "task 12 predicts %e\n", cost);
  58. return PERTURBATE(cost);
  59. }
  60. double task_22_cost(starpu_buffer_descr *descr)
  61. {
  62. uint32_t nx, ny, nz;
  63. nx = starpu_matrix_get_nx(descr[2].handle);
  64. ny = starpu_matrix_get_ny(descr[2].handle);
  65. nz = starpu_matrix_get_ny(descr[0].handle);
  66. double cost = ((nx*ny*nz)/4110.0);
  67. return PERTURBATE(cost);
  68. }
  69. /*
  70. *
  71. * Models for CUDA
  72. *
  73. */
  74. double task_11_cost_cuda(starpu_buffer_descr *descr)
  75. {
  76. uint32_t n;
  77. n = starpu_matrix_get_nx(descr[0].handle);
  78. double cost = ((n*n*n)/1853.7806);
  79. // printf("CUDA task 11 ; predict %e\n", cost);
  80. return PERTURBATE(cost);
  81. }
  82. double task_12_cost_cuda(starpu_buffer_descr *descr)
  83. {
  84. uint32_t n;
  85. n = starpu_matrix_get_nx(descr[0].handle);
  86. double cost = ((n*n*n)/42838.5718);
  87. // printf("CUDA task 12 ; predict %e\n", cost);
  88. return PERTURBATE(cost);
  89. }
  90. double task_21_cost_cuda(starpu_buffer_descr *descr)
  91. {
  92. uint32_t n;
  93. n = starpu_matrix_get_nx(descr[0].handle);
  94. double cost = ((n*n*n)/49208.667);
  95. // printf("CUDA task 21 ; predict %e\n", cost);
  96. return PERTURBATE(cost);
  97. }
  98. double task_22_cost_cuda(starpu_buffer_descr *descr)
  99. {
  100. uint32_t nx, ny, nz;
  101. nx = starpu_matrix_get_nx(descr[2].handle);
  102. ny = starpu_matrix_get_ny(descr[2].handle);
  103. nz = starpu_matrix_get_ny(descr[0].handle);
  104. double cost = ((nx*ny*nz)/57523.560);
  105. // printf("CUDA task 22 ; predict %e\n", cost);
  106. return PERTURBATE(cost);
  107. }
  108. /*
  109. *
  110. * Models for CPUs
  111. *
  112. */
  113. double task_11_cost_cpu(starpu_buffer_descr *descr)
  114. {
  115. uint32_t n;
  116. n = starpu_matrix_get_nx(descr[0].handle);
  117. double cost = ((n*n*n)/537.5);
  118. // printf("CPU task 11 ; predict %e\n", cost);
  119. return PERTURBATE(cost);
  120. }
  121. double task_12_cost_cpu(starpu_buffer_descr *descr)
  122. {
  123. uint32_t n;
  124. n = starpu_matrix_get_nx(descr[0].handle);
  125. double cost = ((n*n*n)/6668.224);
  126. // printf("CPU task 12 ; predict %e\n", cost);
  127. return PERTURBATE(cost);
  128. }
  129. double task_21_cost_cpu(starpu_buffer_descr *descr)
  130. {
  131. uint32_t n;
  132. n = starpu_matrix_get_nx(descr[0].handle);
  133. double cost = ((n*n*n)/6793.8423);
  134. // printf("CPU task 21 ; predict %e\n", cost);
  135. return PERTURBATE(cost);
  136. }
  137. double task_22_cost_cpu(starpu_buffer_descr *descr)
  138. {
  139. uint32_t nx, ny, nz;
  140. nx = starpu_matrix_get_nx(descr[2].handle);
  141. ny = starpu_matrix_get_ny(descr[2].handle);
  142. nz = starpu_matrix_get_ny(descr[0].handle);
  143. double cost = ((nx*ny*nz)/4203.0175);
  144. // printf("CPU task 22 ; predict %e\n", cost);
  145. return PERTURBATE(cost);
  146. }
  147. struct starpu_perfmodel_t model_11 = {
  148. .cost_model = task_11_cost,
  149. .per_arch = {
  150. [STARPU_CPU_DEFAULT] = { .cost_model = task_11_cost_cpu },
  151. [STARPU_CUDA_DEFAULT] = { .cost_model = task_11_cost_cuda }
  152. },
  153. .type = STARPU_HISTORY_BASED,
  154. #ifdef STARPU_ATLAS
  155. .symbol = "lu_model_11_atlas"
  156. #elif defined(STARPU_GOTO)
  157. .symbol = "lu_model_11_goto"
  158. #else
  159. .symbol = "lu_model_11"
  160. #endif
  161. };
  162. struct starpu_perfmodel_t model_12 = {
  163. .cost_model = task_12_cost,
  164. .per_arch = {
  165. [STARPU_CPU_DEFAULT] = { .cost_model = task_12_cost_cpu },
  166. [STARPU_CUDA_DEFAULT] = { .cost_model = task_12_cost_cuda }
  167. },
  168. .type = STARPU_HISTORY_BASED,
  169. #ifdef STARPU_ATLAS
  170. .symbol = "lu_model_12_atlas"
  171. #elif defined(STARPU_GOTO)
  172. .symbol = "lu_model_12_goto"
  173. #else
  174. .symbol = "lu_model_12"
  175. #endif
  176. };
  177. struct starpu_perfmodel_t model_21 = {
  178. .cost_model = task_21_cost,
  179. .per_arch = {
  180. [STARPU_CPU_DEFAULT] = { .cost_model = task_21_cost_cpu },
  181. [STARPU_CUDA_DEFAULT] = { .cost_model = task_21_cost_cuda }
  182. },
  183. .type = STARPU_HISTORY_BASED,
  184. #ifdef STARPU_ATLAS
  185. .symbol = "lu_model_21_atlas"
  186. #elif defined(STARPU_GOTO)
  187. .symbol = "lu_model_21_goto"
  188. #else
  189. .symbol = "lu_model_21"
  190. #endif
  191. };
  192. struct starpu_perfmodel_t model_22 = {
  193. .cost_model = task_22_cost,
  194. .per_arch = {
  195. [STARPU_CPU_DEFAULT] = { .cost_model = task_22_cost_cpu },
  196. [STARPU_CUDA_DEFAULT] = { .cost_model = task_22_cost_cuda }
  197. },
  198. .type = STARPU_HISTORY_BASED,
  199. #ifdef STARPU_ATLAS
  200. .symbol = "lu_model_22_atlas"
  201. #elif defined(STARPU_GOTO)
  202. .symbol = "lu_model_22_goto"
  203. #else
  204. .symbol = "lu_model_22"
  205. #endif
  206. };