Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

zgelqf.c 9.94 KB
Newer Older
1
/**
2 3
 *
 * @file zgelqf.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,
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 zgelqf wrappers
13
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
14
 * @version 1.0.0
15
 * @comment This file has been automatically generated
Mathieu Faverge's avatar
Mathieu Faverge committed
16
 *          from Plasma 2.5.0 for CHAMELEON 1.0.0
17 18 19 20 21 22 23 24
 * @author Jakub Kurzak
 * @author Dulceneia Becker
 * @author Mathieu Faverge
 * @author Emmanuel Agullo
 * @author Cedric Castagnede
 * @date 2010-11-15
 * @precisions normal z -> s d c
 *
25
 */
26
#include "control/common.h"
27

28 29
/**
 ********************************************************************************
30
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
31
 * @ingroup CHAMELEON_Complex64_t
32
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
33
 *  CHAMELEON_zgelqf - Computes the tile LQ factorization of a complex M-by-N matrix A: A = L * Q.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
 *
 *******************************************************************************
 *
 * @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 >= 0.
 *
 * @param[in,out] A
 *          On entry, the M-by-N matrix A.
 *          On exit, the elements on and below the diagonal of the array contain the m-by-min(M,N)
 *          lower trapezoidal matrix L (L is lower triangular if M <= N); the elements above the
 *          diagonal represent the unitary matrix Q as a product of elementary reflectors, stored
 *          by tiles.
 *
 * @param[in] LDA
 *          The leading dimension of the array A. LDA >= max(1,M).
 *
 * @param[out] descT
Mathieu Faverge's avatar
Mathieu Faverge committed
54
 *          On exit, auxiliary factorization data, required by CHAMELEON_zgelqs to solve the system
55 56 57 58 59
 *          of equations.
 *
 *******************************************************************************
 *
 * @return
Mathieu Faverge's avatar
Mathieu Faverge committed
60
 *          \retval CHAMELEON_SUCCESS successful exit
61 62 63 64
 *          \retval <0 if -i, the i-th argument had an illegal value
 *
 *******************************************************************************
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
65 66 67 68 69 70
 * @sa CHAMELEON_zgelqf_Tile
 * @sa CHAMELEON_zgelqf_Tile_Async
 * @sa CHAMELEON_cgelqf
 * @sa CHAMELEON_dgelqf
 * @sa CHAMELEON_sgelqf
 * @sa CHAMELEON_zgelqs
71
 *
72
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
73 74 75
int CHAMELEON_zgelqf( int M, int N,
                  CHAMELEON_Complex64_t *A, int LDA,
                  CHAM_desc_t *descT )
76 77 78
{
    int NB;
    int status;
Mathieu Faverge's avatar
Mathieu Faverge committed
79
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
80 81 82
    RUNTIME_sequence_t *sequence = NULL;
    RUNTIME_request_t request = RUNTIME_REQUEST_INITIALIZER;
    CHAM_desc_t descAl, descAt;
83

Mathieu Faverge's avatar
Mathieu Faverge committed
84 85 86
    chamctxt = chameleon_context_self();
    if (chamctxt == NULL) {
        chameleon_fatal_error("CHAMELEON_zgelqf", "CHAMELEON not initialized");
Mathieu Faverge's avatar
Mathieu Faverge committed
87
        return CHAMELEON_ERR_NOT_INITIALIZED;
88 89 90 91
    }

    /* Check input arguments */
    if (M < 0) {
Mathieu Faverge's avatar
Mathieu Faverge committed
92
        chameleon_error("CHAMELEON_zgelqf", "illegal value of M");
93 94 95
        return -1;
    }
    if (N < 0) {
Mathieu Faverge's avatar
Mathieu Faverge committed
96
        chameleon_error("CHAMELEON_zgelqf", "illegal value of N");
97 98
        return -2;
    }
99
    if (LDA < chameleon_max(1, M)) {
Mathieu Faverge's avatar
Mathieu Faverge committed
100
        chameleon_error("CHAMELEON_zgelqf", "illegal value of LDA");
101 102 103 104
        return -4;
    }

    /* Quick return */
