pzungqrrh.c 6.33 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
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
12
 * @brief Chameleon zungqrrh parallel algorithm
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 25
 * @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
 *
26
 */
27
#include "control/common.h"
28

29 30 31 32 33
#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)
#define D(m,n)  D, (m), (n)
34 35 36 37

/**
 *  Parallel construction of Q using tile V (application to identity;
 *  reduction Householder) - dynamic scheduling
38
 */
39 40 41 42
void chameleon_pzungqrrh( int genD, int BS,
                          CHAM_desc_t *A, CHAM_desc_t *Q,
                          CHAM_desc_t *T,  CHAM_desc_t *D,
                          RUNTIME_sequence_t *sequence, RUNTIME_request_t *request )
43
{
Mathieu Faverge's avatar
Mathieu Faverge committed
44
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
45
    RUNTIME_option_t options;
46 47 48 49 50
    size_t ws_worker = 0;
    size_t ws_host = 0;

    int k, m, n;
    int K, M, RD, lastRD;
Mathieu Faverge's avatar
Mathieu Faverge committed
51
    int ldaM, ldam, ldaMRD, lddM;
52
    int ldqM, ldqm, ldqMRD;
53 54 55
    int tempkn, tempMm, tempnn, tempmm, tempMRDm, tempkmin;
    int ib;

Mathieu Faverge's avatar
Mathieu Faverge committed
56
    chamctxt = chameleon_context_self();
Mathieu Faverge's avatar
Mathieu Faverge committed
57
    if (sequence->status != CHAMELEON_SUCCESS)
58
        return;
Mathieu Faverge's avatar
Mathieu Faverge committed
59
    RUNTIME_options_init(&options, chamctxt, sequence, request);
60

Mathieu Faverge's avatar
Mathieu Faverge committed
61
    ib = CHAMELEON_IB;
62

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

68 69 70 71 72 73 74
    /*
     * zunmqr = A->nb * ib
     * ztsmqr = A->nb * ib
     * zttmqr = A->nb * ib
     */
    ws_worker = A->nb * ib;

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

Mathieu Faverge's avatar
Mathieu Faverge committed
84 85
    ws_worker *= sizeof(CHAMELEON_Complex64_t);
    ws_host   *= sizeof(CHAMELEON_Complex64_t);
86 87 88

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );

89
    K = chameleon_min(A->mt, A->nt);
90
    for (k = K-1; k >= 0; k--) {
Mathieu Faverge's avatar
Mathieu Faverge committed
91
        RUNTIME_iteration_push(chamctxt, k);
92

93 94 95 96 97 98 99
        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;
100 101
                ldqM   = BLKLDD(Q, M   );
                ldqMRD = BLKLDD(Q, M+RD);
102
                ldaMRD = BLKLDD(A, M+RD);
103
                for (n = k; n < Q->nt; n++) {
104
                    tempnn = n == Q->nt-1 ? Q->n-n*Q->nb : Q->nb;
105 106 107 108 109 110

                    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 ) );

111
                    /* TT kernel */
Mathieu Faverge's avatar
Mathieu Faverge committed
112
                    INSERT_TASK_ztpmqrt(
113
                        &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
114
                        ChamLeft, ChamNoTrans,
115
                        tempMRDm, tempnn, tempkn, tempMRDm, ib, T->nb,
116
                        A (M+RD, k), ldaMRD,
117 118 119
                        T2(M+RD, k), T->mb,
                        Q (M,    n), ldqM,
                        Q (M+RD, n), ldqMRD);
120
                }
121

Mathieu Faverge's avatar
Mathieu Faverge committed
122 123
                RUNTIME_data_flush( sequence, A (M+RD, k) );
                RUNTIME_data_flush( sequence, T2(M+RD, k) );
124 125 126 127
            }
        }
        for (M = k; M < A->mt; M += BS) {
            tempMm   = M == A->mt-1 ? A->m-M*A->mb : A->mb;
128
            tempkmin = chameleon_min(tempMm, tempkn);
129
            ldaM = BLKLDD(A, M);
Mathieu Faverge's avatar
Mathieu Faverge committed
130
            lddM = BLKLDD(D, M);
131
            ldqM = BLKLDD(Q, M);
132
            for (m = chameleon_min(M+BS, A->mt)-1; m > M; m--) {
133
                tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
134
                ldqm = BLKLDD(Q, m);
135 136
                ldam = BLKLDD(A, m);

137
                for (n = k; n < Q->nt; n++) {
138
                    tempnn = n == Q->nt-1 ? Q->n-n*Q->nb : Q->nb;
139 140 141 142 143 144

                    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 ) );

145
                    /* TS kernel */
Mathieu Faverge's avatar
Mathieu Faverge committed
146
                    INSERT_TASK_ztpmqrt(
147
                        &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
148
                        ChamLeft, ChamNoTrans,
149
                        tempmm, tempnn, tempkn, 0, ib, T->nb,
150
                        A(m, k), ldam,
151 152 153
                        T(m, k), T->mb,
                        Q(M, n), ldqM,
                        Q(m, n), ldqm);
154
                }
Mathieu Faverge's avatar
Mathieu Faverge committed
155 156
                RUNTIME_data_flush( sequence, A(m, k) );
                RUNTIME_data_flush( sequence, T(m, k) );
157
            }
158

159 160 161 162 163
            if ( genD ) {
                INSERT_TASK_zlacpy(
                    &options,
                    ChamLower, tempMm, tempkmin, A->nb,
                    A(M, k), ldaM,
Mathieu Faverge's avatar
Mathieu Faverge committed
164
                    D(M, k), lddM );
Mathieu Faverge's avatar
Mathieu Faverge committed
165
#if defined(CHAMELEON_USE_CUDA)
166 167 168 169
                INSERT_TASK_zlaset(
                    &options,
                    ChamUpper, tempMm, tempkmin,
                    0., 1.,
Mathieu Faverge's avatar
Mathieu Faverge committed
170
                    D(M, k), lddM );
171
#endif
172
            }
173
            for (n = k; n < Q->nt; n++) {
174
                tempnn = n == Q->nt-1 ? Q->n-n*Q->nb : Q->nb;
175 176 177 178 179

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

Mathieu Faverge's avatar
Mathieu Faverge committed
180
                INSERT_TASK_zunmqr(
181
                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
182
                    ChamLeft, ChamNoTrans,
183 184
                    tempMm, tempnn,
                    tempkmin, ib, T->nb,
Mathieu Faverge's avatar
Mathieu Faverge committed
185
                    D(M, k), lddM,
186
                    T(M, k), T->mb,
187
                    Q(M, n), ldqM);
188
            }
Mathieu Faverge's avatar
Mathieu Faverge committed
189 190
            RUNTIME_data_flush( sequence, D(M, k) );
            RUNTIME_data_flush( sequence, T(M, k) );
191
        }
Mathieu Faverge's avatar
Mathieu Faverge committed
192
        RUNTIME_iteration_pop(chamctxt);
193
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
194

195
    RUNTIME_options_ws_free(&options);
Mathieu Faverge's avatar
Mathieu Faverge committed
196
    RUNTIME_options_finalize(&options, chamctxt);
Mathieu Faverge's avatar
Mathieu Faverge committed
197
    (void)D;
198
}