xlu.h 3.4 KB

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