Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

zgelqs_param.c 12.2 KB
Newer Older
1
/**
2 3
 *
 * @file zgelqs_param.c
4
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
5 6
 * @copyright 2009-2014 The University of Tennessee and The University of
 *                      Tennessee Research Foundation. All rights reserved.
Mathieu Faverge's avatar
Mathieu Faverge committed
7
 * @copyright 2012-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
Mathieu Faverge's avatar
Mathieu Faverge committed
8
 *                      Univ. Bordeaux. All rights reserved.
9
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
10
 ***
11
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
12
 * @brief Chameleon zgelqs_param wrappers
13
 *
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
14 15
 * @version 1.0.0
 * @author Raphael Boucherie
16
 * @author Mathieu Faverge
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
17
 * @date 2017-05-17
18 19
 * @precisions normal z -> s d c
 *
20
 */
21
#include "control/common.h"
Mathieu Faverge's avatar
Mathieu Faverge committed
22
#include <stdlib.h>
23

BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
24 25
/**
 *******************************************************************************
26
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
27
 * @ingroup CHAMELEON_Complex64_t
28
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
29 30
 *  CHAMELEON_zgelqs_param - Compute a minimum-norm solution min || A*X - B || using the LQ factorization
 *  A = L*Q computed by CHAMELEON_zgelqf.
31 32 33
 *
 *******************************************************************************
 *
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
34 35 36
 * @param[in] qrtree
 *          The tree used for the factorization
 *
37 38 39 40 41 42 43 44 45 46
 * @param[in] M
 *          The number of rows of the matrix A. M >= 0.
 *
 * @param[in] N
 *          The number of columns of the matrix A. N >= M >= 0.
 *
 * @param[in] NRHS
 *          The number of columns of B. NRHS >= 0.
 *
 * @param[in] A
Mathieu Faverge's avatar
Mathieu Faverge committed
47
 *          Details of the LQ factorization of the original matrix A as returned by CHAMELEON_zgelqf.
48 49 50 51
 *
 * @param[in] LDA
 *          The leading dimension of the array A. LDA >= M.
 *
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
52
 * @param[in] descTS
Mathieu Faverge's avatar
Mathieu Faverge committed
53
 *          Auxiliary factorization data, computed by CHAMELEON_zgelqf.
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
54 55
 *
 * @param[in] descTT
Mathieu Faverge's avatar
Mathieu Faverge committed
56
 *          Auxiliary factorization data, computed by CHAMELEON_zgelqf.
57 58 59 60 61 62 63 64 65 66 67
 *
 * @param[in,out] B
 *          On entry, the M-by-NRHS right hand side matrix B.
 *          On exit, the N-by-NRHS solution matrix X.
 *
 * @param[in] LDB
 *          The leading dimension of the array B. LDB >= N.
 *
 *******************************************************************************
 *
 * @return
Mathieu Faverge's avatar
Mathieu Faverge committed
68
 *          \retval CHAMELEON_SUCCESS successful exit
69 70 71 72
 *          \retval <0 if -i, the i-th argument had an illegal value
 *
 *******************************************************************************
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
73 74 75 76 77 78
 * @sa CHAMELEON_zgelqs_param_Tile
 * @sa CHAMELEON_zgelqs_param_Tile_Async
 * @sa CHAMELEON_cgelqs
 * @sa CHAMELEON_dgelqs
 * @sa CHAMELEON_sgelqs
 * @sa CHAMELEON_zgelqf
79
 *
80
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
81 82 83 84
int CHAMELEON_zgelqs_param( const libhqr_tree_t *qrtree, int M, int N, int NRHS,
                        CHAMELEON_Complex64_t *A, int LDA,
                        CHAM_desc_t *descTS, CHAM_desc_t *descTT,
                        CHAMELEON_Complex64_t *B, int LDB )
85 86 87
{
    int NB;
    int status;
Mathieu Faverge's avatar
Mathieu Faverge committed
88
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
89 90 91 92
    RUNTIME_sequence_t *sequence = NULL;
    RUNTIME_request_t request = RUNTIME_REQUEST_INITIALIZER;
    CHAM_desc_t descAl, descAt;
    CHAM_desc_t descBl, descBt;
93

Mathieu Faverge's avatar
Mathieu Faverge committed
94 95 96
    chamctxt = chameleon_context_self();
    if (chamctxt == NULL) {
        chameleon_fatal_error("CHAMELEON_zgelqs_param", "CHAMELEON not initialized");
Mathieu Faverge's avatar
Mathieu Faverge committed
97
        return CHAMELEON_ERR_NOT_INITIALIZED;
98 99 100 101
    }

    /* Check input arguments */
    if (M < 0) {
Mathieu Faverge's avatar
Mathieu Faverge committed
102
        chameleon_error("CHAMELEON_zgelqs_param", "illegal value of M");
103 104 105
        return -1;
    }
    if (N < 0 || M > N) {
Mathieu Faverge's avatar
Mathieu Faverge committed
106
        chameleon_error("CHAMELEON_zgelqs_param", "illegal value of N");
107 108 109
        return -2;
    }
    if (NRHS < 0) {
Mathieu Faverge's avatar
Mathieu Faverge committed
110
        chameleon_error("CHAMELEON_zgelqs_param", "illegal value of N");
111 112 113
        return -3;
    }
    if (LDA < chameleon_max(1, M)) {
Mathieu Faverge's avatar
Mathieu Faverge committed
114
        chameleon_error("CHAMELEON_zgelqs_param", "illegal value of LDA");
115 116 117
        return -5;
    }
    if (LDB < chameleon_max(1, chameleon_max(1, N))) {
Mathieu Faverge's avatar
Mathieu Faverge committed
118
        chameleon_error("CHAMELEON_zgelqs_param", "illegal value of LDB");
119 120 121 122
        return -8;
    }
    /* Quick return */
    if (chameleon_min(M, chameleon_min(N, NRHS)) == 0) {
Mathieu Faverge's avatar
Mathieu Faverge committed
123
        return CHAMELEON_SUCCESS;
124 125 126
    }

    /* Tune NB & IB depending on M, N & NRHS; Set NBNBSIZE */