Mathieu Faverge's avatar
Mathieu Faverge committed
105
    if (chameleon_min(M, N) == 0)
Mathieu Faverge's avatar
Mathieu Faverge committed
106
        return CHAMELEON_SUCCESS;
107 108

    /* Tune NB & IB depending on M, N & NRHS; Set NBNBSIZE */
Mathieu Faverge's avatar
Mathieu Faverge committed
109
    status = chameleon_tune(CHAMELEON_FUNC_ZGELS, M, N, 0);
Mathieu Faverge's avatar
Mathieu Faverge committed
110
    if (status != CHAMELEON_SUCCESS) {
Mathieu Faverge's avatar
Mathieu Faverge committed
111
        chameleon_error("CHAMELEON_zgelqf", "chameleon_tune() failed");
112 113 114 115
        return status;
    }

    /* Set NT */
Mathieu Faverge's avatar
Mathieu Faverge committed
116
    NB = CHAMELEON_NB;
117

Mathieu Faverge's avatar
Mathieu Faverge committed
118
    chameleon_sequence_create( chamctxt, &sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
119

120
    /* Submit the matrix conversion */
Mathieu Faverge's avatar
Mathieu Faverge committed
121
    chameleon_zlap2tile( chamctxt, &descAl, &descAt, ChamDescInout, ChamUpperLower,
122
                     A, NB, NB, LDA, N, M, N, sequence, &request );
123 124

    /* Call the tile interface */
Mathieu Faverge's avatar
Mathieu Faverge committed
125
    CHAMELEON_zgelqf_Tile_Async( &descAt, descT, sequence, &request );
126

Mathieu Faverge's avatar
Cleanup  
Mathieu Faverge committed
127
    /* Submit the matrix conversion back */
Mathieu Faverge's avatar
Mathieu Faverge committed
128
    chameleon_ztile2lap( chamctxt, &descAl, &descAt,
Mathieu Faverge's avatar
Mathieu Faverge committed
129 130
                     ChamDescInout, ChamUpperLower, sequence, &request );
    CHAMELEON_Desc_Flush( descT, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
131

Mathieu Faverge's avatar
Mathieu Faverge committed
132
    chameleon_sequence_wait( chamctxt, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
133

Mathieu Faverge's avatar
Mathieu Faverge committed
134
    /* Cleanup the temporary data */
Mathieu Faverge's avatar
Mathieu Faverge committed
135
    chameleon_ztile2lap_cleanup( chamctxt, &descAl, &descAt );
136 137

    status = sequence->status;
Mathieu Faverge's avatar
Mathieu Faverge committed
138
    chameleon_sequence_destroy( chamctxt, sequence );
139 140 141
    return status;
}

142 143
/**
 ********************************************************************************
144
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
145
 * @ingroup CHAMELEON_Complex64_t_Tile
146
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
147 148
 *  CHAMELEON_zgelqf_Tile - Computes the tile LQ factorization of a matrix.
 *  Tile equivalent of CHAMELEON_zgelqf().
149 150 151 152 153 154 155 156 157 158 159 160 161 162
 *  Operates on matrices stored by tiles.
 *  All matrices are passed through descriptors.
 *  All dimensions are taken from the descriptors.
 *
 *******************************************************************************
 *
 * @param[in,out] A
 *          On entry, the M-by-N matrix A.
 *          On exit, the elements on and below the diagonal of the array contain the m-by-min(M,N)
 *          lower trapezoidal matrix L (L is lower triangular if M <= N); the elements above the
 *          diagonal represent the unitary matrix Q as a product of elementary reflectors, stored
 *          by tiles.
 *
 * @param[out] T
Mathieu Faverge's avatar
Mathieu Faverge committed
163
 *          On exit, auxiliary factorization data, required by CHAMELEON_zgelqs to solve the system
164 165 166 167 168
 *          of equations.
 *
 *******************************************************************************
 *
 * @return
Mathieu Faverge's avatar
Mathieu Faverge committed
169
 *          \retval CHAMELEON_SUCCESS successful exit
170 171 172
 *
 *******************************************************************************
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
173 174 175 176 177 178
 * @sa CHAMELEON_zgelqf
 * @sa CHAMELEON_zgelqf_Tile_Async
 * @sa CHAMELEON_cgelqf_Tile
 * @sa CHAMELEON_dgelqf_Tile
 * @sa CHAMELEON_sgelqf_Tile
 * @sa CHAMELEON_zgelqs_Tile
179
 *
180
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
181
int CHAMELEON_zgelqf_Tile( CHAM_desc_t *A, CHAM_desc_t *T )
182
{
Mathieu Faverge's avatar
Mathieu Faverge committed
183
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
184 185
    RUNTIME_sequence_t *sequence = NULL;
    RUNTIME_request_t request = RUNTIME_REQUEST_INITIALIZER;
186 187
    int status;

Mathieu Faverge's avatar
Mathieu Faverge committed
188 189 190
    chamctxt = chameleon_context_self();
    if (chamctxt == NULL) {
        chameleon_fatal_error("CHAMELEON_zgelqf_Tile", "CHAMELEON not initialized");
Mathieu Faverge's avatar
Mathieu Faverge committed
191
        return CHAMELEON_ERR_NOT_INITIALIZED;
192
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
193
    chameleon_sequence_create( chamctxt, &sequence );
194

Mathieu Faverge's avatar
Mathieu Faverge committed
195
    CHAMELEON_zgelqf_Tile_Async( A, T, sequence, &request );
Mathieu Faverge's avatar
Mathieu Faverge committed
196

Mathieu Faverge's avatar
Mathieu Faverge committed
197 198
    CHAMELEON_Desc_Flush( A, sequence );
    CHAMELEON_Desc_Flush( T, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
199

Mathieu Faverge's avatar
Mathieu Faverge committed
200
    chameleon_sequence_wait( chamctxt, sequence );
201
    status = sequence->status;
Mathieu Faverge's avatar
Mathieu Faverge committed
202
    chameleon_sequence_destroy( chamctxt, sequence );
203 204 205
    return status;
}

206 207
/**
 ********************************************************************************
208
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
209
 * @ingroup CHAMELEON_Complex64_t_Tile_Async
210
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
211 212
 *  CHAMELEON_zgelqf_Tile_Async - Computes the tile LQ factorization of a matrix.
 *  Non-blocking equivalent of CHAMELEON_zgelqf_Tile().
213 214 215 216 217 218 219 220 221 222 223 224 225 226
 *  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
227 228 229 230 231 232
 * @sa CHAMELEON_zgelqf
 * @sa CHAMELEON_zgelqf_Tile
 * @sa CHAMELEON_cgelqf_Tile_Async
 * @sa CHAMELEON_dgelqf_Tile_Async
 * @sa CHAMELEON_sgelqf_Tile_Async
 * @sa CHAMELEON_zgelqs_Tile_Async
233
 *
234
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
235 236
int CHAMELEON_zgelqf_Tile_Async( CHAM_desc_t *A, CHAM_desc_t *T,
                             RUNTIME_sequence_t *sequence, RUNTIME_request_t *request )
237
{
Mathieu Faverge's avatar
Mathieu Faverge committed
238
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
239
    CHAM_desc_t D, *Dptr = NULL;
240

Mathieu Faverge's avatar
Mathieu Faverge committed
241 242 243
    chamctxt = chameleon_context_self();
    if (chamctxt == NULL) {
        chameleon_fatal_error("CHAMELEON_zgelqf_Tile", "CHAMELEON not initialized");
Mathieu Faverge's avatar
Mathieu Faverge committed
244
        return CHAMELEON_ERR_NOT_INITIALIZED;
245 246
    }
    if (sequence == NULL) {
Mathieu Faverge's avatar
Mathieu Faverge committed
247
        chameleon_fatal_error("CHAMELEON_zgelqf_Tile", "NULL sequence");
Mathieu Faverge's avatar
Mathieu Faverge committed
248
        return CHAMELEON_ERR_UNALLOCATED;
249 250
    }
    if (request == NULL) {
Mathieu Faverge's avatar
Mathieu Faverge committed
251
        chameleon_fatal_error("CHAMELEON_zgelqf_Tile", "NULL request");
Mathieu Faverge's avatar
Mathieu Faverge committed
252
        return CHAMELEON_ERR_UNALLOCATED;
253 254
    }
    /* Check sequence status */
Mathieu Faverge's avatar
Mathieu Faverge committed
255 256
    if (sequence->status == CHAMELEON_SUCCESS) {
        request->status = CHAMELEON_SUCCESS;
Mathieu Faverge's avatar
Mathieu Faverge committed
257 258
    }
    else {
Mathieu Faverge's avatar
Mathieu Faverge committed
259
        return chameleon_request_fail(sequence, request, CHAMELEON_ERR_SEQUENCE_FLUSHED);
Mathieu Faverge's avatar
Mathieu Faverge committed
260
    }
261 262

    /* Check descriptors for correctness */
Mathieu Faverge's avatar
Mathieu Faverge committed
263 264 265
    if (chameleon_desc_check(A) != CHAMELEON_SUCCESS) {
        chameleon_error("CHAMELEON_zgelqf_Tile", "invalid first descriptor");
        return chameleon_request_fail(sequence, request, CHAMELEON_ERR_ILLEGAL_VALUE);
266
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
267 268 269
    if (chameleon_desc_check(T) != CHAMELEON_SUCCESS) {
        chameleon_error("CHAMELEON_zgelqf_Tile", "invalid second descriptor");
        return chameleon_request_fail(sequence, request, CHAMELEON_ERR_ILLEGAL_VALUE);
270 271 272
    }
    /* Check input arguments */
    if (A->nb != A->mb) {
Mathieu Faverge's avatar
Mathieu Faverge committed
273 274
        chameleon_error("CHAMELEON_zgelqf_Tile", "only square tiles supported");
        return chameleon_request_fail(sequence, request, CHAMELEON_ERR_ILLEGAL_VALUE);
275 276
    }
    /* Quick return */
277 278
    /*
     if (chameleon_min(M, N) == 0)
Mathieu Faverge's avatar
Mathieu Faverge committed
279
     return CHAMELEON_SUCCESS;
280
     */
281 282
#if defined(CHAMELEON_COPY_DIAG)
    {
Mathieu Faverge's avatar
Mathieu Faverge committed
283
        int m = chameleon_min(A->m, A->n);
Mathieu Faverge's avatar
Mathieu Faverge committed
284
        chameleon_zdesc_alloc(D, A->mb, A->nb, m, A->n, 0, 0, m, A->n, );
285 286 287 288
        Dptr = &D;
    }
#endif

Mathieu Faverge's avatar
Mathieu Faverge committed
289
    if (chamctxt->householder == ChamFlatHouseholder) {
290
        chameleon_pzgelqf( 1, A, T, Dptr, sequence, request );
291 292
    }
    else {
293
        chameleon_pzgelqfrh( 1, CHAMELEON_RHBLK, A, T, Dptr, sequence, request );
294
    }
295
    if (Dptr != NULL) {
Mathieu Faverge's avatar
Mathieu Faverge committed
296 297 298
        CHAMELEON_Desc_Flush( A, sequence );
        CHAMELEON_Desc_Flush( T, sequence );
        CHAMELEON_Desc_Flush( Dptr, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
299
        chameleon_sequence_wait( chamctxt, sequence );
300
        RUNTIME_desc_destroy( Dptr );
Mathieu Faverge's avatar
Mathieu Faverge committed
301
        chameleon_desc_mat_free( Dptr );
302 303
    }
    (void)D;
Mathieu Faverge's avatar
Mathieu Faverge committed
304
    return CHAMELEON_SUCCESS;
305
}