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
dlacpy.c
Go to the documentation of this file.
1 
15 #include "common.h"
16 
17 /***************************************************************************/
62 int PLASMA_dlacpy(PLASMA_enum uplo, int M, int N,
63  double *A, int LDA,
64  double *B, int LDB)
65 {
66  int NB;
67  int status;
69  PLASMA_sequence *sequence = NULL;
71  PLASMA_desc descA, descB;
72 
73  plasma = plasma_context_self();
74  if (plasma == NULL) {
75  plasma_fatal_error("PLASMA_dlacpy", "PLASMA not initialized");
77  }
78  /* Check input arguments */
79  if ( (uplo != PlasmaUpperLower) &&
80  (uplo != PlasmaUpper) &&
81  (uplo != PlasmaLower) ) {
82  plasma_error("PLASMA_dlacpy", "illegal value of uplo");
83  return -1;
84  }
85  if (M < 0) {
86  plasma_error("PLASMA_dlacpy", "illegal value of M");
87  return -2;
88  }
89  if (N < 0) {
90  plasma_error("PLASMA_dlacpy", "illegal value of N");
91  return -3;
92  }
93  if (LDA < max(1, M)) {
94  plasma_error("PLASMA_dlacpy", "illegal value of LDA");
95  return -5;
96  }
97  if (LDB < max(1, M)) {
98  plasma_error("PLASMA_dlacpy", "illegal value of LDB");
99  return -7;
100  }
101 
102  /* Quick return */
103  if (min(N, M) == 0)
104  return (double)0.0;
105 
106  /* Tune NB depending on M, N & NRHS; Set NBNB */
107  status = plasma_tune(PLASMA_FUNC_DGEMM, M, N, 0);
108  if (status != PLASMA_SUCCESS) {
109  plasma_error("PLASMA_dlacpy", "plasma_tune() failed");
110  return status;
111  }
112 
113  /* Set NT */
114  NB = PLASMA_NB;
115 
116  plasma_sequence_create(plasma, &sequence);
117 
119  plasma_dooplap2tile( descA, A, NB, NB, LDA, N, 0, 0, M, N, plasma_desc_mat_free(&(descA)) );
120  plasma_dooplap2tile( descB, B, NB, NB, LDB, N, 0, 0, M, N, plasma_desc_mat_free(&(descA)); plasma_desc_mat_free(&(descB)) );
121  } else {
122  plasma_diplap2tile( descA, A, NB, NB, LDA, N, 0, 0, M, N);
123  plasma_diplap2tile( descB, B, NB, NB, LDA, N, 0, 0, M, N);
124  }
125 
126  /* Call the tile interface */
127  PLASMA_dlacpy_Tile_Async(uplo, &descA, &descB, sequence, &request);
128 
130  plasma_dooptile2lap( descB, B, NB, NB, LDB, N );
132  plasma_desc_mat_free(&descA);
133  plasma_desc_mat_free(&descB);
134  } else {
135  plasma_diptile2lap( descB, B, NB, NB, LDB, N );
137  }
138 
139  plasma_sequence_destroy(plasma, sequence);
140  return PLASMA_SUCCESS;
141 }
142 
143 /***************************************************************************/
184 {
186  PLASMA_sequence *sequence = NULL;
188 
189  plasma = plasma_context_self();
190  if (plasma == NULL) {
191  plasma_fatal_error("PLASMA_dlacpy_Tile", "PLASMA not initialized");
193  }
194  plasma_sequence_create(plasma, &sequence);
195  PLASMA_dlacpy_Tile_Async(uplo, A, B, sequence, &request);
197  plasma_sequence_destroy(plasma, sequence);
198  return PLASMA_SUCCESS;
199 }
200 
201 /***************************************************************************/
228  PLASMA_sequence *sequence, PLASMA_request *request)
229 {
230  PLASMA_desc descA = *A;
231  PLASMA_desc descB = *B;
233 
234  plasma = plasma_context_self();
235  if (plasma == NULL) {
236  plasma_fatal_error("PLASMA_dlacpy_Tile_Async", "PLASMA not initialized");
238  }
239  if (sequence == NULL) {
240  plasma_fatal_error("PLASMA_dlacpy_Tile_Async", "NULL sequence");
241  return PLASMA_ERR_UNALLOCATED;
242  }
243  if (request == NULL) {
244  plasma_fatal_error("PLASMA_dlacpy_Tile_Async", "NULL request");
245  return PLASMA_ERR_UNALLOCATED;
246  }
247  /* Check sequence status */
248  if (sequence->status == PLASMA_SUCCESS)
249  request->status = PLASMA_SUCCESS;
250  else
251  return plasma_request_fail(sequence, request, PLASMA_ERR_SEQUENCE_FLUSHED);
252 
253  /* Check descriptors for correctness */
254  if (plasma_desc_check(&descA) != PLASMA_SUCCESS) {
255  plasma_error("PLASMA_dlacpy_Tile_Async", "invalid descriptor");
256  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
257  }
258  /* Check input arguments */
259  if (descA.nb != descA.mb) {
260  plasma_error("PLASMA_dlacpy_Tile_Async", "only square tiles supported");
261  return plasma_request_fail(sequence, request, PLASMA_ERR_ILLEGAL_VALUE);
262  }
263  /* Check input arguments */
264  if ( (uplo != PlasmaUpperLower) &&
265  (uplo != PlasmaUpper) &&
266  (uplo != PlasmaLower) ) {
267  plasma_error("PLASMA_dlacpy_Tile_Async", "illegal value of uplo");
268  return -1;
269  }
270  /* Quick return */
271  if (min(descA.m, descA.n) == 0) {
272  return PLASMA_SUCCESS;
273  }
274 
276  PLASMA_enum, uplo,
277  PLASMA_desc, descA,
278  PLASMA_desc, descB,
279  PLASMA_sequence*, sequence,
280  PLASMA_request*, request);
281 
282  return PLASMA_SUCCESS;
283 }