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
zlaset.c
Go to the documentation of this file.
1 
15 #include "common.h"
16 
17 /***************************************************************************/
63 int PLASMA_zlaset(PLASMA_enum uplo, int M, int N,
65  PLASMA_Complex64_t *A, int LDA)
66 {
67  int NB;
68  int status;
70  PLASMA_sequence *sequence = NULL;
72  PLASMA_desc descA;
73 
74  plasma = plasma_context_self();
75  if (plasma == NULL) {
76  plasma_fatal_error("PLASMA_zlaset", "PLASMA not initialized");
78  }
79  /* Check input arguments */
80  if ( (uplo != PlasmaUpperLower) &&
81  (uplo != PlasmaUpper) &&
82  (uplo != PlasmaLower) ) {
83  plasma_error("PLASMA_zlaset", "illegal value of uplo");
84  return -1;
85  }
86  if (M < 0) {
87  plasma_error("PLASMA_zlaset", "illegal value of M");
88  return -2;
89  }
90  if (N < 0) {
91  plasma_error("PLASMA_zlaset", "illegal value of N");
92  return -3;
93  }
94  if (LDA < max(1, M)) {
95  plasma_error("PLASMA_zlaset", "illegal value of LDA");
96  return -5;
97  }
98 
99  /* Quick return */
100  if (min(N, M) == 0)
101  return (double)0.0;
102 
103  /* Tune NB depending on M, N & NRHS; Set NBNB */
104  status = plasma_tune(PLASMA_FUNC_ZGEMM, M, N, 0);
105  if (status != PLASMA_SUCCESS) {
106  plasma_error("PLASMA_zlaset", "plasma_tune() failed");
107  return status;
108  }
109 
110  /* Set NT */
111  NB = PLASMA_NB;
112 
113  plasma_sequence_create(plasma, &sequence);
114 
116  plasma_zooplap2tile( descA, A, NB, NB, LDA, N, 0, 0, M, N, plasma_desc_mat_free(&(descA)) );
117  } else {
118  plasma_ziplap2tile( descA, A, NB, NB, LDA, N, 0, 0, M, N);
119  }
120 
121  /* Call the tile interface */
122  PLASMA_zlaset_Tile_Async(uplo, alpha, beta, &descA, sequence, &request);
123 
126  plasma_desc_mat_free(&descA);
127  } else {
128  plasma_ziptile2lap( descA, A, NB, NB, LDA, N );
130  }
131 
132  plasma_sequence_destroy(plasma, sequence);
133  return PLASMA_SUCCESS;
134 }
135 
136 /***************************************************************************/
174  PLASMA_desc *A)
175 {
177  PLASMA_sequence *sequence = NULL;
179 
180  plasma = plasma_context_self();
181  if (plasma == NULL) {
182  plasma_fatal_error("PLASMA_zlaset_Tile", "PLASMA not initialized");
184  }
185  plasma_sequence_create(plasma, &sequence);
186  PLASMA_zlaset_Tile_Async(uplo, alpha, beta, A, sequence, &request);
188  plasma_sequence_destroy(plasma, sequence);
189  return PLASMA_SUCCESS;
190 }
191 
192 /***************************************************************************/
220  PLASMA_desc *A,
221  PLASMA_sequence *sequence, PLASMA_request *request)
222 {
223  PLASMA_desc descA = *A;
225 
226  plasma = plasma_context_self();
227  if (plasma == NULL) {
228  plasma_fatal_error("PLASMA_zlaset_Tile_Async", "PLASMA not initialized");
230  }
231  if (sequence == NULL) {
232  plasma_fatal_error("PLASMA_zlaset_Tile_Async", "NULL sequence");
233  return PLASMA_ERR_UNALLOCATED;
234  }
235  if (request == NULL) {
236  plasma_fatal_error("PLASMA_zlaset_Tile_Async", "NULL request");
237  return PLASMA_ERR_UNALLOCATED;
238  }
239  /* Check sequence status */
240  if (sequence->status == PLASMA_SUCCESS)
241  request->status = PLASMA_SUCCESS;
242  else
243  return plasma_request_fail(sequence, request, PLASMA_ERR_SEQUENCE_FLUSHED);
244 
245  /* Check descriptors for correctness */
246  if (plasma_desc_check(&descA) != PLASMA_SUCCESS) {
247  plasma_error("PLASMA_zlaset_Tile_Async", "invalid descriptor");
248  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
249  }
250  /* Check input arguments */
251  if (descA.nb != descA.mb) {
252  plasma_error("PLASMA_zlaset_Tile_Async", "only square tiles supported");
253  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
254  }
255  /* Check input arguments */
256  if ( (uplo != PlasmaUpperLower) &&
257  (uplo != PlasmaUpper) &&
258  (uplo != PlasmaLower) ) {
259  plasma_error("PLASMA_zlaset_Tile_Async", "illegal value of uplo");
260  return -1;
261  }
262  /* Quick return */
263  if (min(descA.m, descA.n) == 0) {
264  return PLASMA_SUCCESS;
265  }
266 
267  plasma_dynamic_call_6(plasma_pzlaset,
268  PLASMA_enum, uplo,
269  PLASMA_Complex64_t, alpha,
270  PLASMA_Complex64_t, beta,
271  PLASMA_desc, descA,
272  PLASMA_sequence*, sequence,
273  PLASMA_request*, request);
274 
275  return PLASMA_SUCCESS;
276 }