Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

pzunglqrh.c 5.93 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
    int tempkm, tempkmin, tempNn, tempnn, tempmm, tempNRDn;
51
    int ib, node;
52

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

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

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

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

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

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

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );

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

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

103 104 105
                    node = Q->get_rankof( Q, m, N+RD );
                    RUNTIME_data_migrate( sequence, Q(m, N),    node );
                    RUNTIME_data_migrate( sequence, Q(m, N+RD), node );
106

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

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 151 152 153 154 155

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

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

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

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