cholesky.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2013 Inria
  4. * Copyright (C) 2010-2013,2015,2017 CNRS
  5. * Copyright (C) 2009-2011,2013,2014 Université de Bordeaux
  6. * Copyright (C) 2013 Thibaut Lambert
  7. *
  8. * StarPU is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation; either version 2.1 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * StarPU is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  18. */
  19. #ifndef __DW_CHOLESKY_H__
  20. #define __DW_CHOLESKY_H__
  21. #include <limits.h>
  22. #include <string.h>
  23. #include <math.h>
  24. #include <sys/time.h>
  25. #ifdef STARPU_USE_CUDA
  26. #include <cuda.h>
  27. #include <cuda_runtime.h>
  28. #include <cublas.h>
  29. #endif
  30. #include <common/blas.h>
  31. #include <starpu.h>
  32. #include <starpu_bound.h>
  33. #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
  34. #define NMAXBLOCKS 32
  35. #define TAG11(k) ((starpu_tag_t)( (1ULL<<60) | (unsigned long long)(k)))
  36. #define TAG21(k,j) ((starpu_tag_t)(((3ULL<<60) | (((unsigned long long)(k))<<32) \
  37. | (unsigned long long)(j))))
  38. #define TAG22(k,i,j) ((starpu_tag_t)(((4ULL<<60) | ((unsigned long long)(k)<<32) \
  39. | ((unsigned long long)(i)<<16) \
  40. | (unsigned long long)(j))))
  41. #define TAG11_AUX(k, prefix) ((starpu_tag_t)( (((unsigned long long)(prefix))<<60) | (1ULL<<56) | (unsigned long long)(k)))
  42. #define TAG21_AUX(k,j, prefix) ((starpu_tag_t)( (((unsigned long long)(prefix))<<60) \
  43. | ((3ULL<<56) | (((unsigned long long)(k))<<32) \
  44. | (unsigned long long)(j))))
  45. #define TAG22_AUX(k,i,j, prefix) ((starpu_tag_t)( (((unsigned long long)(prefix))<<60) \
  46. | ((4ULL<<56) | ((unsigned long long)(k)<<32) \
  47. | ((unsigned long long)(i)<<16) \
  48. | (unsigned long long)(j))))
  49. #define BLOCKSIZE (size/nblocks)
  50. #define BLAS3_FLOP(n1,n2,n3) \
  51. (2*((uint64_t)n1)*((uint64_t)n2)*((uint64_t)n3))
  52. static unsigned size = 4*1024;
  53. static unsigned nblocks = 16;
  54. static unsigned nbigblocks = 8;
  55. static unsigned pinned = 0;
  56. static unsigned noprio = 0;
  57. static unsigned check = 0;
  58. static unsigned bound = 0;
  59. static unsigned with_ctxs = 0;
  60. static unsigned with_noctxs = 0;
  61. static unsigned chole1 = 0;
  62. static unsigned chole2 = 0;
  63. void chol_cpu_codelet_update_u11(void **, void *);
  64. void chol_cpu_codelet_update_u21(void **, void *);
  65. void chol_cpu_codelet_update_u22(void **, void *);
  66. double cpu_chol_task_11_cost(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  67. double cpu_chol_task_21_cost(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  68. double cpu_chol_task_22_cost(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  69. #ifdef STARPU_USE_CUDA
  70. void chol_cublas_codelet_update_u11(void *descr[], void *_args);
  71. void chol_cublas_codelet_update_u21(void *descr[], void *_args);
  72. void chol_cublas_codelet_update_u22(void *descr[], void *_args);
  73. double cuda_chol_task_11_cost(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  74. double cuda_chol_task_21_cost(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  75. double cuda_chol_task_22_cost(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
  76. #endif
  77. void initialize_chol_model(struct starpu_perfmodel* model, char* symbol,
  78. double (*cpu_cost_function)(struct starpu_task *, struct starpu_perfmodel_arch*, unsigned),
  79. double (*cuda_cost_function)(struct starpu_task *, struct starpu_perfmodel_arch*, unsigned));
  80. static void parse_args(int argc, char **argv)
  81. {
  82. int i;
  83. for (i = 1; i < argc; i++)
  84. {
  85. if (strcmp(argv[i], "-with_ctxs") == 0)
  86. {
  87. with_ctxs = 1;
  88. break;
  89. }
  90. if (strcmp(argv[i], "-with_noctxs") == 0)
  91. {
  92. with_noctxs = 1;
  93. break;
  94. }
  95. if (strcmp(argv[i], "-chole1") == 0)
  96. {
  97. chole1 = 1;
  98. break;
  99. }
  100. if (strcmp(argv[i], "-chole2") == 0)
  101. {
  102. chole2 = 1;
  103. break;
  104. }
  105. if (strcmp(argv[i], "-size") == 0)
  106. {
  107. char *argptr;
  108. size = strtol(argv[++i], &argptr, 10);
  109. }
  110. if (strcmp(argv[i], "-nblocks") == 0)
  111. {
  112. char *argptr;
  113. nblocks = strtol(argv[++i], &argptr, 10);
  114. }
  115. if (strcmp(argv[i], "-nbigblocks") == 0)
  116. {
  117. char *argptr;
  118. nbigblocks = strtol(argv[++i], &argptr, 10);
  119. }
  120. if (strcmp(argv[i], "-pin") == 0)
  121. {
  122. pinned = 1;
  123. }
  124. if (strcmp(argv[i], "-no-prio") == 0)
  125. {
  126. noprio = 1;
  127. }
  128. if (strcmp(argv[i], "-bound") == 0)
  129. {
  130. bound = 1;
  131. }
  132. if (strcmp(argv[i], "-check") == 0)
  133. {
  134. check = 1;
  135. }
  136. if (strcmp(argv[i], "-h") == 0)
  137. {
  138. printf("usage : %s [-pin] [-size size] [-nblocks nblocks] [-check]\n", argv[0]);
  139. }
  140. }
  141. }
  142. #endif /* __DW_CHOLESKY_H__ */