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
zgetrf.c
Go to the documentation of this file.
1 
17 #include "common.h"
18 
19 /***************************************************************************/
62 int PLASMA_zgetrf(int M, int N,
63  PLASMA_Complex64_t *A, int LDA,
64  int *IPIV)
65 {
66  int NB, NBNB, minMN;
67  int status;
68  PLASMA_desc descA ;
70  PLASMA_sequence *sequence = NULL;
72 
73  plasma = plasma_context_self();
74  if (plasma == NULL) {
75  plasma_fatal_error("PLASMA_zgetrf", "PLASMA not initialized");
77  }
78  /* Check input arguments */
79  if (M < 0) {
80  plasma_error("PLASMA_zgetrf", "illegal value of M");
81  return -1;
82  }
83  if (N < 0) {
84  plasma_error("PLASMA_zgetrf", "illegal value of N");
85  return -2;
86  }
87  if (LDA < max(1, M)) {
88  plasma_error("PLASMA_zgetrf", "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_ZGESV, M, N, 0);
97  if (status != PLASMA_SUCCESS) {
98  plasma_error("PLASMA_zgetrf", "plasma_tune() failed");
99  return status;
100  }
101 
102  /* Set NT & NTRHS */
103  NB = PLASMA_NB;
104  NBNB = NB*NB;
105 
106  plasma_sequence_create(plasma, &sequence);
107 
108  descA = plasma_desc_init(
110  NB, NB, NBNB,
111  LDA, N, 0, 0, M, N);
112  descA.mat = A;
113 
114  minMN = min(M, N);
115  memset(IPIV, 0, minMN*sizeof(int));
116 
117  /* Call the tile interface */
118  plasma_dynamic_call_4(plasma_pzgetrf_reclap,
119  PLASMA_desc, descA,
120  int*, IPIV,
121  PLASMA_sequence*, sequence,
122  PLASMA_request*, &request);
123 
125 
126  /*
127  * Generate the correct IPIV (Has to be moved in a task)
128  */
129  {
130  int i, inc, tmp, j;
131  for(i=1; i<descA.mt; i++) {
132  inc = i*descA.mb;
133  tmp = min( minMN - inc, descA.mb);
134  if ( tmp < 1 )
135  break;
136 
137  for (j=0; j<tmp; j++)
138  IPIV[inc+j] = IPIV[inc+j] + inc;
139  }
140  }
141 
142  status = sequence->status;
143  plasma_sequence_destroy(plasma, sequence);
144 
145  return status;
146 }
147 
148 /***************************************************************************/
190 {
192  PLASMA_sequence *sequence = NULL;
194  int status;
195 
196  plasma = plasma_context_self();
197  if (plasma == NULL) {
198  plasma_fatal_error("PLASMA_zgetrf_Tile", "PLASMA not initialized");
200  }
201  plasma_sequence_create(plasma, &sequence);
202  PLASMA_zgetrf_Tile_Async(A, IPIV, sequence, &request);
204  status = sequence->status;
205  plasma_sequence_destroy(plasma, sequence);
206  return status;
207 }
208 
209 /***************************************************************************/
238  PLASMA_sequence *sequence, PLASMA_request *request)
239 {
240  PLASMA_desc descA = *A;
242 
243  plasma = plasma_context_self();
244  if (plasma == NULL) {
245  plasma_fatal_error("PLASMA_zgetrf_Tile", "PLASMA not initialized");
247  }
248  if (sequence == NULL) {
249  plasma_fatal_error("PLASMA_zgetrf_Tile", "NULL sequence");
250  return PLASMA_ERR_UNALLOCATED;
251  }
252  if (request == NULL) {
253  plasma_fatal_error("PLASMA_zgetrf_Tile", "NULL request");
254  return PLASMA_ERR_UNALLOCATED;
255  }
256  /* Check sequence status */
257  if (sequence->status == PLASMA_SUCCESS)
258  request->status = PLASMA_SUCCESS;
259  else
260  return plasma_request_fail(sequence, request, PLASMA_ERR_SEQUENCE_FLUSHED);
261 
262  /* Check descriptors for correctness */
263  if (plasma_desc_check(&descA) != PLASMA_SUCCESS) {
264  plasma_error("PLASMA_zgetrf_Tile", "invalid first descriptor");
265  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
266  }
267  /* Check input arguments */
268  if (descA.nb != descA.mb) {
269  plasma_error("PLASMA_zgetrf_Tile", "only square tiles supported");
270  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
271  }
272  /* Quick return */
273 /*
274  if (min(M, N) == 0)
275  return PLASMA_SUCCESS;
276 */
277 
279  plasma_pzbarrier_tl2pnl,
280  PLASMA_desc, descA,
281  PLASMA_sequence*, sequence,
282  PLASMA_request*, request);
283 
284  plasma_dynamic_call_4(plasma_pzgetrf_rectil,
285  PLASMA_desc, descA,
286  int*, IPIV,
287  PLASMA_sequence*, sequence,
288  PLASMA_request*, request);
289 
291  plasma_pzbarrier_pnl2tl,
292  PLASMA_desc, descA,
293  PLASMA_sequence*, sequence,
294  PLASMA_request*, request);
295 
296  return PLASMA_SUCCESS;
297 }