PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
zlange.c
Go to the documentation of this file.
1 
15 #include "common.h"
16 
17 /***************************************************************************/
78 double PLASMA_zlange(PLASMA_enum norm, int M, int N,
79  PLASMA_Complex64_t *A, int LDA, double *work)
80 {
81  int NB;
82  int status;
83  double value;
85  PLASMA_sequence *sequence = NULL;
87  PLASMA_desc descA;
88 
89  plasma = plasma_context_self();
90  if (plasma == NULL) {
91  plasma_fatal_error("PLASMA_zlange", "PLASMA not initialized");
93  }
94  /* Check input arguments */
95  if ( (norm != PlasmaMaxNorm) && (norm != PlasmaOneNorm)
96  && (norm != PlasmaInfNorm) && (norm != PlasmaFrobeniusNorm) ) {
97  plasma_error("PLASMA_zlange", "illegal value of norm");
98  return -1;
99  }
100  if (M < 0) {
101  plasma_error("PLASMA_zlange", "illegal value of M");
102  return -2;
103  }
104  if (N < 0) {
105  plasma_error("PLASMA_zlange", "illegal value of N");
106  return -3;
107  }
108  if (LDA < max(1, M)) {
109  plasma_error("PLASMA_zlange", "illegal value of LDA");
110  return -5;
111  }
112 
113  /* Quick return */
114  if (min(N, M) == 0)
115  return (double)0.0;
116 
117  /* Tune NB depending on M, N & NRHS; Set NBNB */
118  status = plasma_tune(PLASMA_FUNC_ZGEMM, M, N, 0);
119  if (status != PLASMA_SUCCESS) {
120  plasma_error("PLASMA_zlange", "plasma_tune() failed");
121  return status;
122  }
123 
124  /* Set NT */
125  NB = PLASMA_NB;
126 
127  plasma_sequence_create(plasma, &sequence);
128 
130  plasma_zooplap2tile( descA, A, NB, NB, LDA, N, 0, 0, M, N, plasma_desc_mat_free(&(descA)) );
131  } else {
132  plasma_ziplap2tile( descA, A, NB, NB, LDA, N, 0, 0, M, N);
133  }
134 
135  /* Call the tile interface */
136  PLASMA_zlange_Tile_Async(norm, &descA, work, &value, sequence, &request);
137 
140  plasma_desc_mat_free(&descA);
141  } else {
142  plasma_ziptile2lap( descA, A, NB, NB, LDA, N );
144  }
145 
146  plasma_sequence_destroy(plasma, sequence);
147  return value;
148 }
149 
150 /***************************************************************************/
194 {
196  PLASMA_sequence *sequence = NULL;
198  double value;
199 
200  plasma = plasma_context_self();
201  if (plasma == NULL) {
202  plasma_fatal_error("PLASMA_zlange_Tile", "PLASMA not initialized");
204  }
205  plasma_sequence_create(plasma, &sequence);
206  PLASMA_zlange_Tile_Async(norm, A, work, &value, sequence, &request);
208  plasma_sequence_destroy(plasma, sequence);
209  return value;
210 }
211 
212 /***************************************************************************/
238 int PLASMA_zlange_Tile_Async(PLASMA_enum norm, PLASMA_desc *A, double *work, double *value,
239  PLASMA_sequence *sequence, PLASMA_request *request)
240 {
241  PLASMA_desc descA = *A;
243 
244  plasma = plasma_context_self();
245  if (plasma == NULL) {
246  plasma_fatal_error("PLASMA_zlange_Tile", "PLASMA not initialized");
248  }
249  if (sequence == NULL) {
250  plasma_fatal_error("PLASMA_zlange_Tile", "NULL sequence");
251  return PLASMA_ERR_UNALLOCATED;
252  }
253  if (request == NULL) {
254  plasma_fatal_error("PLASMA_zlange_Tile", "NULL request");
255  return PLASMA_ERR_UNALLOCATED;
256  }
257  /* Check sequence status */
258  if (sequence->status == PLASMA_SUCCESS)
259  request->status = PLASMA_SUCCESS;
260  else
261  return plasma_request_fail(sequence, request, PLASMA_ERR_SEQUENCE_FLUSHED);
262 
263  /* Check descriptors for correctness */
264  if (plasma_desc_check(&descA) != PLASMA_SUCCESS) {
265  plasma_error("PLASMA_zlange_Tile", "invalid descriptor");
266  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
267  }
268  /* Check input arguments */
269  if (descA.nb != descA.mb) {
270  plasma_error("PLASMA_zlange_Tile", "only square tiles supported");
271  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
272  }
273  if ( (norm != PlasmaMaxNorm) && (norm != PlasmaOneNorm)
274  && (norm != PlasmaInfNorm) && (norm != PlasmaFrobeniusNorm) ) {
275  plasma_error("PLASMA_zlange", "illegal value of norm");
276  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
277  }
278  /* Quick return */
279  if (min(descA.m, descA.n) == 0) {
280  *value = 0.0;
281  return PLASMA_SUCCESS;
282  }
283 
285  PLASMA_enum, norm,
286  PLASMA_desc, descA,
287  double*, work,
288  double*, value,
289  PLASMA_sequence*, sequence,
290  PLASMA_request*, request);
291 
292  return PLASMA_SUCCESS;
293 }