pzunglqrh.c 5.95 KB
Newer Older
1
/**
2 3
 *
 * @file pzunglqrh.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 zunglqrh 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
 * @author Dulceneia Becker
 * @author Mathieu Faverge
 * @author Emmanuel Agullo
 * @author Cedric Castagnede
 * @date 2011-05-24
 * @precisions normal z -> s d c
 *
24
 */
25
#include "control/common.h"
26 27 28 29 30

#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)
31
#if defined(CHAMELEON_COPY_DIAG)
32
#define D(m,n) D, ((n)/BS), 0
33
#else
34
#define D(m,n) A, (m), (n)
35
#endif
36

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

    int k, m, n;
    int K, N, RD, lastRD;
    int ldak;
    int ldqm;
    int tempkm, tempkmin, tempNn, tempnn, tempmm, tempNRDn;
    int ib;

    morse = morse_context_self();
Mathieu Faverge's avatar
Mathieu Faverge committed
58
    if (sequence->status != CHAMELEON_SUCCESS)
59 60 61
        return;
    RUNTIME_options_init(&options, morse, sequence, request);

Mathieu Faverge's avatar
Mathieu Faverge committed
62
    ib = CHAMELEON_IB;
63 64 65 66 67 68 69 70

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

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

Mathieu Faverge's avatar
Mathieu Faverge committed
80 81
    ws_worker *= sizeof(CHAMELEON_Complex64_t);
    ws_host   *= sizeof(CHAMELEON_Complex64_t);
82 83 84

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );

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

89 90 91 92 93 94 95 96
        tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
        ldak = BLKLDD(A, k);
        lastRD = 0;
        for (RD = BS; RD < A->nt-k; RD *= 2)
            lastRD = RD;
        for (RD = lastRD; RD >= BS; RD /= 2) {
            for (N = k; N+RD < A->nt; N += 2*RD) {
                tempNRDn = N+RD == A->nt-1 ? A->n-(N+RD)*A->nb : A->nb;
97
                for (m = k; m < Q->mt; m++) {
98 99
                    tempmm = m == Q->mt-1 ? Q->m-m*Q->mb : Q->mb;
                    ldqm   = BLKLDD(Q, m   );
100 101 102 103 104 105

                    RUNTIME_data_migrate( sequence, Q(m, N),
                                          Q->get_rankof( Q, m, N+RD ) );
                    RUNTIME_data_migrate( sequence, Q(m, N+RD),
                                          Q->get_rankof( Q, m, N+RD ) );

106
                    /* TT kernel */
Mathieu Faverge's avatar
Mathieu Faverge committed
107
                    INSERT_TASK_ztpmlqt(
108
                        &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
109
                        ChamRight, ChamNoTrans,
110
                        tempmm, tempNRDn, tempkm, tempNRDn, ib, T->nb,
111
                        A (k, N+RD), ldak,
112 113 114
                        T2(k, N+RD), T->mb,
                        Q (m, N   ), ldqm,
                        Q (m, N+RD), ldqm);
115
                }
116

Mathieu Faverge's avatar
Mathieu Faverge committed
117 118
                RUNTIME_data_flush( sequence, A (k, N+RD) );
                RUNTIME_data_flush( sequence, T2(k, N+RD) );
119 120 121 122
            }
        }
        for (N = k; N < A->nt; N += BS) {
            tempNn = N == A->nt-1 ? A->n-N*A->nb : A->nb;
123 124
            tempkmin = chameleon_min(tempkm, tempNn);
            for (n = chameleon_min(N+BS, A->nt)-1; n > N; n--) {
125 126
                tempnn = n == Q->nt-1 ? Q->n-n*Q->nb : Q->nb;

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

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

136
                    /* TS kernel */
Mathieu Faverge's avatar
Mathieu Faverge committed
137
                    INSERT_TASK_ztpmlqt(
138
                        &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
139
                        ChamRight, ChamNoTrans,
140
                        tempmm, tempnn, tempkm, 0, ib, T->nb,
141
                        A(k, n), ldak,
142 143 144
                        T(k, n), T->mb,
                        Q(m, N), ldqm,
                        Q(m, n), ldqm);
145
                }
146

Mathieu Faverge's avatar
Mathieu Faverge committed
147 148
                RUNTIME_data_flush( sequence, A(k, n) );
                RUNTIME_data_flush( sequence, T(k, n) );
149
            }
150
#if defined(CHAMELEON_COPY_DIAG)
Mathieu Faverge's avatar
Mathieu Faverge committed
151
            INSERT_TASK_zlacpy(
152
                &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
153
                ChamUpper, tempkmin, tempNn, A->nb,
154
                A(k, N), ldak,
155
                D(k, N), ldak );
Mathieu Faverge's avatar
Mathieu Faverge committed
156
#if defined(CHAMELEON_USE_CUDA)
Mathieu Faverge's avatar
Mathieu Faverge committed
157
            INSERT_TASK_zlaset(
158
                &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
159
                ChamLower, tempkmin, tempNn,
160
                0., 1.,
161
                D(k, N), ldak );
162
#endif
163 164
#endif
            for (m = k; m < Q->mt; m++) {
165 166
                tempmm = m == Q->mt-1 ? Q->m-m*Q->mb : Q->mb;
                ldqm = BLKLDD(Q, m);
167 168 169 170

                RUNTIME_data_migrate( sequence, Q(m, N),
                                      Q->get_rankof( Q, m, N ) );

Mathieu Faverge's avatar
Mathieu Faverge committed
171
                INSERT_TASK_zunmlq(
172
                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
173
                    ChamRight, ChamNoTrans,
174 175
                    tempmm, tempNn,
                    tempkmin, ib, T->nb,
176
                    D(k, N), ldak,
177 178 179
                    T(k, N), T->mb,
                    Q(m, N), ldqm);
            }
Mathieu Faverge's avatar
Mathieu Faverge committed
180 181
            RUNTIME_data_flush( sequence, D(k, N) );
            RUNTIME_data_flush( sequence, T(k, N) );
182
        }
183
        RUNTIME_iteration_pop(morse);
184
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
185

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