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
zpotrs.c
Go to the documentation of this file.
1 
15 #include "common.h"
16 
17 /***************************************************************************/
67 int PLASMA_zpotrs(PLASMA_enum uplo, int N, int NRHS,
68  PLASMA_Complex64_t *A, int LDA,
69  PLASMA_Complex64_t *B, int LDB)
70 {
71  int NB;
72  int status;
74  PLASMA_sequence *sequence = NULL;
76  PLASMA_desc descA, descB;
77 
78  plasma = plasma_context_self();
79  if (plasma == NULL) {
80  plasma_fatal_error("PLASMA_zpotrs", "PLASMA not initialized");
82  }
83  /* Check input arguments */
84  if (uplo != PlasmaUpper && uplo != PlasmaLower) {
85  plasma_error("PLASMA_zpotrs", "illegal value of uplo");
86  return -1;
87  }
88  if (N < 0) {
89  plasma_error("PLASMA_zpotrs", "illegal value of N");
90  return -2;
91  }
92  if (NRHS < 0) {
93  plasma_error("PLASMA_zpotrs", "illegal value of NRHS");
94  return -3;
95  }
96  if (LDA < max(1, N)) {
97  plasma_error("PLASMA_zpotrs", "illegal value of LDA");
98  return -5;
99  }
100  if (LDB < max(1, N)) {
101  plasma_error("PLASMA_zpotrs", "illegal value of LDB");
102  return -7;
103  }
104  /* Quick return */
105  if (min(N, NRHS) == 0)
106  return PLASMA_SUCCESS;
107 
108  /* Tune NB depending on M, N & NRHS; Set NBNB */
109  status = plasma_tune(PLASMA_FUNC_ZPOSV, N, N, NRHS);
110  if (status != PLASMA_SUCCESS) {
111  plasma_error("PLASMA_zpotrs", "plasma_tune() failed");
112  return status;
113  }
114 
115  /* Set NT & NTRHS */
116  NB = PLASMA_NB;
117 
118  plasma_sequence_create(plasma, &sequence);
119 
121  plasma_zooplap2tile( descA, A, NB, NB, LDA, N, 0, 0, N, N , plasma_desc_mat_free(&(descA)) );
122  plasma_zooplap2tile( descB, B, NB, NB, LDB, NRHS, 0, 0, N, NRHS, plasma_desc_mat_free(&(descA)); plasma_desc_mat_free(&(descB)));
123  } else {
124  plasma_ziplap2tile( descA, A, NB, NB, LDA, N, 0, 0, N, N );
125  plasma_ziplap2tile( descB, B, NB, NB, LDB, NRHS, 0, 0, N, NRHS);
126  }
127 
128  /* Call the tile interface */
129  PLASMA_zpotrs_Tile_Async(uplo, &descA, &descB, sequence, &request);
130 
132  plasma_zooptile2lap( descB, B, NB, NB, LDB, NRHS );
134  plasma_desc_mat_free(&descA);
135  plasma_desc_mat_free(&descB);
136  } else {
137  plasma_ziptile2lap( descA, A, NB, NB, LDA, N );
138  plasma_ziptile2lap( descB, B, NB, NB, LDB, NRHS );
140  }
141 
142  status = sequence->status;
143  plasma_sequence_destroy(plasma, sequence);
144  return status;
145 }
146 
147 /***************************************************************************/
188 {
190  PLASMA_sequence *sequence = NULL;
192  int status;
193 
194  plasma = plasma_context_self();
195  if (plasma == NULL) {
196  plasma_fatal_error("PLASMA_zpotrs_Tile", "PLASMA not initialized");
198  }
199  plasma_sequence_create(plasma, &sequence);
200  PLASMA_zpotrs_Tile_Async(uplo, A, B, sequence, &request);
202  status = sequence->status;
203  plasma_sequence_destroy(plasma, sequence);
204  return status;
205 }
206 
207 /***************************************************************************/
237  PLASMA_sequence *sequence, PLASMA_request *request)
238 {
239  PLASMA_desc descA = *A;
240  PLASMA_desc descB = *B;
242 
243  plasma = plasma_context_self();
244  if (plasma == NULL) {
245  plasma_fatal_error("PLASMA_zpotrs_Tile", "PLASMA not initialized");
247  }
248  if (sequence == NULL) {
249  plasma_fatal_error("PLASMA_zpotrs_Tile", "NULL sequence");
250  return PLASMA_ERR_UNALLOCATED;
251  }
252  if (request == NULL) {
253  plasma_fatal_error("PLASMA_zpotrs_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_zpotrs_Tile", "invalid first descriptor");
265  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
266  }
267  if (plasma_desc_check(&descB) != PLASMA_SUCCESS) {
268  plasma_error("PLASMA_zpotrs_Tile", "invalid second descriptor");
269  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
270  }
271  /* Check input arguments */
272  if (descA.nb != descA.mb || descB.nb != descB.mb) {
273  plasma_error("PLASMA_zpotrs_Tile", "only square tiles supported");
274  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
275  }
276  if (uplo != PlasmaUpper && uplo != PlasmaLower) {
277  plasma_error("PLASMA_zpotrs_Tile", "illegal value of uplo");
278  return plasma_request_fail(sequence, request, -1);
279  }
280  /* Quick return */
281 /*
282  if (min(N, NRHS) == 0)
283  return PLASMA_SUCCESS;
284 */
287  PLASMA_enum, uplo,
290  PLASMA_Complex64_t, 1.0,
291  PLASMA_desc, descA,
292  PLASMA_desc, descB,
293  PLASMA_sequence*, sequence,
294  PLASMA_request*, request);
295 
298  PLASMA_enum, uplo,
299  PLASMA_enum, uplo == PlasmaUpper ? PlasmaNoTrans : PlasmaConjTrans,
301  PLASMA_Complex64_t, 1.0,
302  PLASMA_desc, descA,
303  PLASMA_desc, descB,
304  PLASMA_sequence*, sequence,
305  PLASMA_request*, request);
306 
307  return PLASMA_SUCCESS;
308 }