pzungqrrh.c 6.21 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.
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 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
    int tempkn, tempMm, tempnn, tempmm, tempMRDm, tempkmin;
54
    int ib, node;
55

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
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
60
    RUNTIME_options_init(&options, chamctxt, sequence, request);
61

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

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

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

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

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

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );

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

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

107 108 109
                    node = Q->get_rankof( Q, M+RD, n );
                    RUNTIME_data_migrate( sequence, Q(M, n),    node );
                    RUNTIME_data_migrate( sequence, Q(M+RD, n), node );
110

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
                    node = Q->get_rankof( Q, m, n );
                    RUNTIME_data_migrate( sequence, Q(M, n), node );
                    RUNTIME_data_migrate( sequence, Q(m, n), node );
143

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

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

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

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