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
zgeqrf.c
Go to the documentation of this file.
1 
15 #include "common.h"
16 
17 /***************************************************************************/
61 int PLASMA_zgeqrf(int M, int N,
62  PLASMA_Complex64_t *A, int LDA,
64 {
65  int NB, IB, IBNB, MT, NT;
66  int status;
68  PLASMA_sequence *sequence = NULL;
70  PLASMA_desc descA, descT;
71 
72  plasma = plasma_context_self();
73  if (plasma == NULL) {
74  plasma_fatal_error("PLASMA_zgeqrf", "PLASMA not initialized");
76  }
77  /* Check input arguments */
78  if (M < 0) {
79  plasma_error("PLASMA_zgeqrf", "illegal value of M");
80  return -1;
81  }
82  if (N < 0) {
83  plasma_error("PLASMA_zgeqrf", "illegal value of N");
84  return -2;
85  }
86  if (LDA < max(1, M)) {
87  plasma_error("PLASMA_zgeqrf", "illegal value of LDA");
88  return -4;
89  }
90  /* Quick return */
91  if (min(M, N) == 0)
92  return PLASMA_SUCCESS;
93 
94  /* Tune NB & IB depending on M, N & NRHS; Set NBNBSIZE */
95  status = plasma_tune(PLASMA_FUNC_ZGELS, M, N, 0);
96  if (status != PLASMA_SUCCESS) {
97  plasma_error("PLASMA_zgeqrf", "plasma_tune() failed");
98  return status;
99  }
100 
101  /* Set MT & NT */
102  NB = PLASMA_NB;
103  IB = PLASMA_IB;
104  IBNB = IB*NB;
105  MT = (M%NB==0) ? (M/NB) : (M/NB+1);
106  NT = (N%NB==0) ? (N/NB) : (N/NB+1);
107 
108  plasma_sequence_create(plasma, &sequence);
109 
110  if (plasma->householder == PLASMA_FLAT_HOUSEHOLDER) {
111  descT = plasma_desc_init(
113  IB, NB, IBNB,
114  MT*IB, NT*NB, 0, 0, MT*IB, NT*NB);
115  }
116  else {
117  /* Double the size of T to accomodate the tree reduction phase */
118  descT = plasma_desc_init(
120  IB, NB, IBNB,
121  MT*IB, 2*NT*NB, 0, 0, MT*IB, 2*NT*NB);
122  }
123  descT.mat = T;
124 
126  plasma_zooplap2tile( descA, A, NB, NB, LDA, N, 0, 0, M, N, plasma_desc_mat_free(&(descA)) );
127  } else {
128  plasma_ziplap2tile( descA, A, NB, NB, LDA, N, 0, 0, M, N);
129  }
130 
131  /* Call the tile interface */
132  PLASMA_zgeqrf_Tile_Async(&descA, &descT, sequence, &request);
133 
135  plasma_zooptile2lap( descA, A, NB, NB, LDA, N );
137  plasma_desc_mat_free(&descA);
138  } else {
139  plasma_ziptile2lap( descA, A, NB, NB, LDA, N );
141  }
142 
143  status = sequence->status;
144  plasma_sequence_destroy(plasma, sequence);
145  return status;
146 }
147 
148 /***************************************************************************/
187 {
189  PLASMA_sequence *sequence = NULL;
191  int status;
192 
193  plasma = plasma_context_self();
194  if (plasma == NULL) {
195  plasma_fatal_error("PLASMA_zgeqrf_Tile", "PLASMA not initialized");
197  }
198  plasma_sequence_create(plasma, &sequence);
199  PLASMA_zgeqrf_Tile_Async(A, T, sequence, &request);
201  status = sequence->status;
202  plasma_sequence_destroy(plasma, sequence);
203  return status;
204 }
205 
206 /***************************************************************************/
235  PLASMA_sequence *sequence, PLASMA_request *request)
236 {
237  PLASMA_desc descA = *A;
238  PLASMA_desc descT = *T;
240 
241  plasma = plasma_context_self();
242  if (plasma == NULL) {
243  plasma_error("PLASMA_zgeqrf_Tile", "PLASMA not initialized");
245  }
246  if (sequence == NULL) {
247  plasma_fatal_error("PLASMA_zgeqrf_Tile", "NULL sequence");
248  return PLASMA_ERR_UNALLOCATED;
249  }
250  if (request == NULL) {
251  plasma_fatal_error("PLASMA_zgeqrf_Tile", "NULL request");
252  return PLASMA_ERR_UNALLOCATED;
253  }
254  /* Check sequence status */
255  if (sequence->status == PLASMA_SUCCESS)
256  request->status = PLASMA_SUCCESS;
257  else
258  return plasma_request_fail(sequence, request, PLASMA_ERR_SEQUENCE_FLUSHED);
259 
260  /* Check descriptors for correctness */
261  if (plasma_desc_check(&descA) != PLASMA_SUCCESS) {
262  plasma_error("PLASMA_zgeqrf_Tile", "invalid first descriptor");
263  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
264  }
265  if (plasma_desc_check(&descT) != PLASMA_SUCCESS) {
266  plasma_error("PLASMA_zgeqrf_Tile", "invalid second descriptor");
267  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
268  }
269  /* Check input arguments */
270  if (descA.nb != descA.mb) {
271  plasma_error("PLASMA_zgeqrf_Tile", "only square tiles supported");
272  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
273  }
274  /* Quick return */
275 /*
276  if (min(M, N) == 0)
277  return PLASMA_SUCCESS;
278 */
279  if (plasma->householder == PLASMA_FLAT_HOUSEHOLDER) {
281  PLASMA_desc, descA,
282  PLASMA_desc, descT,
283  PLASMA_sequence*, sequence,
284  PLASMA_request*, request);
285  }
286  else {
287  plasma_dynamic_call_5(plasma_pzgeqrfrh,
288  PLASMA_desc, descA,
289  PLASMA_desc, descT,
291  PLASMA_sequence*, sequence,
292  PLASMA_request*, request);
293  }
294 
295  return PLASMA_SUCCESS;
296 }