Mathieu Faverge's avatar
Mathieu Faverge committed
127
    status = chameleon_tune(CHAMELEON_FUNC_ZGELS, M, N, NRHS);
Mathieu Faverge's avatar
Mathieu Faverge committed
128
    if (status != CHAMELEON_SUCCESS) {
Mathieu Faverge's avatar
Mathieu Faverge committed
129
        chameleon_error("CHAMELEON_zgelqs_param", "chameleon_tune() failed");
130 131 132 133
        return status;
    }

    /* Set NT */
Mathieu Faverge's avatar
Mathieu Faverge committed
134
    NB = CHAMELEON_NB;
135

Mathieu Faverge's avatar
Mathieu Faverge committed
136
    chameleon_sequence_create( chamctxt, &sequence );
137

138
    /* Submit the matrix conversion */
Mathieu Faverge's avatar
Mathieu Faverge committed
139
    chameleon_zlap2tile( chamctxt, &descAl, &descAt, ChamDescInput, ChamUpperLower,
140
                     A, NB, NB, LDA, N, M, N, sequence, &request );
Mathieu Faverge's avatar
Mathieu Faverge committed
141
    chameleon_zlap2tile( chamctxt, &descBl, &descBt, ChamDescInout, ChamUpperLower,
142
                     B, NB, NB, LDB, NRHS, N, NRHS, sequence, &request );
143 144

    /* Call the tile interface */
Mathieu Faverge's avatar
Mathieu Faverge committed
145
    CHAMELEON_zgelqs_param_Tile_Async( qrtree, &descAt, descTS, descTT, &descBt, sequence, &request );
146

Mathieu Faverge's avatar
Cleanup  
Mathieu Faverge committed
147
    /* Submit the matrix conversion back */
Mathieu Faverge's avatar
Mathieu Faverge committed
148
    chameleon_ztile2lap( chamctxt, &descAl, &descAt,
Mathieu Faverge's avatar
Mathieu Faverge committed
149
                     ChamDescInput, ChamUpperLower, sequence, &request );
