xlu.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 __XLU_H__
  17. #define __XLU_H__
  18. #include <sys/time.h>
  19. /* for STARPU_USE_CUDA */
  20. #include <starpu_config.h>
  21. #include <starpu.h>
  22. #include <starpu_cuda.h>
  23. #include <common/blas.h>
  24. #define BLAS3_FLOP(n1,n2,n3) \
  25. (2*((uint64_t)n1)*((uint64_t)n2)*((uint64_t)n3))
  26. #ifdef CHECK_RESULTS
  27. static void __attribute__ ((unused)) compare_A_LU(float *A, float *LU,
  28. unsigned size, unsigned ld)
  29. {
  30. unsigned i,j;
  31. float *L;
  32. float *U;
  33. L = malloc(size*size*sizeof(float));
  34. U = malloc(size*size*sizeof(float));
  35. memset(L, 0, size*size*sizeof(float));
  36. memset(U, 0, size*size*sizeof(float));
  37. /* only keep the lower part */
  38. for (j = 0; j < size; j++)
  39. {
  40. for (i = 0; i < j; i++)
  41. {
  42. L[j+i*size] = LU[j+i*ld];
  43. }
  44. /* diag i = j */
  45. L[j+j*size] = LU[j+j*ld];
  46. U[j+j*size] = 1.0f;
  47. for (i = j+1; i < size; i++)
  48. {
  49. U[j+i*size] = LU[j+i*ld];
  50. }
  51. }
  52. /* now A_err = L, compute L*U */
  53. STRMM("R", "U", "N", "U", size, size, 1.0f, U, size, L, size);
  54. float max_err = 0.0f;
  55. for (i = 0; i < size ; i++)
  56. {
  57. for (j = 0; j < size; j++)
  58. {
  59. max_err = STARPU_MAX(max_err, fabs( L[j+i*size] - A[j+i*ld] ));
  60. }
  61. }
  62. printf("max error between A and L*U = %f \n", max_err);
  63. }
  64. #endif // CHECK_RESULTS
  65. void dw_cpu_codelet_update_u11(void **, void *);
  66. void dw_cpu_codelet_update_u12(void **, void *);
  67. void dw_cpu_codelet_update_u21(void **, void *);
  68. void dw_cpu_codelet_update_u22(void **, void *);
  69. #ifdef STARPU_USE_CUDA
  70. void dw_cublas_codelet_update_u11(void *descr[], void *_args);
  71. void dw_cublas_codelet_update_u12(void *descr[], void *_args);
  72. void dw_cublas_codelet_update_u21(void *descr[], void *_args);
  73. void dw_cublas_codelet_update_u22(void *descr[], void *_args);
  74. #endif
  75. void dw_callback_codelet_update_u11(void *);
  76. void dw_callback_codelet_update_u12_21(void *);
  77. void dw_callback_codelet_update_u22(void *);
  78. void dw_callback_v2_codelet_update_u11(void *);
  79. void dw_callback_v2_codelet_update_u12(void *);
  80. void dw_callback_v2_codelet_update_u21(void *);
  81. void dw_callback_v2_codelet_update_u22(void *);
  82. extern struct starpu_perfmodel_t model_11;
  83. extern struct starpu_perfmodel_t model_12;
  84. extern struct starpu_perfmodel_t model_21;
  85. extern struct starpu_perfmodel_t model_22;
  86. struct piv_s {
  87. unsigned *piv; /* complete pivot array */
  88. unsigned first; /* first element */
  89. unsigned last; /* last element */
  90. };
  91. void STARPU_LU(lu_decomposition)(TYPE *matA, unsigned size, unsigned ld, unsigned nblocks);
  92. void STARPU_LU(lu_decomposition_pivot_no_stride)(TYPE **matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks);
  93. void STARPU_LU(lu_decomposition_pivot)(TYPE *matA, unsigned *ipiv, unsigned size, unsigned ld, unsigned nblocks);
  94. #endif // __XLU_H__