pzgelqfrh.c 7.02 KB
Newer Older
1
/**
2 3
 *
 * @file pzgelqfrh.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-2018 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 zgelqfrh 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 Jakub Kurzak
 * @author Hatem Ltaief
 * @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

Mathieu Faverge's avatar
Mathieu Faverge committed
29 30
#define A(m,n)  A,  (m),  (n)
#define T(m,n)  T,  (m),  (n)
31
#define T2(m,n) T,  (m),  (n)+A->nt
32
#if defined(CHAMELEON_COPY_DIAG)
33
#define D(m,n) D, ((n)/BS), 0
34
#else
35
#define D(m,n) A,  (m),  (n)
36
#endif
37

Mathieu Faverge's avatar
Mathieu Faverge committed
38
/*
39
 *  Parallel tile LQ factorization (reduction Householder) - dynamic scheduling
Mathieu Faverge's avatar
Mathieu Faverge committed
40
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
41 42
void morse_pzgelqfrh(CHAM_desc_t *A, CHAM_desc_t *T, CHAM_desc_t *D, int BS,
                     RUNTIME_sequence_t *sequence, RUNTIME_request_t *request)
43
{
Mathieu Faverge's avatar
Mathieu Faverge committed
44 45
    CHAM_context_t *morse;
    RUNTIME_option_t options;
46 47 48 49
    size_t ws_worker = 0;
    size_t ws_host = 0;

    int k, m, n;
Mathieu Faverge's avatar
Mathieu Faverge committed
50
    int K, N, RD;
51 52 53 54 55
    int ldak, ldam;
    int tempkmin, tempkm, tempNn, tempnn, tempmm, tempNRDn;
    int ib;

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

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

    /*
     * zgelqt = A->nb * (ib+1)
     * zunmlq = A->nb * ib
     * ztslqt = A->nb * (ib+1)
     * zttlqt = A->nb * (ib+1)
     * ztsmlq = A->nb * ib
     * zttmlq = A->nb * ib
     */
    ws_worker = A->nb * (ib+1);

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

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

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );

