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
cgetrs_incpiv.c
Go to the documentation of this file.
1 
15 #include "common.h"
16 
17 /***************************************************************************/
75 int PLASMA_cgetrs_incpiv(PLASMA_enum trans, int N, int NRHS,
76  PLASMA_Complex32_t *A, int LDA,
77  PLASMA_Complex32_t *L, int *IPIV,
78  PLASMA_Complex32_t *B, int LDB)
79 {
80  int NB, IB, IBNB, NT;
81  int status;
83  PLASMA_sequence *sequence = NULL;
85  PLASMA_desc descA, descB, descL;
86 
87  plasma = plasma_context_self();
88  if (plasma == NULL) {
89  plasma_fatal_error("PLASMA_cgetrs_incpiv", "PLASMA not initialized");
91  }
92  /* Check input arguments */
93  if (trans != PlasmaNoTrans) {
94  plasma_error("PLASMA_cgetrs_incpiv", "only PlasmaNoTrans supported");
96  }
97  if (N < 0) {
98  plasma_error("PLASMA_cgetrs_incpiv", "illegal value of N");
99  return -2;
100  }
101  if (NRHS < 0) {
102  plasma_error("PLASMA_cgetrs_incpiv", "illegal value of NRHS");
103  return -3;
104  }
105  if (LDA < max(1, N)) {
106  plasma_error("PLASMA_cgetrs_incpiv", "illegal value of LDA");
107  return -5;
108  }
109  if (LDB < max(1, N)) {
110  plasma_error("PLASMA_cgetrs_incpiv", "illegal value of LDB");
111  return -9;
112  }
113  /* Quick return */
114  if (min(N, NRHS) == 0)
115  return PLASMA_SUCCESS;
116 
117  /* Tune NB & IB depending on N & NRHS; Set NBNBSIZE */
118  status = plasma_tune(PLASMA_FUNC_CGESV, N, N, NRHS);
119  if (status != PLASMA_SUCCESS) {
120  plasma_error("PLASMA_cgetrs_incpiv", "plasma_tune() failed");
121  return status;
122  }
123 
124  /* Set NT & NTRHS */
125  NB = PLASMA_NB;
126  IB = PLASMA_IB;
127  IBNB = IB*NB;
128  NT = (N%NB==0) ? (N/NB) : (N/NB+1);
129 
130  plasma_sequence_create(plasma, &sequence);
131 
132  descL = plasma_desc_init(
134  IB, NB, IBNB,
135  NT*IB, NT*NB, 0, 0, NT*IB, NT*NB);
136  descL.mat = L;
137 
139  plasma_cooplap2tile( descA, A, NB, NB, LDA, N, 0, 0, N, N , plasma_desc_mat_free(&(descA)) );
140  plasma_cooplap2tile( descB, B, NB, NB, LDB, NRHS, 0, 0, N, NRHS, plasma_desc_mat_free(&(descA)); plasma_desc_mat_free(&(descB)));
141  } else {
142  plasma_ciplap2tile( descA, A, NB, NB, LDA, N, 0, 0, N, N );
143  plasma_ciplap2tile( descB, B, NB, NB, LDB, NRHS, 0, 0, N, NRHS);
144  }
145 
146  /* Call the tile interface */
147  PLASMA_cgetrs_incpiv_Tile_Async(&descA, &descL, IPIV, &descB, sequence, &request);
148 
150  plasma_cooptile2lap( descB, B, NB, NB, LDB, NRHS );
152  plasma_desc_mat_free(&descA);
153  plasma_desc_mat_free(&descB);
154  } else {
155  plasma_ciptile2lap( descA, A, NB, NB, LDA, N );
156  plasma_ciptile2lap( descB, B, NB, NB, LDB, NRHS );
158  }
159 
160  status = sequence->status;
161  plasma_sequence_destroy(plasma, sequence);
162  return status;
163 }
164 
165 /***************************************************************************/
207 {
209  PLASMA_sequence *sequence = NULL;
211  int status;
212 
213  plasma = plasma_context_self();
214  if (plasma == NULL) {
215  plasma_fatal_error("PLASMA_cgetrs_incpiv_Tile", "PLASMA not initialized");
217  }
218  plasma_sequence_create(plasma, &sequence);
219  PLASMA_cgetrs_incpiv_Tile_Async(A, L, IPIV, B, sequence, &request);
221  status = sequence->status;
222  plasma_sequence_destroy(plasma, sequence);
223  return status;
224 }
225 
226 /***************************************************************************/
256  PLASMA_sequence *sequence, PLASMA_request *request)
257 {
258  PLASMA_desc descA = *A;
259  PLASMA_desc descL = *L;
260  PLASMA_desc descB = *B;
262 
263  plasma = plasma_context_self();
264  if (plasma == NULL) {
265  plasma_fatal_error("PLASMA_cgetrs_incpiv_Tile", "PLASMA not initialized");
267  }
268  if (sequence == NULL) {
269  plasma_fatal_error("PLASMA_cgetrs_incpiv_Tile", "NULL sequence");
270  return PLASMA_ERR_UNALLOCATED;
271  }
272  if (request == NULL) {
273  plasma_fatal_error("PLASMA_cgetrs_incpiv_Tile", "NULL request");
274  return PLASMA_ERR_UNALLOCATED;
275  }
276  /* Check sequence status */
277  if (sequence->status == PLASMA_SUCCESS)
278  request->status = PLASMA_SUCCESS;
279  else
280  return plasma_request_fail(sequence, request, PLASMA_ERR_SEQUENCE_FLUSHED);
281 
282  /* Check descriptors for correctness */
283  if (plasma_desc_check(&descA) != PLASMA_SUCCESS) {
284  plasma_error("PLASMA_cgetrs_incpiv_Tile", "invalid first descriptor");
285  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
286  }
287  if (plasma_desc_check(&descL) != PLASMA_SUCCESS) {
288  plasma_error("PLASMA_cgetrs_incpiv_Tile", "invalid second descriptor");
289  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
290  }
291  if (plasma_desc_check(&descB) != PLASMA_SUCCESS) {
292  plasma_error("PLASMA_cgetrs_incpiv_Tile", "invalid third descriptor");
293  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
294  }
295  /* Check input arguments */
296  if (descA.nb != descA.mb || descB.nb != descB.mb) {
297  plasma_error("PLASMA_cgetrs_incpiv_Tile", "only square tiles supported");
298  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
299  }
300  /* Quick return */
301 /*
302  if (min(N, NRHS) == 0)
303  return PLASMA_SUCCESS;
304 */
306  PLASMA_desc, descA,
307  PLASMA_desc, descB,
308  PLASMA_desc, descL,
309  int*, IPIV,
310  PLASMA_sequence*, sequence,
311  PLASMA_request*, request);
312 
318  PLASMA_Complex32_t, 1.0,
319  PLASMA_desc, descA,
320  PLASMA_desc, descB,
321  PLASMA_sequence*, sequence,
322  PLASMA_request*, request);
323 
324  return PLASMA_SUCCESS;
325 }