zlascal.c 8.58 KB
 Mathieu Faverge committed Nov 30, 2016 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 /** * * @file zlascal.c * * MORSE computational routines * MORSE is a software package provided by Univ. of Tennessee, * Univ. of California Berkeley and Univ. of Colorado Denver * * @version 2.8.0 * @author Dalal Sukkari * @date 2010-11-15 * @precisions normal z -> s d c * **/ #include "control/common.h"  Mathieu Faverge committed Jan 15, 2018 17 18 /** ********************************************************************************  Mathieu Faverge committed Nov 30, 2016 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65  * * @ingroup MORSE_Complex64_t * * MORSE_zlascal - Scales a matrix by the scalar alpha as in * ScaLAPACK pzlascal(). * * \f[ A = \alpha A \f], * * alpha is a scalar, and A a general, upper or lower trapezoidal matrix. * ******************************************************************************* * * @param[in] uplo * Specifies the shape of A: * = MorseUpperLower: A is a general matrix. * = MorseUpper: A is an upper trapezoidal matrix. * = MorseLower: A is a lower trapezoidal matrix. * * @param[in] M * M specifies the number of rows of the matrix A. M >= 0. * * @param[in] N * N specifies the number of columns of the matrix A. N >= 0. * * @param[in] alpha * alpha specifies the scalar alpha * * @param[in,out] A * A is a LDA-by-N matrix. * * @param[in] LDA * The leading dimension of the array A. LDA >= max(1,M). * ******************************************************************************* * * @return * \retval MORSE_SUCCESS successful exit * ******************************************************************************* * * @sa MORSE_zlascal_Tile * @sa MORSE_clascal * @sa MORSE_dlascal * @sa MORSE_slascal * ******************************************************************************/ int MORSE_zlascal(MORSE_enum uplo, int M, int N,  Mathieu Faverge committed Jan 22, 2018 66  MORSE_Complex64_t alpha, MORSE_Complex64_t *A, int LDA)  Mathieu Faverge committed Nov 30, 2016 67 68 69 { int NB; int status;  Mathieu Faverge committed Jan 22, 2018 70  MORSE_desc_t descAl, descAt;  Mathieu Faverge committed Nov 30, 2016 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93  MORSE_context_t *morse; MORSE_sequence_t *sequence = NULL; MORSE_request_t request = MORSE_REQUEST_INITIALIZER; morse = morse_context_self(); if (morse == NULL) { morse_fatal_error("MORSE_zlascal", "MORSE not initialized"); return MORSE_ERR_NOT_INITIALIZED; } /* Check input arguments */ if (uplo != MorseUpper && uplo != MorseLower && uplo != MorseUpperLower) { morse_error("MORSE_zlascal", "illegal value of uplo"); return -1; } if (M < 0) { morse_error("MORSE_zlascal", "illegal value of M"); return -2; } if (N < 0) { morse_error("MORSE_zlascal", "illegal value of N"); return -3; }  94  if (LDA < chameleon_max(1, M)) {  Mathieu Faverge committed Nov 30, 2016 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115  morse_error("MORSE_zlascal", "illegal value of LDA"); return -6; } /* Quick return */ if (M == 0 || N == 0 || (alpha == (MORSE_Complex64_t)1.0)) return MORSE_SUCCESS; /* Tune NB depending on M, N & NRHS; Set NBNBSIZE */ status = morse_tune(MORSE_FUNC_ZGEMM, M, N, 0); if (status != MORSE_SUCCESS) { morse_error("MORSE_zlascal", "morse_tune() failed"); return status; } /* Set MT & NT & KT */ NB = MORSE_NB; morse_sequence_create(morse, &sequence);  Mathieu Faverge committed Jan 22, 2018 116  /* Submit the matrix conversion */  Mathieu Faverge committed Jan 22, 2018 117 118  morse_zlap2tile( morse, &descAl, &descAt, MorseUpperLower, A, NB, NB, LDA, N, M, N, sequence, &request );  Mathieu Faverge committed Nov 30, 2016 119 120 121 122 123  /* Call the tile interface */ MORSE_zlascal_Tile_Async( uplo, alpha, &descA, sequence, &request);  Mathieu Faverge committed Jan 22, 2018 124  /* Submit the matrix conversion back */  Mathieu Faverge committed Jan 22, 2018 125 126  morse_ztile2lap( morse, &descAl, &descAt, MorseUpperLower, sequence, &request );  Mathieu Faverge committed Jan 22, 2018 127  RUNTIME_sequence_wait(morse, sequence);  Mathieu Faverge committed Jan 22, 2018 128  morse_ztile2lap_cleanup( morse, &descAl, &descAt );  Mathieu Faverge committed Nov 30, 2016 129 130 131 132 133 134  status = sequence->status; morse_sequence_destroy(morse, sequence); return status; }  Mathieu Faverge committed Jan 15, 2018 135 136 /** ********************************************************************************  Mathieu Faverge committed Nov 30, 2016 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175  * * @ingroup MORSE_Complex64_t_Tile * * MORSE_zlascal_Tile - Scales a matrix by the scalar alpha as in * ScaLAPACK pzlascal(). * * \f[ A = \alpha A \f], * * alpha is a scalar, and A a general, upper or lower trapezoidal matrix. * ******************************************************************************* * * @param[in] uplo * Specifies the shape of A: * = MorseUpperLower: A is a general matrix. * = MorseUpper: A is an upper trapezoidal matrix. * = MorseLower: A is a lower trapezoidal matrix. * * @param[in] alpha * alpha specifies the scalar alpha * * @param[in] A * A is a LDA-by-N matrix. * ******************************************************************************* * * @return * \retval MORSE_SUCCESS successful exit * ******************************************************************************* * * @sa MORSE_zlascal * @sa MORSE_zlascal_Tile_Async * @sa MORSE_clascal_Tile * @sa MORSE_dlascal_Tile * @sa MORSE_slascal_Tile * ******************************************************************************/ int MORSE_zlascal_Tile(MORSE_enum uplo,  Mathieu Faverge committed Jan 22, 2018 176  MORSE_Complex64_t alpha, MORSE_desc_t *A)  Mathieu Faverge committed Nov 30, 2016 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 { MORSE_context_t *morse; MORSE_sequence_t *sequence = NULL; MORSE_request_t request = MORSE_REQUEST_INITIALIZER; int status; morse = morse_context_self(); if (morse == NULL) { morse_fatal_error("MORSE_zlascal_Tile", "MORSE not initialized"); return MORSE_ERR_NOT_INITIALIZED; } morse_sequence_create(morse, &sequence); MORSE_zlascal_Tile_Async(uplo, alpha, A, sequence, &request); RUNTIME_sequence_wait(morse, sequence); status = sequence->status; morse_sequence_destroy(morse, sequence); return status; }  Mathieu Faverge committed Jan 15, 2018 196 197 /** ********************************************************************************  Mathieu Faverge committed Nov 30, 2016 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225  * * @ingroup MORSE_Complex64_t_Tile_Async * * MORSE_zlascal_Tile_Async - Scales a matrix by the scalar alpha as in * ScaLAPACK pzlascal(). * Non-blocking equivalent of MORSE_zlascal_Tile(). * May return before the computation is finished. * Allows for pipelining of operations at runtime. * ******************************************************************************* * * @param[in] sequence * Identifies the sequence of function calls that this call belongs to * (for completion checks and exception handling purposes). * * @param[out] request * Identifies this function call (for exception handling purposes). * ******************************************************************************* * * @sa MORSE_zlascal * @sa MORSE_zlascal_Tile * @sa MORSE_clascal_Tile_Async * @sa MORSE_dlascal_Tile_Async * @sa MORSE_slascal_Tile_Async * ******************************************************************************/ int MORSE_zlascal_Tile_Async(MORSE_enum uplo,  Mathieu Faverge committed Jan 22, 2018 226 227  MORSE_Complex64_t alpha, MORSE_desc_t *A, MORSE_sequence_t *sequence, MORSE_request_t *request)  Mathieu Faverge committed Nov 30, 2016 228 229 { MORSE_context_t *morse;  Mathieu Faverge committed Jan 22, 2018 230  MORSE_desc_t descAl, descAt;  Mathieu Faverge committed Nov 30, 2016 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277  morse = morse_context_self(); if (morse == NULL) { morse_fatal_error("MORSE_zlascal_Tile_Async", "MORSE not initialized"); return MORSE_ERR_NOT_INITIALIZED; } if (sequence == NULL) { morse_fatal_error("MORSE_zlascal_Tile_Async", "NULL sequence"); return MORSE_ERR_UNALLOCATED; } if (request == NULL) { morse_fatal_error("MORSE_zlascal_Tile_Async", "NULL request"); return MORSE_ERR_UNALLOCATED; } /* Check sequence status */ if (sequence->status == MORSE_SUCCESS) request->status = MORSE_SUCCESS; else return morse_request_fail(sequence, request, MORSE_ERR_SEQUENCE_FLUSHED); /* Check descriptors for correctness */ if (morse_desc_check(A) != MORSE_SUCCESS) { morse_error("MORSE_zlascal_Tile_Async", "invalid first descriptor"); return morse_request_fail(sequence, request, MORSE_ERR_ILLEGAL_VALUE); } else { descA = *A; } /* Check input arguments */ if (uplo != MorseUpper && uplo != MorseLower && uplo != MorseUpperLower) { morse_error("MORSE_zlascal", "illegal value of uplo"); return morse_request_fail(sequence, request, MORSE_ERR_ILLEGAL_VALUE); } if ( (descA.i%descA.mb != 0) || (descA.j%descA.nb != 0) ) { morse_error("MORSE_zlascal", "start indexes have to be multiple of tile size"); return morse_request_fail(sequence, request, MORSE_ERR_ILLEGAL_VALUE); } /* Quick return */ if ( (descA.m == 0) || (descA.n == 0) || (alpha == (MORSE_Complex64_t)1.0) ) return MORSE_SUCCESS; morse_pzlascal( uplo, alpha, A, sequence, request); return MORSE_SUCCESS; }