Mathieu Faverge's avatar
Mathieu Faverge committed
150
    chameleon_ztile2lap( chamctxt, &descBl, &descBt,
Mathieu Faverge's avatar
Mathieu Faverge committed
151 152 153
                     ChamDescInout, ChamUpperLower, sequence, &request );
    CHAMELEON_Desc_Flush( descTS, sequence );
    CHAMELEON_Desc_Flush( descTT, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
154

Mathieu Faverge's avatar
Mathieu Faverge committed
155
    chameleon_sequence_wait( chamctxt, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
156

Mathieu Faverge's avatar
Mathieu Faverge committed
157
    /* Cleanup the temporary data */
Mathieu Faverge's avatar
Mathieu Faverge committed
158 159
    chameleon_ztile2lap_cleanup( chamctxt, &descAl, &descAt );
    chameleon_ztile2lap_cleanup( chamctxt, &descBl, &descBt );
160 161

    status = sequence->status;
Mathieu Faverge's avatar
Mathieu Faverge committed
162
    chameleon_sequence_destroy( chamctxt, sequence );
163 164 165 166 167 168
    return status;
}

/**
 *******************************************************************************
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
169
 * @ingroup CHAMELEON_Complex64_t_Tile
170
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
171
 *  CHAMELEON_zgelqs_param_Tile - Computes a minimum-norm solution using previously computed
172
 *  LQ factorization.
Mathieu Faverge's avatar
Mathieu Faverge committed
173
 *  Tile equivalent of CHAMELEON_zgelqs_param().
174 175 176 177 178 179 180
 *  Operates on matrices stored by tiles.
 *  All matrices are passed through descriptors.
 *  All dimensions are taken from the descriptors.
 *
 *******************************************************************************
 *
 * @param[in] A
Mathieu Faverge's avatar
Mathieu Faverge committed
181
 *          Details of the LQ factorization of the original matrix A as returned by CHAMELEON_zgelqf.
182
 *
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
183
 * @param[in] TS
Mathieu Faverge's avatar
Mathieu Faverge committed
184
 *          Auxiliary factorization data, computed by CHAMELEON_zgelqf.
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
185 186
 *
 * @param[in] TT
Mathieu Faverge's avatar
Mathieu Faverge committed
187
 *          Auxiliary factorization data, computed by CHAMELEON_zgelqf.
188 189 190 191 192 193 194 195
 *
 * @param[in,out] B
 *          On entry, the M-by-NRHS right hand side matrix B.
 *          On exit, the N-by-NRHS solution matrix X.
 *
 *******************************************************************************
 *
 * @return
Mathieu Faverge's avatar
Mathieu Faverge committed
196
 *          \retval CHAMELEON_SUCCESS successful exit
197 198 199
 *
 *******************************************************************************
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
200 201 202 203 204 205
 * @sa CHAMELEON_zgelqs_param
 * @sa CHAMELEON_zgelqs_param_Tile_Async
 * @sa CHAMELEON_cgelqs_Tile
 * @sa CHAMELEON_dgelqs_Tile
 * @sa CHAMELEON_sgelqs_Tile
 * @sa CHAMELEON_zgelqf_Tile
206
 *
207
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
208 209
int CHAMELEON_zgelqs_param_Tile( const libhqr_tree_t *qrtree, CHAM_desc_t *A,
                             CHAM_desc_t *TS, CHAM_desc_t *TT, CHAM_desc_t *B )
210
{
Mathieu Faverge's avatar
Mathieu Faverge committed
211
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
212 213
    RUNTIME_sequence_t *sequence = NULL;
    RUNTIME_request_t request = RUNTIME_REQUEST_INITIALIZER;
214 215
    int status;

Mathieu Faverge's avatar
Mathieu Faverge committed
216 217 218
    chamctxt = chameleon_context_self();
    if (chamctxt == NULL) {
        chameleon_fatal_error("CHAMELEON_zgelqs_param_Tile", "CHAMELEON not initialized");
Mathieu Faverge's avatar
Mathieu Faverge committed
219
        return CHAMELEON_ERR_NOT_INITIALIZED;
220
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
221
    chameleon_sequence_create( chamctxt, &sequence );
222

Mathieu Faverge's avatar
Mathieu Faverge committed
223
    CHAMELEON_zgelqs_param_Tile_Async( qrtree, A, TS, TT, B, sequence, &request );
224

Mathieu Faverge's avatar
Mathieu Faverge committed
225 226 227 228
    CHAMELEON_Desc_Flush( A, sequence );
    CHAMELEON_Desc_Flush( TS, sequence );
    CHAMELEON_Desc_Flush( TT, sequence );
    CHAMELEON_Desc_Flush( B, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
229

Mathieu Faverge's avatar
Mathieu Faverge committed
230
    chameleon_sequence_wait( chamctxt, sequence );
231
    status = sequence->status;
Mathieu Faverge's avatar
Mathieu Faverge committed
232
    chameleon_sequence_destroy( chamctxt, sequence );
233 234 235 236 237 238
    return status;
}

/**
 *******************************************************************************
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
239
 * @ingroup CHAMELEON_Complex64_t_Tile_Async
240
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
241
 *  CHAMELEON_zgelqs_param_Tile_Async - Computes a minimum-norm solution using previously
242
 *  computed LQ factorization.
Mathieu Faverge's avatar
Mathieu Faverge committed
243
 *  Non-blocking equivalent of CHAMELEON_zgelqs_param_Tile().
244 245 246 247 248 249 250 251 252 253 254 255 256 257
 *  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).
 *
 *******************************************************************************
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
258 259 260 261 262 263
 * @sa CHAMELEON_zgelqs_param
 * @sa CHAMELEON_zgelqs_param_Tile
 * @sa CHAMELEON_cgelqs_Tile_Async
 * @sa CHAMELEON_dgelqs_Tile_Async
 * @sa CHAMELEON_sgelqs_Tile_Async
 * @sa CHAMELEON_zgelqf_Tile_Async
264
 *
265
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
266 267
int CHAMELEON_zgelqs_param_Tile_Async( const libhqr_tree_t *qrtree, CHAM_desc_t *A, CHAM_desc_t *TS, CHAM_desc_t *TT, CHAM_desc_t *B,
                                   RUNTIME_sequence_t *sequence, RUNTIME_request_t *request )
268
{
Mathieu Faverge's avatar
Mathieu Faverge committed
269 270
    CHAM_desc_t *subB;
    CHAM_desc_t *subA;
Mathieu Faverge's avatar
Mathieu Faverge committed
271
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
272
    CHAM_desc_t D, *Dptr = NULL;
273

Mathieu Faverge's avatar
Mathieu Faverge committed
274 275 276
    chamctxt = chameleon_context_self();
    if (chamctxt == NULL) {
        chameleon_fatal_error("CHAMELEON_zgelqs_param_Tile", "CHAMELEON not initialized");
Mathieu Faverge's avatar
Mathieu Faverge committed
277
        return CHAMELEON_ERR_NOT_INITIALIZED;
278 279
    }
    if (sequence == NULL) {
Mathieu Faverge's avatar
Mathieu Faverge committed
280
        chameleon_fatal_error("CHAMELEON_zgelqs_param_Tile", "NULL sequence");
Mathieu Faverge's avatar
Mathieu Faverge committed
281
        return CHAMELEON_ERR_UNALLOCATED;
282 283
    }
    if (request == NULL) {
Mathieu Faverge's avatar
Mathieu Faverge committed
284
        chameleon_fatal_error("CHAMELEON_zgelqs_param_Tile", "NULL request");
Mathieu Faverge's avatar
Mathieu Faverge committed
285
        return CHAMELEON_ERR_UNALLOCATED;
286 287
    }
    /* Check sequence status */
Mathieu Faverge's avatar
Mathieu Faverge committed
288 289
    if (sequence->status == CHAMELEON_SUCCESS) {
        request->status = CHAMELEON_SUCCESS;
Mathieu Faverge's avatar
Mathieu Faverge committed
290 291
    }
    else {
Mathieu Faverge's avatar
Mathieu Faverge committed
292
        return chameleon_request_fail(sequence, request, CHAMELEON_ERR_SEQUENCE_FLUSHED);
Mathieu Faverge's avatar
Mathieu Faverge committed
293
    }
294 295

    /* Check descriptors for correctness */
Mathieu Faverge's avatar
Mathieu Faverge committed
296 297 298
    if (chameleon_desc_check(A) != CHAMELEON_SUCCESS) {
        chameleon_error("CHAMELEON_zgelqs_param_Tile", "invalid first descriptor");
        return chameleon_request_fail(sequence, request, CHAMELEON_ERR_ILLEGAL_VALUE);
299
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
300 301 302
    if (chameleon_desc_check(TS) != CHAMELEON_SUCCESS) {
        chameleon_error("CHAMELEON_zgelqs_param_Tile", "invalid second descriptor");
        return chameleon_request_fail(sequence, request, CHAMELEON_ERR_ILLEGAL_VALUE);
303
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
304 305 306
    if (chameleon_desc_check(TT) != CHAMELEON_SUCCESS) {
        chameleon_error("CHAMELEON_zgelqs_param_Tile", "invalid third descriptor");
        return chameleon_request_fail(sequence, request, CHAMELEON_ERR_ILLEGAL_VALUE);
307
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
308 309 310
    if (chameleon_desc_check(B) != CHAMELEON_SUCCESS) {
        chameleon_error("CHAMELEON_zgelqs_param_Tile", "invalid fourth descriptor");
        return chameleon_request_fail(sequence, request, CHAMELEON_ERR_ILLEGAL_VALUE);
311 312 313
    }
    /* Check input arguments */
    if (A->nb != A->mb || B->nb != B->mb) {
Mathieu Faverge's avatar
Mathieu Faverge committed
314 315
        chameleon_error("CHAMELEON_zgelqs_param_Tile", "only square tiles supported");
        return chameleon_request_fail(sequence, request, CHAMELEON_ERR_ILLEGAL_VALUE);
316 317
    }
    /* Quick return */
318 319
    /*
     if (chameleon_min(M, chameleon_min(N, NRHS)) == 0) {
Mathieu Faverge's avatar
Mathieu Faverge committed
320
     return CHAMELEON_SUCCESS;
321 322
     }
     */
Mathieu Faverge's avatar
Mathieu Faverge committed
323 324
    /* subB = chameleon_desc_submatrix(B, A->m, 0, A->n-A->m, B->n);
     chameleon_pzlaset( ChamUpperLower, 0., 0., subB, sequence, request );
325
     free(subB); */
326

Mathieu Faverge's avatar
Mathieu Faverge committed
327 328 329
    subB = chameleon_desc_submatrix(B, 0, 0, A->m, B->n);
    subA = chameleon_desc_submatrix(A, 0, 0, A->m, A->m);
    chameleon_pztrsm( ChamLeft, ChamLower, ChamNoTrans, ChamNonUnit, 1.0, subA, subB, sequence, request );
330 331 332
    free(subA);
    free(subB);

BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
333
#if defined(CHAMELEON_COPY_DIAG)
Mathieu Faverge's avatar
Mathieu Faverge committed
334
    {
Mathieu Faverge's avatar
Mathieu Faverge committed
335
        int m = chameleon_min(A->m, A->n);
Mathieu Faverge's avatar
Mathieu Faverge committed
336
        chameleon_zdesc_alloc(D, A->mb, A->nb, m, A->n, 0, 0, m, A->n, );
Mathieu Faverge's avatar
Mathieu Faverge committed
337 338
        Dptr = &D;
    }
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
339
#endif
340

341
    chameleon_pzunmlq_param( 1, qrtree, ChamLeft, ChamConjTrans, A, B, TS, TT, Dptr, sequence, request );
Mathieu Faverge's avatar
Mathieu Faverge committed
342
    if (Dptr != NULL) {
Mathieu Faverge's avatar
Mathieu Faverge committed
343 344 345 346 347
        CHAMELEON_Desc_Flush( A, sequence );
        CHAMELEON_Desc_Flush( B, sequence );
        CHAMELEON_Desc_Flush( TS, sequence );
        CHAMELEON_Desc_Flush( TT, sequence );
        CHAMELEON_Desc_Flush( Dptr, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
348
        chameleon_sequence_wait( chamctxt, sequence );
349
        RUNTIME_desc_destroy( Dptr );
Mathieu Faverge's avatar
Mathieu Faverge committed
350
        chameleon_desc_mat_free( Dptr );
Mathieu Faverge's avatar
Mathieu Faverge committed
351
    }
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
352
    (void)D;
Mathieu Faverge's avatar
Mathieu Faverge committed
353
    return CHAMELEON_SUCCESS;
354
}