dw_cholesky.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (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. #ifdef USE_CUDA
  22. #include <cuda.h>
  23. #include <cublas.h>
  24. #endif
  25. #include "../common/blas.h"
  26. #include <starpu.h>
  27. #define NMAXBLOCKS 32
  28. #define TAG11(k) ( (1ULL<<60) | (unsigned long long)(k))
  29. #define TAG21(k,j) (((3ULL<<60) | (((unsigned long long)(k))<<32) \
  30. | (unsigned long long)(j)))
  31. #define TAG22(k,i,j) (((4ULL<<60) | ((unsigned long long)(k)<<32) \
  32. | ((unsigned long long)(i)<<16) \
  33. | (unsigned long long)(j)))
  34. #define BLOCKSIZE (size/nblocks)
  35. #define BLAS3_FLOP(n1,n2,n3) \
  36. (2*((uint64_t)n1)*((uint64_t)n2)*((uint64_t)n3))
  37. typedef struct {
  38. starpu_data_handle dataA;
  39. unsigned i;
  40. unsigned j;
  41. unsigned k;
  42. unsigned nblocks;
  43. unsigned *remaining;
  44. sem_t *sem;
  45. } cl_args;
  46. static unsigned size = 4*1024;
  47. static unsigned nblocks = 4;
  48. static unsigned pinned = 0;
  49. void chol_core_codelet_update_u11(starpu_data_interface_t *, void *);
  50. void chol_core_codelet_update_u21(starpu_data_interface_t *, void *);
  51. void chol_core_codelet_update_u22(starpu_data_interface_t *, void *);
  52. #ifdef USE_CUDA
  53. void chol_cublas_codelet_update_u11(starpu_data_interface_t *descr, void *_args);
  54. void chol_cublas_codelet_update_u21(starpu_data_interface_t *descr, void *_args);
  55. void chol_cublas_codelet_update_u22(starpu_data_interface_t *descr, void *_args);
  56. #endif
  57. void initialize_system(float **A, unsigned dim, unsigned pinned);
  58. void dw_cholesky(float *matA, unsigned size, unsigned ld, unsigned nblocks);
  59. extern struct starpu_perfmodel_t chol_model_11;
  60. extern struct starpu_perfmodel_t chol_model_21;
  61. extern struct starpu_perfmodel_t chol_model_22;
  62. static void __attribute__((unused)) parse_args(int argc, char **argv)
  63. {
  64. int i;
  65. for (i = 1; i < argc; i++) {
  66. if (strcmp(argv[i], "-size") == 0) {
  67. char *argptr;
  68. size = strtol(argv[++i], &argptr, 10);
  69. }
  70. if (strcmp(argv[i], "-nblocks") == 0) {
  71. char *argptr;
  72. nblocks = strtol(argv[++i], &argptr, 10);
  73. }
  74. if (strcmp(argv[i], "-pin") == 0) {
  75. pinned = 1;
  76. }
  77. if (strcmp(argv[i], "-h") == 0) {
  78. printf("usage : %s [-pin] [-size size] [-nblocks nblocks]\n", argv[0]);
  79. }
  80. }
  81. }
  82. #endif // __DW_CHOLESKY_H__