pzunglqrh.c 6.05 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.
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 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
#define A(m,n)  A,  (m),  (n)
#define Q(m,n)  Q,  (m),  (n)
#define T(m,n)  T,  (m),  (n)
30
#define T2(m,n) T,  (m),  (n)+(A->nt)
31
#define D(m,n)  D,  (m),  (n)
32

33 34 35
/**
 *  Parallel construction of Q using tile V (application to identity;
 *  reduction Householder) - dynamic scheduling
36
 */
37 38 39 40
void chameleon_pzunglqrh( 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 )
41
{
Mathieu Faverge's avatar
Mathieu Faverge committed
42
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
43
    RUNTIME_option_t options;
44 45 46 47 48
    size_t ws_worker = 0;
    size_t ws_host = 0;

    int k, m, n;
    int K, N, RD, lastRD;
Mathieu Faverge's avatar
Mathieu Faverge committed
49
    int ldak, lddk, ldqm;
50 51 52
    int tempkm, tempkmin, tempNn, tempnn, tempmm, tempNRDn;
    int ib;

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

Mathieu Faverge's avatar
Mathieu Faverge committed
58
    ib = CHAMELEON_IB;
59

60 61 62 63 64
    if ( D == NULL ) {
        D    = A;
        genD = 0;
    }

65 66
    /*
     * zunmqr = A->nb * ib
67
     * ztpmqr = A->nb * ib
68 69 70
     */
    ws_worker = A->nb * ib;

Mathieu Faverge's avatar
Mathieu Faverge committed
71
#if defined(CHAMELEON_USE_CUDA)
72 73 74
    /* Worker space
     *
     * zunmqr = A->nb * ib
75
     * ztpmqr = 2 * A->nb * ib
76
     */
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--) {
Mathieu Faverge's avatar
Mathieu Faverge committed
87
        RUNTIME_iteration_push(chamctxt, k);
88

89 90
        tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
        ldak = BLKLDD(A, k);
Mathieu Faverge's avatar
Mathieu Faverge committed
91
        lddk = BLKLDD(D, k);
92 93 94 95 96 97
        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;
98
                for (m = k; m < Q->mt; m++) {
99 100
                    tempmm = m == Q->mt-1 ? Q->m-m*Q->mb : Q->mb;
                    ldqm   = BLKLDD(Q, m   );
101 102 103 104 105 106

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

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

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

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

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

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

Mathieu Faverge's avatar
Mathieu Faverge committed
148 149
                RUNTIME_data_flush( sequence, A(k, n) );
                RUNTIME_data_flush( sequence, T(k, n) );
150
            }
151 152 153 154 155 156

            if ( genD ) {
                INSERT_TASK_zlacpy(
                    &options,
                    ChamUpper, tempkmin, tempNn, A->nb,
                    A(k, N), ldak,
Mathieu Faverge's avatar
Mathieu Faverge committed
157
                    D(k, N), lddk );
Mathieu Faverge's avatar
Mathieu Faverge committed
158
#if defined(CHAMELEON_USE_CUDA)
159 160 161 162
                INSERT_TASK_zlaset(
                    &options,
                    ChamLower, tempkmin, tempNn,
                    0., 1.,
Mathieu Faverge's avatar
Mathieu Faverge committed
163
                    D(k, N), lddk );
164
#endif
165
            }
166
            for (m = k; m < Q->mt; m++) {
167 168
                tempmm = m == Q->mt-1 ? Q->m-m*Q->mb : Q->mb;
                ldqm = BLKLDD(Q, m);
169 170 171 172

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

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

188
    RUNTIME_options_ws_free(&options);
Mathieu Faverge's avatar
Mathieu Faverge committed
189
    RUNTIME_options_finalize(&options, chamctxt);
Mathieu Faverge's avatar
Mathieu Faverge committed
190
    (void)D;
191
}