strassen.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 __STRASSEN_H__
  17. #define __STRASSEN_H__
  18. #include <semaphore.h>
  19. #include <sys/time.h>
  20. #include <string.h>
  21. #include <math.h>
  22. #include <sys/types.h>
  23. #include <pthread.h>
  24. #include <signal.h>
  25. #include <cblas.h>
  26. #include <starpu_config.h>
  27. #ifdef STARPU_USE_CUDA
  28. #include <cuda.h>
  29. #include <cublas.h>
  30. #endif
  31. #include <starpu.h>
  32. typedef enum {
  33. ADD,
  34. SUB,
  35. MULT,
  36. SELFADD,
  37. SELFSUB,
  38. NONE
  39. } operation;
  40. typedef struct {
  41. /* monitor the progress of the algorithm */
  42. unsigned Ei12[7]; // Ei12[k] is 0, 1 or 2 (2 = finished Ei1 and Ei2)
  43. unsigned Ei[7];
  44. unsigned Ei_remaining_use[7];
  45. unsigned Cij[4];
  46. starpu_data_handle A, B, C;
  47. starpu_data_handle A11, A12, A21, A22;
  48. starpu_data_handle B11, B12, B21, B22;
  49. starpu_data_handle C11, C12, C21, C22;
  50. starpu_data_handle E1, E2, E3, E4, E5, E6, E7;
  51. starpu_data_handle E11, E12, E21, E22, E31, E32, E41, E52, E62, E71;
  52. starpu_data_handle E42, E51, E61, E72;
  53. unsigned reclevel;
  54. /* */
  55. unsigned counter;
  56. /* called at the end of the iteration */
  57. void (*strassen_iter_callback)(void *);
  58. void *argcb;
  59. } strassen_iter_state_t;
  60. typedef struct {
  61. strassen_iter_state_t *iter;
  62. /* phase 1 computes Ei1 or Ei2 with i in 0-6 */
  63. unsigned i;
  64. } phase1_t;
  65. typedef struct {
  66. strassen_iter_state_t *iter;
  67. /* phase 2 computes Ei with i in 0-6 */
  68. unsigned i;
  69. } phase2_t;
  70. typedef struct {
  71. strassen_iter_state_t *iter;
  72. /* phase 2 computes Ei with i in 0-6 */
  73. unsigned i;
  74. } phase3_t;
  75. void mult_cpu_codelet(void *descr[], __attribute__((unused)) void *arg);
  76. void sub_cpu_codelet(void *descr[], __attribute__((unused)) void *arg);
  77. void add_cpu_codelet(void *descr[], __attribute__((unused)) void *arg);
  78. void self_add_cpu_codelet(void *descr[], __attribute__((unused)) void *arg);
  79. void self_sub_cpu_codelet(void *descr[], __attribute__((unused)) void *arg);
  80. #ifdef STARPU_USE_CUDA
  81. void mult_cublas_codelet(void *descr[], __attribute__((unused)) void *arg);
  82. void sub_cublas_codelet(void *descr[], __attribute__((unused)) void *arg);
  83. void add_cublas_codelet(void *descr[], __attribute__((unused)) void *arg);
  84. void self_add_cublas_codelet(void *descr[], __attribute__((unused)) void *arg);
  85. void self_sub_cublas_codelet(void *descr[], __attribute__((unused)) void *arg);
  86. #endif
  87. void strassen(starpu_data_handle A, starpu_data_handle B, starpu_data_handle C, void (*callback)(void *), void *argcb, unsigned reclevel);
  88. extern struct starpu_perfmodel_t strassen_model_mult;
  89. extern struct starpu_perfmodel_t strassen_model_add_sub;
  90. extern struct starpu_perfmodel_t strassen_model_self_add_sub;
  91. #endif // __STRASSEN_H__