HiCMA
Hierarchical Computations on Manycore Architectures
hcore_zgemmbdcd.c
Go to the documentation of this file.
1 
16 #include "coreblas/coreblas.h"
17 #include "coreblas/lapacke.h"
18 #include <assert.h>
19 
20 //FIXME PREVIOUS DECLARION OF CBLAS_SADDR ~/hicma/chameleon/build/include/chameleon/coreblas/include/coreblas.h
21 #undef CBLAS_SADDR
22 #define CBLAS_SADDR(_val) (_val)
23 
26 
27 /*
28  * CD=AU*BV'.
29  * Rank of tile AU is in Ark.
30  * Rank of tile BV is in Brk.
31  * Multiplied tiles must have same rank.
32  * CD is dense output.
33 */
34 void HCORE_zgemmbdcd(MORSE_enum transA, MORSE_enum transB,
35  int M, int N,
36  double alpha,
37  double *AU,
38  double *AV,
39  double *Ark,
40  int LDA,
41  double *BD,
42  int LDB,
43  double beta,
44  double *CD,
45  int LDC,
46  double *work
47 )
48 {
49  /*printf("%d|M:%d N:%d K:%d LDA:%d LDB:%d LDC:%d rk:%d acc:%e a:%e b:%e\n",*/
50  /*__LINE__, M, N, K, LDA, LDB, LDC, rk, acc, alpha, beta);*/
51 
52  /*
53  * NOTES:
54  * assumptions on matrix dimensions are marked as //ASSUMPTION
55  * I am currently allocating and freeing temporary buffers.
56  * They are marked as //ALLOCATE
57  */
58  /*printf("%d %d|%g->%d. %g %g, %g %g\n", */
59  /*__LINE__, __COUNTER__,*/
60  /*Crk[0], new_Crk, CU[0], CU[1], CV[0], CV[1]);*/
61  //hcore_dgemm(Aij, ik, Ajk, -1, rank, acc);
62  int64_t _Ark = (int64_t)(Ark[0]);
63  int64_t sizeofAVBD = LDB * N * sizeof(double);
65  printf("Ark:%d M:%d N:%d K:%d LDA:%d LDB:%d LDC:%d sizeofAVBD=%d transA:%d transB:%d alpha:%g beta:%g\n",
66  _Ark, M, N, _Ark, LDA, LDB, LDC, sizeofAVBD, transA, transB, alpha, beta );
67  }
68  double one = 1.0, zero = 0.0, minusone = -1.0;
70  /*hcfrk_printmat(AU, M, _Ark, LDA); */
71  /*hcfrk_printmat(BV, N, _Brk, LDB); */
72  }
73  double *AVBD = malloc(sizeofAVBD);
74  if ( transA == MorseTrans) {
75  /*printf("AUBD=AU^TxBD m,n,k:%d,%d,%d ld:%d,%d,%d\n", _Ark, N, M, LDA, LDB, LDB);*/
76  cblas_dgemm(
77  CblasColMajor,
78  CblasTrans, CblasNoTrans,
79  _Ark, N, M,
80  CBLAS_SADDR(one), AV, LDA,
81  BD, LDB,
82  CBLAS_SADDR(zero), AVBD, LDB);
83  /*printf("CD=AVxAUBD m,n,k:%d,%d,%d ld:%d,%d,%d\n", LDA, N, _Ark, LDA, LDB, LDC);*/
84  cblas_dgemm(
85  CblasColMajor,
86  CblasNoTrans, CblasNoTrans,
87  LDA, N, _Ark,
88  CBLAS_SADDR(alpha), AU, LDA,
89  AVBD, LDB,
90  CBLAS_SADDR(beta), CD, LDC);
91  } else {
92  /*printf("AVBD=AV^TxBD m,n,k:%d,%d,%d ld:%d,%d,%d\n", _Ark, N, LDB, LDA, LDB, LDB);*/
93  cblas_dgemm(
94  CblasColMajor,
95  CblasTrans, CblasNoTrans,
96  _Ark, N, LDB,
97  CBLAS_SADDR(one), AV, LDA,
98  BD, LDB,
99  CBLAS_SADDR(zero), AVBD, LDB);
100  /*printf("CD=AUxAVBD m,n,k:%d,%d,%d ld:%d,%d,%d\n", M, N, _Ark, LDA, LDB, LDC);*/
101  cblas_dgemm(
102  CblasColMajor,
103  CblasNoTrans, CblasNoTrans,
104  M, N, _Ark,
105  CBLAS_SADDR(alpha), AU, LDA,
106  AVBD, LDB,
107  CBLAS_SADDR(beta), CD, LDC);
108  }
109  free(AVBD);
110  if(gemmbdcd_print_mat){
111  /*hcfrk_printmat(CD, M, N, LDC); */
112  }
113 
114 }
115 
void HCORE_zgemmbdcd(MORSE_enum transA, MORSE_enum transB, int M, int N, double alpha, double *AU, double *AV, double *Ark, int LDA, double *BD, int LDB, double beta, double *CD, int LDC, double *work)
#define CBLAS_SADDR(_val)
int gemmbdcd_print_index
int gemmbdcd_print_mat