Mathieu Faverge's avatar
Mathieu Faverge committed
87 88 89 90
    K = chameleon_min(A->mt, A->nt);

    /* The number of the factorization */
    for (k = 0; k < K; k++) {
91
        RUNTIME_iteration_push(morse, k);
92

93 94 95 96
        tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
        ldak = BLKLDD(A, k);
        for (N = k; N < A->nt; N += BS) {
            tempNn = N == A->nt-1 ? A->n-N*A->nb : A->nb;
97
            tempkmin = chameleon_min(tempkm, tempNn);
Mathieu Faverge's avatar
Mathieu Faverge committed
98
            INSERT_TASK_zgelqt(
99 100 101 102
                &options,
                tempkm, tempNn, ib, T->nb,
                A(k, N), ldak,
                T(k, N), T->mb);
Mathieu Faverge's avatar
Mathieu Faverge committed
103
            if ( k < (A->mt-1) ) {
104
#if defined(CHAMELEON_COPY_DIAG)
Mathieu Faverge's avatar
Mathieu Faverge committed
105
                INSERT_TASK_zlacpy(
Mathieu Faverge's avatar
Mathieu Faverge committed
106
                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
107
                    ChamUpper, tempkm, tempNn, A->nb,
Mathieu Faverge's avatar
Mathieu Faverge committed
108
                    A(k, N), ldak,
109
                    D(k, N), ldak );
Mathieu Faverge's avatar
Mathieu Faverge committed
110
#if defined(CHAMELEON_USE_CUDA)
Mathieu Faverge's avatar
Mathieu Faverge committed
111
                INSERT_TASK_zlaset(
Mathieu Faverge's avatar
Mathieu Faverge committed
112
                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
113
                    ChamLower, tempkm, tempNn,
Mathieu Faverge's avatar
Mathieu Faverge committed
114
                    0., 1.,
115
                    D(k, N), ldak );
116
#endif
117
#endif
Mathieu Faverge's avatar
Mathieu Faverge committed
118
            }
119 120 121
            for (m = k+1; m < A->mt; m++) {
                tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
                ldam = BLKLDD(A, m);
Mathieu Faverge's avatar
Mathieu Faverge committed
122
                INSERT_TASK_zunmlq(
123
                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
124
                    ChamRight, ChamConjTrans,
125
                    tempmm, tempNn, tempkmin, ib, T->nb,
126
                    D(k, N), ldak,
127 128 129
                    T(k, N), T->mb,
                    A(m, N), ldam);
            }
Mathieu Faverge's avatar
Mathieu Faverge committed
130 131
            RUNTIME_data_flush( sequence, D(k, N) );
            RUNTIME_data_flush( sequence, T(k, N) );
132

133
            for (n = N+1; n < chameleon_min(N+BS, A->nt); n++) {
134
                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
135 136 137 138

                RUNTIME_data_migrate( sequence, A(k, N),
                                      A->get_rankof( A, k, n ) );

139
                /* TS kernel */
Mathieu Faverge's avatar
Mathieu Faverge committed
140
                INSERT_TASK_ztplqt(
141
                    &options,
142
                    tempkm, tempnn, 0, ib, T->nb,
143 144 145 146 147 148 149
                    A(k, N), ldak,
                    A(k, n), ldak,
                    T(k, n), T->mb);

                for (m = k+1; m < A->mt; m++) {
                    tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
                    ldam = BLKLDD(A, m);
150 151 152 153

                    RUNTIME_data_migrate( sequence, A(m, N),
                                          A->get_rankof( A, m, n ) );

Mathieu Faverge's avatar
Mathieu Faverge committed
154
                    INSERT_TASK_ztpmlqt(
155
                        &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
156
                        ChamRight, ChamConjTrans,
157
                        tempmm, tempnn, tempkm, 0, ib, T->nb,
158
                        A(k, n), ldak,
159 160 161
                        T(k, n), T->mb,
                        A(m, N), ldam,
                        A(m, n), ldam);
162
                }
Mathieu Faverge's avatar
Mathieu Faverge committed
163 164
                RUNTIME_data_flush( sequence, A(k, n) );
                RUNTIME_data_flush( sequence, T(k, n) );
165 166 167 168 169
            }
        }
        for (RD = BS; RD < A->nt-k; 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;
170 171 172 173 174 175

                RUNTIME_data_migrate( sequence, A(k, N),
                                      A->get_rankof( A, k, N+RD ) );
                RUNTIME_data_migrate( sequence, A(k, N+RD),
                                      A->get_rankof( A, k, N+RD ) );

176
                /* TT kernel */
Mathieu Faverge's avatar
Mathieu Faverge committed
177
                INSERT_TASK_ztplqt(
178
                    &options,
179
                    tempkm, tempNRDn, chameleon_min(tempNRDn, tempkm), ib, T->nb,
180 181 182 183 184 185 186
                    A (k, N   ), ldak,
                    A (k, N+RD), ldak,
                    T2(k, N+RD), T->mb);

                for (m = k+1; m < A->mt; m++) {
                    tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
                    ldam   = BLKLDD(A, m );
187 188 189 190 191 192

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

Mathieu Faverge's avatar
Mathieu Faverge committed
193
                    INSERT_TASK_ztpmlqt(
194
                        &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
195
                        ChamRight, ChamConjTrans,
196
                        tempmm, tempNRDn, tempkm, tempNRDn, ib, T->nb,
197
                        A (k, N+RD), ldak,
198 199 200
                        T2(k, N+RD), T->mb,
                        A (m, N   ), ldam,
                        A (m, N+RD), ldam);
201
                }
Mathieu Faverge's avatar
Mathieu Faverge committed
202 203
                RUNTIME_data_flush( sequence, A (k, N+RD) );
                RUNTIME_data_flush( sequence, T2(k, N+RD) );
204 205
            }
        }
206 207 208 209 210 211 212

        /* Restore the original location of the tiles */
        for (m = k; m < A->mt; m++) {
            RUNTIME_data_migrate( sequence, A(m, k),
                                  A->get_rankof( A, m, k ) );
        }

213
        RUNTIME_iteration_pop(morse);
214
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
215

216 217
    RUNTIME_options_ws_free(&options);
    RUNTIME_options_finalize(&options, morse);
Mathieu Faverge's avatar
Mathieu Faverge committed
218
    (void)D;
219
}