HiCMA
Hierarchical Computations on Manycore Architectures
zgemm.c
Go to the documentation of this file.
1 /*
2  * @copyright (c) 2017 King Abdullah University of Science and Technology (KAUST).
3  * All rights reserved.
4  **/
5 
6 
20 /*
21  * @copyright (c) 2009-2014 The University of Tennessee and The University
22  * of Tennessee Research Foundation.
23  * All rights reserved.
24  * @copyright (c) 2012-2016 Inria. All rights reserved.
25  * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
26  */
27 
28 /*
29  *
30  * @file zgemm.c
31  *
32  * MORSE computational routines
33  * MORSE is a software package provided by Univ. of Tennessee,
34  * Univ. of California Berkeley and Univ. of Colorado Denver
35  *
36  * @version 2.5.0
37  * @comment This file has been automatically generated
38  * from Plasma 2.5.0 for MORSE 1.0.0
39  * @author Mathieu Faverge
40  * @author Emmanuel Agullo
41  * @author Cedric Castagnede
42  * @date 2018-11-08
43  * @precisions normal z -> s d c
44  *
45  **/
46 #include "morse.h"
47 #include "control/common.h"
48 #include "control/hicma_common.h"
49 
50 
51 /***************************************************************************/
109 int HICMA_zgemm_Tile(MORSE_enum transA, MORSE_enum transB,
110  double alpha,
111  MORSE_desc_t *AUV, MORSE_desc_t *Ark,
112  MORSE_desc_t *BUV, MORSE_desc_t *Brk,
113  double beta,
114  MORSE_desc_t *CUV, MORSE_desc_t *Crk,
115  int rk,
116  int maxrk,
117  double acc
118  )
119 {
120  MORSE_context_t *morse;
121  MORSE_sequence_t *sequence = NULL;
122  MORSE_request_t request = MORSE_REQUEST_INITIALIZER;
123  int status;
124 
125  morse = morse_context_self();
126  if (morse == NULL) {
127  morse_fatal_error("MORSE_zgemm_Tile", "MORSE not initialized");
128  return MORSE_ERR_NOT_INITIALIZED;
129  }
130  morse_sequence_create(morse, &sequence);
131 
132  HICMA_zgemm_Tile_Async( transA, transB,
133  alpha, AUV, Ark,
134  BUV, Brk,
135  beta, CUV, Crk,
136  rk, maxrk, acc,
137  sequence, &request
138  );
139 
140  MORSE_Desc_Flush( AUV, sequence );
141  MORSE_Desc_Flush( BUV, sequence );
142  MORSE_Desc_Flush( CUV, sequence );
143  MORSE_Desc_Flush( Ark, sequence );
144  MORSE_Desc_Flush( Brk, sequence );
145  MORSE_Desc_Flush( Crk, sequence );
146  morse_sequence_wait(morse, sequence);
147  /*RUNTIME_desc_getoncpu(AUV);*/
148  /*RUNTIME_desc_getoncpu(BUV);*/
149  /*RUNTIME_desc_getoncpu(CUV);*/
150  /*RUNTIME_desc_getoncpu(Ark);*/
151  /*RUNTIME_desc_getoncpu(Brk);*/
152  /*RUNTIME_desc_getoncpu(Crk);*/
153 
154  status = sequence->status;
155  morse_sequence_destroy(morse, sequence);
156  return status;
157 }
158 
159 /***************************************************************************/
176 int HICMA_zgemm_Tile_Async(MORSE_enum transA, MORSE_enum transB,
177  double alpha,
178  MORSE_desc_t *AUV, MORSE_desc_t *Ark,
179  MORSE_desc_t *BUV, MORSE_desc_t *Brk,
180  double beta,
181  MORSE_desc_t *CUV, MORSE_desc_t *Crk,
182  int rk,
183  int maxrk,
184  double acc ,
185  MORSE_sequence_t *sequence, MORSE_request_t *request)
186 {
187  MORSE_context_t *morse;
188  int M, N, K;
189  int Am, An, Ai, Aj, Amb, Anb;
190  int Bm, Bn, Bi, Bj, Bmb, Bnb;
191 
192  morse = morse_context_self();
193  if (morse == NULL) {
194  morse_fatal_error("MORSE_zgemm_Tile_Async", "MORSE not initialized");
195  return MORSE_ERR_NOT_INITIALIZED;
196  }
197  if (sequence == NULL) {
198  morse_fatal_error("MORSE_zgemm_Tile_Async", "NULL sequence");
199  return MORSE_ERR_UNALLOCATED;
200  }
201  if (request == NULL) {
202  morse_fatal_error("MORSE_zgemm_Tile_Async", "NULL request");
203  return MORSE_ERR_UNALLOCATED;
204  }
205  /* Check sequence status */
206  if (sequence->status == MORSE_SUCCESS)
207  request->status = MORSE_SUCCESS;
208  else
209  return morse_request_fail(sequence, request, MORSE_ERR_SEQUENCE_FLUSHED);
210 
211  /* Check descriptors for correctness */
212  if (
213  (morse_desc_check(AUV) != MORSE_SUCCESS)
214  ||(morse_desc_check(BUV) != MORSE_SUCCESS)
215  ||(morse_desc_check(CUV) != MORSE_SUCCESS)
216  ||(morse_desc_check(Ark) != MORSE_SUCCESS)
217  ||(morse_desc_check(Brk) != MORSE_SUCCESS)
218  ||(morse_desc_check(Crk) != MORSE_SUCCESS)
219  )
220  {
221  morse_error("MORSE_zgemm_Tile_Async", "some invalid descriptors");
222  return morse_request_fail(sequence, request, MORSE_ERR_ILLEGAL_VALUE);
223  }
224  /* Check input arguments */
225  if ((transA != MorseNoTrans) && (transA != MorseTrans) && (transA != MorseConjTrans)) {
226  morse_error("MORSE_zgemm_Tile_Async", "illegal value of transA");
227  return morse_request_fail(sequence, request, -1);
228  }
229  if ((transB != MorseNoTrans) && (transB != MorseTrans) && (transB != MorseConjTrans)) {
230  morse_error("MORSE_zgemm_Tile_Async", "illegal value of transB");
231  return morse_request_fail(sequence, request, -2);
232  }
233 
234  if ( transA == MorseNoTrans ) {
235  Am = AUV->m;
236  An = AUV->n;
237  Amb = AUV->mb;
238  Anb = AUV->nb;
239  Ai = AUV->i;
240  Aj = AUV->j;
241  } else {
242  Am = AUV->n;
243  An = AUV->m;
244  Amb = AUV->nb;
245  Anb = AUV->mb;
246  Ai = AUV->j;
247  Aj = AUV->i;
248  }
249 
250  if ( transB == MorseNoTrans ) {
251  Bm = BUV->m;
252  Bn = BUV->n;
253  Bmb = BUV->mb;
254  Bnb = BUV->nb;
255  Bi = BUV->i;
256  Bj = BUV->j;
257  } else {
258  Bm = BUV->n;
259  Bn = BUV->m;
260  Bmb = BUV->nb;
261  Bnb = BUV->mb;
262  Bi = BUV->j;
263  Bj = BUV->i;
264  }
265 
266  // Commented out by @kadir because Currently, Hicma's tiles can be tall and skinny matrices.
267  // these conditions need more validations
268  /*if ( (Amb != CUV->mb) || (Anb != Bmb) || (Bnb != CUV->nb) ) {*/
269  /*morse_error("MORSE_zgemm_Tile_Async", "tile sizes have to match");*/
270  /*return morse_request_fail(sequence, request, MORSE_ERR_ILLEGAL_VALUE);*/
271  /*}*/
272  /*if ( (Am != CUV->m) || (An != Bm) || (Bn != CUV->n) ) {*/
273  /*morse_error("MORSE_zgemm_Tile_Async", "sizes of matrices have to match");*/
274  /*return morse_request_fail(sequence, request, MORSE_ERR_ILLEGAL_VALUE);*/
275  /*}*/
276  /*if ( (Ai != CUV->i) || (Aj != Bi) || (Bj != CUV->j) ) {*/
277  /*morse_error("MORSE_zgemm_Tile_Async", "start indexes have to match");*/
278  /*return morse_request_fail(sequence, request, MORSE_ERR_ILLEGAL_VALUE);*/
279  /*}*/
280  /*if ((AUV->nb != AUV->mb) || (BUV->nb != BUV->mb) || (CUV->nb != CUV->mb) ){*/
281  /*morse_error("HICMA_zpotrf_Tile_Async", "only square tiles supported");*/
282  /*return morse_request_fail(sequence, request, MORSE_ERR_ILLEGAL_VALUE);*/
283  /*}*/
284 
285  M = CUV->m;
286  N = CUV->n;
287  K = An;
288 
289  /* Quick return */
290  if (M == 0 || N == 0 ||
291  ((alpha == 0.0 || K == 0) && beta == 1.0))
292  // ((alpha == (MORSE_Complex64_t)0.0 || K == 0) && beta == (MORSE_Complex64_t)1.0))
293  return MORSE_SUCCESS;
294 
295  hicma_pzgemm(transA, transB,
296  alpha, AUV, Ark,
297  BUV, Brk,
298  beta, CUV, Crk,
299  sequence, request,
300  rk, maxrk, acc);
301 
302  return MORSE_SUCCESS;
303 }
#define AUV(m, n)
Definition: pzgemm.c:60
int HICMA_zgemm_Tile(MORSE_enum transA, MORSE_enum transB, double alpha, MORSE_desc_t *AUV, MORSE_desc_t *Ark, MORSE_desc_t *BUV, MORSE_desc_t *Brk, double beta, MORSE_desc_t *CUV, MORSE_desc_t *Crk, int rk, int maxrk, double acc)
Definition: zgemm.c:109
#define BUV(m, n)
Definition: pzgemm.c:61
#define CUV(m, n)
Definition: pzgemm.c:62
void hicma_pzgemm(MORSE_enum transA, MORSE_enum transB, double alpha, MORSE_desc_t *AUV, MORSE_desc_t *Ark, MORSE_desc_t *BUV, MORSE_desc_t *Brk, double beta, MORSE_desc_t *CUV, MORSE_desc_t *Crk, MORSE_sequence_t *sequence, MORSE_request_t *request, int rk, int maxrk, double acc)
Definition: pzgemm.c:69
int HICMA_zgemm_Tile_Async(MORSE_enum transA, MORSE_enum transB, double alpha, MORSE_desc_t *AUV, MORSE_desc_t *Ark, MORSE_desc_t *BUV, MORSE_desc_t *Brk, double beta, MORSE_desc_t *CUV, MORSE_desc_t *Crk, int rk, int maxrk, double acc, MORSE_sequence_t *sequence, MORSE_request_t *request)
Definition: zgemm.c:176