pzungqrrh.c 5.84 KB
Newer Older
1
/**
2 3
 *
 * @file pzungqrrh.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.
7 8
 * @copyright 2012-2016 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 *                      Univ. Bordeaux. All rights reserved.
9
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
10
 ***
11
 *
12
 * @brief Chameleon auxiliary routines
13
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
14
 * @version 1.0.0
15 16 17 18 19 20 21 22 23 24 25 26
 * @comment This file has been automatically generated
 *          from Plasma 2.5.0 for MORSE 1.0.0
 * @author Hatem Ltaief
 * @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
 *
 **/
27
#include "control/common.h"
28 29 30 31 32

#define A(m,n) A,  (m),  (n)
#define Q(m,n) Q,  (m),  (n)
#define T(m,n) T,  (m),  (n)
#define T2(m,n) T,  (m),  (n)+(A->nt)
33
#if defined(CHAMELEON_COPY_DIAG)
34
#define D(m,n) D, ((m)/BS), 0
35
#else
36
#define D(m,n) A, (m), (n)
37
#endif
38 39 40 41 42 43

/**
 *  Parallel construction of Q using tile V (application to identity;
 *  reduction Householder) - dynamic scheduling
 **/
void morse_pzungqrrh(MORSE_desc_t *A, MORSE_desc_t *Q,
44
                     MORSE_desc_t *T,  MORSE_desc_t *D, int BS,
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 K, M, RD, lastRD;
    int ldaM, ldam, ldaMRD;
55
    int ldqM, ldqm, ldqMRD;
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
    int tempkn, tempMm, tempnn, tempmm, tempMRDm, tempkmin;
    int ib;

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

    ib = MORSE_IB;

    /*
     * zunmqr = A->nb * ib
     * ztsmqr = A->nb * ib
     * zttmqr = A->nb * ib
     */
    ws_worker = A->nb * ib;

Mathieu Faverge's avatar
Mathieu Faverge committed
73
#if defined(CHAMELEON_USE_CUDA)
74 75 76 77 78
    /* Worker space
     *
     * zunmqr = A->nb * ib
     * ztsmqr = 2 * A->nb * ib
     */
79
    ws_worker = chameleon_max( ws_worker, ib * A->nb * 2 );
80 81 82 83 84 85 86
#endif

    ws_worker *= sizeof(MORSE_Complex64_t);
    ws_host   *= sizeof(MORSE_Complex64_t);

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );

87
    K = chameleon_min(A->mt, A->nt);
88
    for (k = K-1; k >= 0; k--) {
89
        RUNTIME_iteration_push(morse, k);
90

91 92 93 94 95 96 97
        tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
        lastRD = 0;
        for (RD = BS; RD < A->mt-k; RD *= 2)
            lastRD = RD;
        for (RD = lastRD; RD >= BS; RD /= 2) {
            for (M = k; M+RD < A->mt; M += 2*RD) {
                tempMRDm = M+RD == A->mt-1 ? A->m-(M+RD)*A->mb : A->mb;
98 99
                ldqM   = BLKLDD(Q, M   );
                ldqMRD = BLKLDD(Q, M+RD);
100
                ldaMRD = BLKLDD(A, M+RD);
101
                for (n = k; n < Q->nt; n++) {
102
                    tempnn = n == Q->nt-1 ? Q->n-n*Q->nb : Q->nb;
103 104 105 106 107 108

                    RUNTIME_data_migrate( sequence, Q(M, n),
                                          Q->get_rankof( Q, M+RD, n ) );
                    RUNTIME_data_migrate( sequence, Q(M+RD, n),
                                          Q->get_rankof( Q, M+RD, n ) );

109
                    /* TT kernel */
110
                    MORSE_TASK_ztpmqrt(
111 112
                        &options,
                        MorseLeft, MorseNoTrans,
113
                        tempMRDm, tempnn, tempkn, tempMRDm, ib, T->nb,
114
                        A (M+RD, k), ldaMRD,
115 116 117
                        T2(M+RD, k), T->mb,
                        Q (M,    n), ldqM,
                        Q (M+RD, n), ldqMRD);
118 119 120 121 122
                }
            }
        }
        for (M = k; M < A->mt; M += BS) {
            tempMm   = M == A->mt-1 ? A->m-M*A->mb : A->mb;
123
            tempkmin = chameleon_min(tempMm, tempkn);
124
            ldaM = BLKLDD(A, M);
125
            ldqM = BLKLDD(Q, M);
126
            for (m = chameleon_min(M+BS, A->mt)-1; m > M; m--) {
127
                tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
128
                ldqm = BLKLDD(Q, m);
129 130
                ldam = BLKLDD(A, m);

131
                for (n = k; n < Q->nt; n++) {
132
                    tempnn = n == Q->nt-1 ? Q->n-n*Q->nb : Q->nb;
133 134 135 136 137 138

                    RUNTIME_data_migrate( sequence, Q(M, n),
                                          Q->get_rankof( Q, m, n ) );
                    RUNTIME_data_migrate( sequence, Q(m, n),
                                          Q->get_rankof( Q, m, n ) );

139
                    /* TS kernel */
140
                    MORSE_TASK_ztpmqrt(
141 142
                        &options,
                        MorseLeft, MorseNoTrans,
143
                        tempmm, tempnn, tempkn, 0, ib, T->nb,
144
                        A(m, k), ldam,
145 146 147
                        T(m, k), T->mb,
                        Q(M, n), ldqM,
                        Q(m, n), ldqm);
148 149
                }
            }
150

151
#if defined(CHAMELEON_COPY_DIAG)
152 153 154 155
            MORSE_TASK_zlacpy(
                &options,
                MorseLower, tempMm, tempkmin, A->nb,
                A(M, k), ldaM,
156
                D(M, k), ldaM );
Mathieu Faverge's avatar
Mathieu Faverge committed
157
#if defined(CHAMELEON_USE_CUDA)
158 159 160 161
            MORSE_TASK_zlaset(
                &options,
                MorseUpper, tempMm, tempkmin,
                0., 1.,
162
                D(M, k), ldaM );
163
#endif
164 165
#endif
            for (n = k; n < Q->nt; n++) {
166
                tempnn = n == Q->nt-1 ? Q->n-n*Q->nb : Q->nb;
167 168 169 170 171

                /* Restore the original location of the tiles */
                RUNTIME_data_migrate( sequence, Q(M, n),
                                      Q->get_rankof( Q, M, n ) );

172 173 174 175 176
                MORSE_TASK_zunmqr(
                    &options,
                    MorseLeft, MorseNoTrans,
                    tempMm, tempnn,
                    tempkmin, ib, T->nb,
177
                    D(M, k), ldaM,
178
                    T(M, k), T->mb,
179
                    Q(M, n), ldqM);
180 181
            }
        }
182
        RUNTIME_iteration_pop(morse);
183
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
184

185 186
    RUNTIME_options_ws_free(&options);
    RUNTIME_options_finalize(&options, morse);
Mathieu Faverge's avatar
Mathieu Faverge committed
187
    (void)D;
188
}