pzgelqfrh.c 6.96 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
#define D(m,n)  D,  (m),  (n)
33

Mathieu Faverge's avatar
Mathieu Faverge committed
34
/*
35
 *  Parallel tile LQ factorization (reduction Householder) - dynamic scheduling
Mathieu Faverge's avatar
Mathieu Faverge committed
36
 */
37
38
void chameleon_pzgelqfrh( int genD, int BS, CHAM_desc_t *A, CHAM_desc_t *T, CHAM_desc_t *D,
                          RUNTIME_sequence_t *sequence, RUNTIME_request_t *request )
39
{
Mathieu Faverge's avatar
Mathieu Faverge committed
40
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
41
    RUNTIME_option_t options;
42
43
44
45
    size_t ws_worker = 0;
    size_t ws_host = 0;

    int k, m, n;
Mathieu Faverge's avatar
Mathieu Faverge committed
46
    int K, N, RD;
47
48
49
50
    int ldak, ldam;
    int tempkmin, tempkm, tempNn, tempnn, tempmm, tempNRDn;
    int ib;

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

Mathieu Faverge's avatar
Mathieu Faverge committed
56
    ib = CHAMELEON_IB;
57

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

     /*
64
65
     * zgelqt = A->nb * (ib+1)
     * zunmlq = A->nb * ib
66
67
     * ztplqt = A->nb * (ib+1)
     * ztpmlq = A->nb * ib
68
69
70
71
     */
    ws_worker = A->nb * (ib+1);

    /* Allocation of temporary (scratch) working space */
Mathieu Faverge's avatar
Mathieu Faverge committed
72
73
74
75
#if defined(CHAMELEON_USE_CUDA)
    /* Worker space
     *
     * zunmqr = A->nb * ib
76
     * ztpmqr = 2 * A->nb * ib
Mathieu Faverge's avatar
Mathieu Faverge committed
77
     */
78
    ws_worker = chameleon_max( ws_worker, ib * A->nb * 2 );
Mathieu Faverge's avatar
Mathieu Faverge committed
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 );

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

    /* The number of the factorization */
    for (k = 0; k < K; k++) {
Mathieu Faverge's avatar
Mathieu Faverge committed
90
        RUNTIME_iteration_push(chamctxt, k);
91

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

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

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

136
                /* TS kernel */
Mathieu Faverge's avatar
Mathieu Faverge committed
137
                INSERT_TASK_ztplqt(
138
                    &options,
139
                    tempkm, tempnn, 0, ib, T->nb,
140
141
142
143
144
145
146
                    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);
147
148
149
150

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

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

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

173
                /* TT kernel */
Mathieu Faverge's avatar
Mathieu Faverge committed
174
                INSERT_TASK_ztplqt(
175
                    &options,
176
                    tempkm, tempNRDn, chameleon_min(tempNRDn, tempkm), ib, T->nb,
177
178
179
180
181
182
183
                    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 );
184
185
186
187
188
189

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

        /* 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 ) );
        }

Mathieu Faverge's avatar
Mathieu Faverge committed
210
        RUNTIME_iteration_pop(chamctxt);
211
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
212

213
    RUNTIME_options_ws_free(&options);
Mathieu Faverge's avatar
Mathieu Faverge committed
214
    RUNTIME_options_finalize(&options, chamctxt);
Mathieu Faverge's avatar
Mathieu Faverge committed
215
    (void)D;
216
}