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
zlaswp.c
Go to the documentation of this file.
1 
15 #include "common.h"
16 
17 /***************************************************************************/
66 int PLASMA_zlaswp(int N, PLASMA_Complex64_t *A, int LDA,
67  int K1, int K2, int *IPIV, int INCX)
68 {
69  int NB;
70  int status;
72  PLASMA_sequence *sequence = NULL;
74  PLASMA_desc descA;
75 
76  plasma = plasma_context_self();
77  if (plasma == NULL) {
78  plasma_fatal_error("PLASMA_zlaswp", "PLASMA not initialized");
80  }
81  /* Check input arguments */
82  if (N < 0) {
83  plasma_error("PLASMA_zlaswp", "illegal value of N");
84  return -1;
85  }
86  if (LDA < max(1, N)) {
87  plasma_error("PLASMA_zlaswp", "illegal value of LDA");
88  return -3;
89  }
90 
91  /* Quick return */
92  if ( N == 0 )
93  return PLASMA_SUCCESS;
94 
95  /* Tune NB & IB depending on N & NRHS; Set NBNBSIZE */
96  status = plasma_tune(PLASMA_FUNC_ZGESV, LDA, N, N);
97  if (status != PLASMA_SUCCESS) {
98  plasma_error("PLASMA_zlaswp", "plasma_tune() failed");
99  return status;
100  }
101 
102  /* Set NT & NTRHS */
103  NB = PLASMA_NB;
104 
105  plasma_sequence_create(plasma, &sequence);
106 
108  plasma_zooplap2tile( descA, A, NB, NB, LDA, N, 0, 0, K2, N, plasma_desc_mat_free(&(descA)) );
109  } else {
110  plasma_ziplap2tile( descA, A, NB, NB, LDA, N, 0, 0, K2, N);
111  }
112 
113  /* Call the tile interface */
114  PLASMA_zlaswp_Tile_Async(&descA, K1, K2, IPIV, INCX, sequence, &request);
115 
117  plasma_zooptile2lap( descA, A, NB, NB, LDA, N );
119  plasma_desc_mat_free(&descA);
120  } else {
121  plasma_ziptile2lap( descA, A, NB, NB, LDA, N );
123  }
124 
125  status = sequence->status;
126  plasma_sequence_destroy(plasma, sequence);
127  return status;
128 }
129 
130 /***************************************************************************/
176 int PLASMA_zlaswp_Tile(PLASMA_desc *A, int K1, int K2, int *IPIV, int INCX)
177 {
179  PLASMA_sequence *sequence = NULL;
181  int status;
182 
183  plasma = plasma_context_self();
184  if (plasma == NULL) {
185  plasma_fatal_error("PLASMA_zlaswp_Tile", "PLASMA not initialized");
187  }
188  plasma_sequence_create(plasma, &sequence);
189  PLASMA_zlaswp_Tile_Async(A, K1, K2, IPIV, INCX, sequence, &request);
191  status = sequence->status;
192  plasma_sequence_destroy(plasma, sequence);
193  return status;
194 }
195 
196 /***************************************************************************/
226 int PLASMA_zlaswp_Tile_Async(PLASMA_desc *A, int K1, int K2, int *IPIV, int INCX,
227  PLASMA_sequence *sequence, PLASMA_request *request)
228 {
229  PLASMA_desc descA = *A;
231 
232  plasma = plasma_context_self();
233  if (plasma == NULL) {
234  plasma_fatal_error("PLASMA_zlaswp_Tile", "PLASMA not initialized");
236  }
237  if (sequence == NULL) {
238  plasma_fatal_error("PLASMA_zlaswp_Tile", "NULL sequence");
239  return PLASMA_ERR_UNALLOCATED;
240  }
241  if (request == NULL) {
242  plasma_fatal_error("PLASMA_zlaswp_Tile", "NULL request");
243  return PLASMA_ERR_UNALLOCATED;
244  }
245  /* Check sequence status */
246  if (sequence->status == PLASMA_SUCCESS)
247  request->status = PLASMA_SUCCESS;
248  else
249  return plasma_request_fail(sequence, request, PLASMA_ERR_SEQUENCE_FLUSHED);
250 
251  /* Check descriptors for correctness */
252  if (plasma_desc_check(&descA) != PLASMA_SUCCESS) {
253  plasma_error("PLASMA_zlaswp_Tile", "invalid first descriptor");
254  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
255  }
256 
257  if ( (K1 != 1) || (K2 != descA.m) ) {
258  plasma_error("PLASMA_zlaswp_Tile", "invalid K1 or K2 (1..M is the only interval supported right now)");
259  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
260  }
261 
263  plasma_pzbarrier_tl2pnl,
264  PLASMA_desc, descA,
265  PLASMA_sequence*, sequence,
266  PLASMA_request*, request);
267 
268  /* swap */
270  plasma_pzlaswp,
271  PLASMA_desc, descA,
272  int *, IPIV,
273  int, INCX,
274  PLASMA_sequence*, sequence,
275  PLASMA_request*, request);
276 
278  plasma_pzbarrier_pnl2tl,
279  PLASMA_desc, descA,
280  PLASMA_sequence*, sequence,
281  PLASMA_request*, request);
282 
283  return PLASMA_SUCCESS;
284 }