xlu.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009, 2010-2011, 2014 Université de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012, 2013, 2014 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. #ifndef __XLU_H__
  18. #define __XLU_H__
  19. #include <starpu.h>
  20. #include <common/blas.h>
  21. #ifdef STARPU_USE_CUDA
  22. #include <cublas.h>
  23. #endif
  24. #define TAG11(k) ((starpu_tag_t)( (1ULL<<60) | (unsigned long long)(k)))
  25. #define TAG12(k,i) ((starpu_tag_t)(((2ULL<<60) | (((unsigned long long)(k))<<32) \
  26. | (unsigned long long)(i))))
  27. #define TAG21(k,j) ((starpu_tag_t)(((3ULL<<60) | (((unsigned long long)(k))<<32) \
  28. | (unsigned long long)(j))))
  29. #define TAG22(k,i,j) ((starpu_tag_t)(((4ULL<<60) | ((unsigned long long)(k)<<32) \
  30. | ((unsigned long long)(i)<<16) \
  31. | (unsigned long long)(j))))
  32. #define PIVOT(k,i) ((starpu_tag_t)(((5ULL<<60) | (((unsigned long long)(k))<<32) \
  33. | (unsigned long long)(i))))
  34. #define FPRINTF(ofile, fmt, ...) do { if (!getenv("STARPU_SSILENT")) {fprintf(ofile, fmt, ## __VA_ARGS__); }} while(0)
  35. #define PRINTF(fmt, ...) do { if (!getenv("STARPU_SSILENT")) {printf(fmt, ## __VA_ARGS__); }} while(0)
  36. #define BLAS3_FLOP(n1,n2,n3) \
  37. (2*((uint64_t)n1)*((uint64_t)n2)*((uint64_t)n3))
  38. #ifdef CHECK_RESULTS
  39. static void STARPU_ATTRIBUTE_UNUSED compare_A_LU(float *A, float *LU,
  40. unsigned size, unsigned ld)
  41. {
  42. unsigned i,j;
  43. float *L;
  44. float *U;
  45. L = malloc(size*size*sizeof(float));
  46. U = malloc(size*size*sizeof(float));
  47. memset(L, 0, size*size*sizeof(float));
  48. memset(U, 0, size*size*sizeof(float));
  49. /* only keep the lower part */
  50. for (j = 0; j < size; j++)
  51. {
  52. for (i = 0; i < j; i++)
  53. {
  54. L[j+i*size] = LU[j+i*ld];
  55. }
  56. /* diag i = j */
  57. L[j+j*size] = LU[j+j*ld];
  58. U[j+j*size] = 1.0f;
  59. for (i = j+1; i < size; i++)
  60. {
  61. U[j+i*size] = LU[j+i*ld];
  62. }
  63. }
  64. /* now A_err = L, compute L*U */
  65. STARPU_STRMM("R", "U", "N", "U", size, size, 1.0f, U, size, L, size);
  66. float max_err = 0.0f;
  67. for (i = 0; i < size ; i++)
  68. {
  69. for (j = 0; j < size; j++)
  70. {
  71. max_err = STARPU_MAX(max_err, fabs( L[j+i*size] - A[j+i*ld] ));
  72. }
  73. }
  74. FPRINTF(stdout, "max error between A and L*U = %f \n", max_err);
  75. }
  76. #endif /* CHECK_RESULTS */
  77. void dw_cpu_codelet_update_u11(void **, void *);
  78. void dw_cpu_codelet_update_u12(void **, void *);
  79. void dw_cpu_codelet_update_u21(void **, void *);
  80. void dw_cpu_codelet_update_u22(void **, void *);
  81. #ifdef STARPU_USE_CUDA
  82. void dw_cublas_codelet_update_u11(void *descr[], void *_args);
  83. void dw_cublas_codelet_update_u12(void *descr[], void *_args);
  84. void dw_cublas_codelet_update_u21(void *descr[], void *_args);
  85. void dw_cublas_codelet_update_u22(void *descr[], void *_args);
  86. #endif
  87. void dw_callback_codelet_update_u11(void *);
  88. void dw_callback_codelet_update_u12_21(void *);
  89. void dw_callback_codelet_update_u22(void *);
  90. void dw_callback_v2_codelet_update_u11(void *);
  91. void dw_callback_v2_codelet_update_u12(void *);
  92. void dw_callback_v2_codelet_update_u21(void *);
  93. void dw_callback_v2_codelet_update_u22(void *);
  94. extern struct starpu_perfmodel model_11;
  95. extern struct starpu_perfmodel model_12;
  96. extern struct starpu_perfmodel model_21;
  97. extern struct starpu_perfmodel model_22;
  98. extern unsigned bound;
  99. extern unsigned bounddeps;
  100. extern unsigned boundprio;
  101. struct piv_s
  102. {
  103. unsigned *piv; /* complete pivot array */
  104. unsigned first; /* first element */
  105. unsigned last; /* last element */
  106. };
  107. int STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned nblocks);
  108. int STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks);
  109. int STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks);
  110. #endif /* __XLU_H__ */