Une nouvelle version du portail de gestion des comptes externes sera mise en production lundi 09 août. Elle permettra d'allonger la validité d'un compte externe jusqu'à 3 ans. Pour plus de détails sur cette version consulter : https://doc-si.inria.fr/x/FCeS

pzgeqrf.c 4.77 KB
Newer Older
1 2
/**
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
3 4
 * @copyright 2009-2014 The University of Tennessee and The University of
 *                      Tennessee Research Foundation. All rights reserved.
5 6
 * @copyright 2012-2016 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 *                      Univ. Bordeaux. All rights reserved.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 *
 **/

/**
 *
 * @file pzgeqrf.c
 *
 *  MORSE auxiliary routines
 *  MORSE is a software package provided by Univ. of Tennessee,
 *  Univ. of California Berkeley and Univ. of Colorado Denver
 *
 * @version 2.5.0
 * @comment This file has been automatically generated
 *          from Plasma 2.5.0 for MORSE 1.0.0
 * @author Jakub Kurzak
 * @author Hatem Ltaief
 * @author Mathieu Faverge
 * @author Emmanuel Agullo
 * @author Cedric Castagnede
 * @date 2010-11-15
 * @precisions normal z -> s d c
 *
 **/
30
#include "control/common.h"
31 32 33

#define A(m,n) A,  m,  n
#define T(m,n) T,  m,  n
34
#if defined(CHAMELEON_COPY_DIAG)
35
#define D(k)   D,  k,  0
36
#else
37
#define D(k)   D,  k,  k
38
#endif
39

Mathieu Faverge's avatar
Mathieu Faverge committed
40
/*******************************************************************************
41 42
 *  Parallel tile QR factorization - dynamic scheduling
 **/
43
void morse_pzgeqrf(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D,
44 45 46 47 48 49 50 51 52 53 54
                   MORSE_sequence_t *sequence, MORSE_request_t *request)
{
    MORSE_context_t *morse;
    MORSE_option_t options;
    size_t ws_worker = 0;
    size_t ws_host = 0;

    int k, m, n;
    int ldak, ldam;
    int tempkm, tempkn, tempnn, tempmm;
    int ib;
55
    int minMNT = chameleon_min(A->mt, A->nt);
56 57 58 59 60 61 62 63

    morse = morse_context_self();
    if (sequence->status != MORSE_SUCCESS)
        return;
    RUNTIME_options_init(&options, morse, sequence, request);

    ib = MORSE_IB;

64 65 66 67
    if ( D == NULL ) {
        D = A;
    }

68 69 70 71 72 73 74 75 76
    /*
     * zgeqrt = A->nb * (ib+1)
     * zunmqr = A->nb * ib
     * ztsqrt = A->nb * (ib+1)
     * ztsmqr = A->nb * ib
     */
    ws_worker = A->nb * (ib+1);

    /* Allocation of temporary (scratch) working space */
Mathieu Faverge's avatar
Mathieu Faverge committed
77 78 79 80 81 82
#if defined(CHAMELEON_USE_CUDA)
    /* Worker space
     *
     * zunmqr = A->nb * ib
     * ztsmqr = 2 * A->nb * ib
     */
83
    ws_worker = chameleon_max( ws_worker, ib * A->nb * 2 );
Mathieu Faverge's avatar
Mathieu Faverge committed
84 85
#endif

86 87 88 89 90 91
    ws_worker *= sizeof(MORSE_Complex64_t);
    ws_host   *= sizeof(MORSE_Complex64_t);

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );

    for (k = 0; k < minMNT; k++) {
92
        RUNTIME_iteration_push(morse, k);
93

94 95 96 97 98 99 100 101 102
        tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
        tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
        ldak = BLKLDD(A, k);
        MORSE_TASK_zgeqrt(
            &options,
            tempkm, tempkn, ib, T->nb,
            A(k, k), ldak,
            T(k, k), T->mb);
        if ( k < (A->nt-1) ) {
103
#if defined(CHAMELEON_COPY_DIAG)
104 105 106 107
            MORSE_TASK_zlacpy(
                &options,
                MorseLower, A->mb, A->nb, A->nb,
                A(k, k), ldak,
108
                D(k), ldak );
Mathieu Faverge's avatar
Mathieu Faverge committed
109
#if defined(CHAMELEON_USE_CUDA)
110 111 112 113
            MORSE_TASK_zlaset(
                &options,
                MorseUpper, A->mb, A->nb,
                0., 1.,
114
                D(k), ldak );
115
#endif
116
#endif
117
        }
118 119 120 121 122 123
        for (n = k+1; n < A->nt; n++) {
            tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
            MORSE_TASK_zunmqr(
                &options,
                MorseLeft, MorseConjTrans,
                tempkm, tempnn, tempkm, ib, T->nb,
124
                D(k), ldak,
125 126 127
                T(k, k), T->mb,
                A(k, n), ldak);
        }
128

129 130 131
        for (m = k+1; m < A->mt; m++) {
            tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
            ldam = BLKLDD(A, m);
132 133 134 135

            RUNTIME_data_migrate( sequence, A(k, k),
                                  A->get_rankof( A, m, k ) );

136
            /* TS kernel */
137
            MORSE_TASK_ztpqrt(
138
                &options,
139
                tempmm, tempkn, 0, ib, T->nb,
140 141 142
                A(k, k), ldak,
                A(m, k), ldam,
                T(m, k), T->mb);
143

144 145
            for (n = k+1; n < A->nt; n++) {
                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
146 147 148 149

                RUNTIME_data_migrate( sequence, A(k, n),
                                      A->get_rankof( A, m, n ) );

150
                /* TS kernel */
151
                MORSE_TASK_ztpmqrt(
152 153
                    &options,
                    MorseLeft, MorseConjTrans,
154
                    tempmm, tempnn, A->nb, 0, ib, T->nb,
155
                    A(m, k), ldam,
156 157 158
                    T(m, k), T->mb,
                    A(k, n), ldak,
                    A(m, n), ldam);
159 160
            }
        }
161

162 163 164 165 166 167
        /* Restore the original location of the tiles */
        for (n = k; n < A->nt; n++) {
            RUNTIME_data_migrate( sequence, A(k, n),
                                  A->get_rankof( A, k, n ) );
        }

168
        RUNTIME_iteration_pop(morse);
169
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
170

171 172
    RUNTIME_options_ws_free(&options);
    RUNTIME_options_finalize(&options, morse);
Mathieu Faverge's avatar
Mathieu Faverge committed
173
    (void)D;
174
}