zgelqf.c 9.85 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
 *
10
 ***
11
 *
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
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
 *
31
 * @ingroup CHAMELEON_Complex64_t
32
 *
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
54
 *          On exit, auxiliary factorization data, required by CHAMELEON_zgelqs to solve the system
55 56 57 58
 *          of equations.
 *
 *******************************************************************************
 *
59 60
 * @retval CHAMELEON_SUCCESS successful exit
 * @retval <0 if -i, the i-th argument had an illegal value
61 62 63
 *
 *******************************************************************************
 *
64 65 66 67 68 69
 * @sa CHAMELEON_zgelqf_Tile
 * @sa CHAMELEON_zgelqf_Tile_Async
 * @sa CHAMELEON_cgelqf
 * @sa CHAMELEON_dgelqf
 * @sa CHAMELEON_sgelqf
 * @sa CHAMELEON_zgelqs
70
 *
71
 */
72 73 74
int CHAMELEON_zgelqf( int M, int N,
                  CHAMELEON_Complex64_t *A, int LDA,
                  CHAM_desc_t *descT )
75 76 77
{
    int NB;
    int status;
Mathieu Faverge's avatar
Mathieu Faverge committed
78
    CHAM_context_t *chamctxt;
79 80 81
    RUNTIME_sequence_t *sequence = NULL;
    RUNTIME_request_t request = RUNTIME_REQUEST_INITIALIZER;
    CHAM_desc_t descAl, descAt;
82

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

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

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

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

    /* Set NT */
115
    NB = CHAMELEON_NB;
116

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

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

    /* Call the tile interface */
124
    CHAMELEON_zgelqf_Tile_Async( &descAt, descT, sequence, &request );
125

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

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

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

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

141 142
/**
 ********************************************************************************
143
 *
144
 * @ingroup CHAMELEON_Complex64_t_Tile
145
 *
146 147
 *  CHAMELEON_zgelqf_Tile - Computes the tile LQ factorization of a matrix.
 *  Tile equivalent of CHAMELEON_zgelqf().
148 149 150 151 152 153 154 155 156 157 158 159 160 161
 *  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
162
 *          On exit, auxiliary factorization data, required by CHAMELEON_zgelqs to solve the system
163 164 165 166
 *          of equations.
 *
 *******************************************************************************
 *
167
 * @retval CHAMELEON_SUCCESS successful exit
168 169 170
 *
 *******************************************************************************
 *
171 172 173 174 175 176
 * @sa CHAMELEON_zgelqf
 * @sa CHAMELEON_zgelqf_Tile_Async
 * @sa CHAMELEON_cgelqf_Tile
 * @sa CHAMELEON_dgelqf_Tile
 * @sa CHAMELEON_sgelqf_Tile
 * @sa CHAMELEON_zgelqs_Tile
177
 *
178
 */
179
int CHAMELEON_zgelqf_Tile( CHAM_desc_t *A, CHAM_desc_t *T )
180
{
Mathieu Faverge's avatar
Mathieu Faverge committed
181
    CHAM_context_t *chamctxt;
182 183
    RUNTIME_sequence_t *sequence = NULL;
    RUNTIME_request_t request = RUNTIME_REQUEST_INITIALIZER;
184 185
    int status;

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

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

195 196
    CHAMELEON_Desc_Flush( A, sequence );
    CHAMELEON_Desc_Flush( T, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
197

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

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

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

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

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