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
sgelqf.c
Go to the documentation of this file.
1 
16 #include "common.h"
17 
18 /***************************************************************************/
62 int PLASMA_sgelqf(int M, int N,
63  float *A, int LDA,
64  float *T)
65 {
66  int NB, IB, IBNB, MT, NT;
67  int status;
69  PLASMA_sequence *sequence = NULL;
71  PLASMA_desc descA, descT;
72 
73  plasma = plasma_context_self();
74  if (plasma == NULL) {
75  plasma_fatal_error("PLASMA_sgelqf", "PLASMA not initialized");
77  }
78  /* Check input arguments */
79  if (M < 0) {
80  plasma_error("PLASMA_sgelqf", "illegal value of M");
81  return -1;
82  }
83  if (N < 0) {
84  plasma_error("PLASMA_sgelqf", "illegal value of N");
85  return -2;
86  }
87  if (LDA < max(1, M)) {
88  plasma_error("PLASMA_sgelqf", "illegal value of LDA");
89  return -4;
90  }
91  /* Quick return */
92  if (min(M, N) == 0)
93  return PLASMA_SUCCESS;
94 
95  /* Tune NB & IB depending on M, N & NRHS; Set NBNBSIZE */
96  status = plasma_tune(PLASMA_FUNC_SGELS, M, N, 0);
97  if (status != PLASMA_SUCCESS) {
98  plasma_error("PLASMA_sgelqf", "plasma_tune() failed");
99  return status;
100  }
101 
102  /* Set MT & NT */
103  NB = PLASMA_NB;
104  IB = PLASMA_IB;
105  IBNB = IB*NB;
106  MT = (M%NB==0) ? (M/NB) : (M/NB+1);
107  NT = (N%NB==0) ? (N/NB) : (N/NB+1);
108 
109  plasma_sequence_create(plasma, &sequence);
110 
111  if (plasma->householder == PLASMA_FLAT_HOUSEHOLDER) {
112  descT = plasma_desc_init(
114  IB, NB, IBNB,
115  MT*IB, NT*NB, 0, 0, MT*IB, NT*NB);
116  }
117  else {
118  /* Double the size of T to accomodate the tree reduction phase */
119  descT = plasma_desc_init(
121  IB, NB, IBNB,
122  MT*IB, 2*NT*NB, 0, 0, MT*IB, 2*NT*NB);
123  }
124  descT.mat = T;
125 
127  plasma_sooplap2tile( descA, A, NB, NB, LDA, N, 0, 0, M, N, plasma_desc_mat_free(&(descA)) );
128  } else {
129  plasma_siplap2tile( descA, A, NB, NB, LDA, N, 0, 0, M, N);
130  }
131 
132  /* Call the tile interface */
133  PLASMA_sgelqf_Tile_Async(&descA, &descT, sequence, &request);
134 
136  plasma_sooptile2lap( descA, A, NB, NB, LDA, N );
138  plasma_desc_mat_free(&descA);
139  } else {
140  plasma_siptile2lap( descA, A, NB, NB, LDA, N );
142  }
143 
144  status = sequence->status;
145  plasma_sequence_destroy(plasma, sequence);
146  return status;
147 }
148 
149 /***************************************************************************/
188 {
190  PLASMA_sequence *sequence = NULL;
192  int status;
193 
194  plasma = plasma_context_self();
195  if (plasma == NULL) {
196  plasma_fatal_error("PLASMA_sgelqf_Tile", "PLASMA not initialized");
198  }
199  plasma_sequence_create(plasma, &sequence);
200  PLASMA_sgelqf_Tile_Async(A, T, sequence, &request);
202  status = sequence->status;
203  plasma_sequence_destroy(plasma, sequence);
204  return status;
205 }
206 
207 /***************************************************************************/
236  PLASMA_sequence *sequence, PLASMA_request *request)
237 {
238  PLASMA_desc descA = *A;
239  PLASMA_desc descT = *T;
241 
242  plasma = plasma_context_self();
243  if (plasma == NULL) {
244  plasma_fatal_error("PLASMA_sgelqf_Tile", "PLASMA not initialized");
246  }
247  if (sequence == NULL) {
248  plasma_fatal_error("PLASMA_sgelqf_Tile", "NULL sequence");
249  return PLASMA_ERR_UNALLOCATED;
250  }
251  if (request == NULL) {
252  plasma_fatal_error("PLASMA_sgelqf_Tile", "NULL request");
253  return PLASMA_ERR_UNALLOCATED;
254  }
255  /* Check sequence status */
256  if (sequence->status == PLASMA_SUCCESS)
257  request->status = PLASMA_SUCCESS;
258  else
259  return plasma_request_fail(sequence, request, PLASMA_ERR_SEQUENCE_FLUSHED);
260 
261  /* Check descriptors for correctness */
262  if (plasma_desc_check(&descA) != PLASMA_SUCCESS) {
263  plasma_error("PLASMA_sgelqf_Tile", "invalid first descriptor");
264  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
265  }
266  if (plasma_desc_check(&descT) != PLASMA_SUCCESS) {
267  plasma_error("PLASMA_sgelqf_Tile", "invalid second descriptor");
268  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
269  }
270  /* Check input arguments */
271  if (descA.nb != descA.mb) {
272  plasma_error("PLASMA_sgelqf_Tile", "only square tiles supported");
273  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
274  }
275  /* Quick return */
276 /*
277  if (min(M, N) == 0)
278  return PLASMA_SUCCESS;
279 */
280  if (plasma->householder == PLASMA_FLAT_HOUSEHOLDER) {
282  PLASMA_desc, descA,
283  PLASMA_desc, descT,
284  PLASMA_sequence*, sequence,
285  PLASMA_request*, request);
286  }
287  else {
288  plasma_dynamic_call_5(plasma_psgelqfrh,
289  PLASMA_desc, descA,
290  PLASMA_desc, descT,
292  PLASMA_sequence*, sequence,
293  PLASMA_request*, request);
294  }
295 
296  return PLASMA_SUCCESS;
297 }