pzgeqrf.c 4.74 KB
Newer Older
1
/**
2 3
 *
 * @file pzgeqrf.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 zgeqrf 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
 * @author Jakub Kurzak
 * @author Hatem Ltaief
 * @author Mathieu Faverge
 * @author Emmanuel Agullo
 * @author Cedric Castagnede
 * @date 2010-11-15
 * @precisions normal z -> s d c
 *
25
 */
26
#include "control/common.h"
27 28 29

#define A(m,n) A,  m,  n
#define T(m,n) T,  m,  n
30
#define D(k)   D,  k,  k
31

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

    int k, m, n;
    int ldak, ldam;
    int tempkm, tempkn, tempnn, tempmm;
    int ib;
47
    int minMNT = chameleon_min(A->mt, A->nt);
48

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

Mathieu Faverge's avatar
Mathieu Faverge committed
54
    ib = CHAMELEON_IB;
55

56
    if ( D == NULL ) {
57 58
        D    = A;
        genD = 0;
59 60
    }

61 62 63 64 65 66 67 68 69
    /*
     * zgeqrt = A->nb * (ib+1)
     * zunmqr = A->nb * ib
     * ztsqrt = A->nb * (ib+1)
     * ztsmqr = A->nb * ib
     */
    ws_worker = A->nb * (ib+1);

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

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

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );

    for (k = 0; k < minMNT; k++) {
Mathieu Faverge's avatar
Mathieu Faverge committed
85
        RUNTIME_iteration_push(chamctxt, k);
86

87 88 89
        tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
        tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
        ldak = BLKLDD(A, k);
Mathieu Faverge's avatar
Mathieu Faverge committed
90
        INSERT_TASK_zgeqrt(
91 92 93 94
            &options,
            tempkm, tempkn, ib, T->nb,
            A(k, k), ldak,
            T(k, k), T->mb);
95
        if ( genD ) {
Mathieu Faverge's avatar
Mathieu Faverge committed
96
            INSERT_TASK_zlacpy(
97
                &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
98
                ChamLower, A->mb, A->nb, A->nb,
99
                A(k, k), ldak,
100
                D(k), ldak );
Mathieu Faverge's avatar
Mathieu Faverge committed
101
#if defined(CHAMELEON_USE_CUDA)
Mathieu Faverge's avatar
Mathieu Faverge committed
102
            INSERT_TASK_zlaset(
103
                &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
104
                ChamUpper, A->mb, A->nb,
105
                0., 1.,
106
                D(k), ldak );
107
#endif
108
        }
109 110
        for (n = k+1; n < A->nt; n++) {
            tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
Mathieu Faverge's avatar
Mathieu Faverge committed
111
            INSERT_TASK_zunmqr(
112
                &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
113
                ChamLeft, ChamConjTrans,
114
                tempkm, tempnn, tempkm, ib, T->nb,
115
                D(k), ldak,
116 117 118
                T(k, k), T->mb,
                A(k, n), ldak);
        }
Mathieu Faverge's avatar
Mathieu Faverge committed
119 120
        RUNTIME_data_flush( sequence, D(k)    );
        RUNTIME_data_flush( sequence, T(k, k) );
121

122 123 124
        for (m = k+1; m < A->mt; m++) {
            tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
            ldam = BLKLDD(A, m);
125 126 127 128

            RUNTIME_data_migrate( sequence, A(k, k),
                                  A->get_rankof( A, m, k ) );

129
            /* TS kernel */
Mathieu Faverge's avatar
Mathieu Faverge committed
130
            INSERT_TASK_ztpqrt(
131
                &options,
132
                tempmm, tempkn, 0, ib, T->nb,
133 134 135
                A(k, k), ldak,
                A(m, k), ldam,
                T(m, k), T->mb);
136

137 138
            for (n = k+1; n < A->nt; n++) {
                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
139 140 141 142

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

143
                /* TS kernel */
Mathieu Faverge's avatar
Mathieu Faverge committed
144
                INSERT_TASK_ztpmqrt(
145
                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
146
                    ChamLeft, ChamConjTrans,
147
                    tempmm, tempnn, A->nb, 0, ib, T->nb,
148
                    A(m, k), ldam,
149 150 151
                    T(m, k), T->mb,
                    A(k, n), ldak,
                    A(m, n), ldam);
152
            }
Mathieu Faverge's avatar
Mathieu Faverge committed
153 154
            RUNTIME_data_flush( sequence, A(m, k) );
            RUNTIME_data_flush( sequence, T(m, k) );
155
        }
156

157 158 159 160 161 162
        /* Restore the original location of the tiles */
        for (n = k; n < A->nt; n++) {
            RUNTIME_data_migrate( sequence, A(k, n),
                                  A->get_rankof( A, k, n ) );
        }

Mathieu Faverge's avatar
Mathieu Faverge committed
163
        RUNTIME_iteration_pop(chamctxt);
164
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
165

166
    RUNTIME_options_ws_free(&options);
Mathieu Faverge's avatar
Mathieu Faverge committed
167
    RUNTIME_options_finalize(&options, chamctxt);
Mathieu Faverge's avatar
Mathieu Faverge committed
168
    (void)D;
169
}