dw_cholesky.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * StarPU
  3. * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (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. #ifndef __DW_CHOLESKY_H__
  17. #define __DW_CHOLESKY_H__
  18. #include <semaphore.h>
  19. #include <string.h>
  20. #include <math.h>
  21. #include <sys/time.h>
  22. #ifdef STARPU_USE_CUDA
  23. #include <cuda.h>
  24. #include <cuda_runtime.h>
  25. #include <cublas.h>
  26. #endif
  27. #include <common/blas.h>
  28. #include <starpu.h>
  29. #define NMAXBLOCKS 32
  30. #define TAG11(k) ((starpu_tag_t)( (1ULL<<60) | (unsigned long long)(k)))
  31. #define TAG21(k,j) ((starpu_tag_t)(((3ULL<<60) | (((unsigned long long)(k))<<32) \
  32. | (unsigned long long)(j))))
  33. #define TAG22(k,i,j) ((starpu_tag_t)(((4ULL<<60) | ((unsigned long long)(k)<<32) \
  34. | ((unsigned long long)(i)<<16) \
  35. | (unsigned long long)(j))))
  36. #define TAG11_AUX(k, prefix) ((starpu_tag_t)( (((unsigned long long)(prefix))<<60) | (1ULL<<56) | (unsigned long long)(k)))
  37. #define TAG21_AUX(k,j, prefix) ((starpu_tag_t)( (((unsigned long long)(prefix))<<60) \
  38. | ((3ULL<<56) | (((unsigned long long)(k))<<32) \
  39. | (unsigned long long)(j))))
  40. #define TAG22_AUX(k,i,j, prefix) ((starpu_tag_t)( (((unsigned long long)(prefix))<<60) \
  41. | ((4ULL<<56) | ((unsigned long long)(k)<<32) \
  42. | ((unsigned long long)(i)<<16) \
  43. | (unsigned long long)(j))))
  44. #define BLOCKSIZE (size/nblocks)
  45. #define BLAS3_FLOP(n1,n2,n3) \
  46. (2*((uint64_t)n1)*((uint64_t)n2)*((uint64_t)n3))
  47. typedef struct {
  48. starpu_data_handle dataA;
  49. unsigned i;
  50. unsigned j;
  51. unsigned k;
  52. unsigned nblocks;
  53. unsigned *remaining;
  54. sem_t *sem;
  55. } cl_args;
  56. static unsigned size = 16*1024;
  57. static unsigned nblocks = 16;
  58. static unsigned nbigblocks = 8;
  59. static unsigned pinned = 0;
  60. static unsigned noprio = 0;
  61. void chol_cpu_codelet_update_u11(void **, void *);
  62. void chol_cpu_codelet_update_u21(void **, void *);
  63. void chol_cpu_codelet_update_u22(void **, void *);
  64. #ifdef STARPU_USE_CUDA
  65. void chol_cublas_codelet_update_u11(void *descr[], void *_args);
  66. void chol_cublas_codelet_update_u21(void *descr[], void *_args);
  67. void chol_cublas_codelet_update_u22(void *descr[], void *_args);
  68. #endif
  69. void initialize_system(float **A, unsigned dim, unsigned pinned);
  70. void dw_cholesky(float *matA, unsigned size, unsigned ld, unsigned nblocks);
  71. extern struct starpu_perfmodel_t chol_model_11;
  72. extern struct starpu_perfmodel_t chol_model_21;
  73. extern struct starpu_perfmodel_t chol_model_22;
  74. static void __attribute__((unused)) parse_args(int argc, char **argv)
  75. {
  76. int i;
  77. for (i = 1; i < argc; i++) {
  78. if (strcmp(argv[i], "-size") == 0) {
  79. char *argptr;
  80. size = strtol(argv[++i], &argptr, 10);
  81. }
  82. if (strcmp(argv[i], "-nblocks") == 0) {
  83. char *argptr;
  84. nblocks = strtol(argv[++i], &argptr, 10);
  85. }
  86. if (strcmp(argv[i], "-nbigblocks") == 0) {
  87. char *argptr;
  88. nbigblocks = strtol(argv[++i], &argptr, 10);
  89. }
  90. if (strcmp(argv[i], "-pin") == 0) {
  91. pinned = 1;
  92. }
  93. if (strcmp(argv[i], "-no-prio") == 0) {
  94. noprio = 1;
  95. }
  96. if (strcmp(argv[i], "-h") == 0) {
  97. printf("usage : %s [-pin] [-size size] [-nblocks nblocks]\n", argv[0]);
  98. }
  99. }
  100. }
  101. #endif // __DW_CHOLESKY_H__