pzgelqf.c 4.84 KB
Newer Older
1
/**
2 3
 *
 * @file pzgelqf.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 zgelqf 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 LQ factorization - dynamic scheduling
34
 */
35 36
void chameleon_pzgelqf( 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
    size_t ws_worker = 0;
    size_t ws_host = 0;

    int k, m, n;
Mathieu Faverge's avatar
Mathieu Faverge committed
44
    int ldak, ldam, lddk;
45
    int tempkm, tempkn, tempmm, tempnn;
46
    int ib, minMNT;
47

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

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

55
    if (A->m > A->n) {
56
        minMNT = A->nt;
57
    } else {
58
        minMNT = A->mt;
59 60
    }

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

66 67 68 69 70 71 72 73 74
    /*
     * zgelqt = A->nb * (ib+1)
     * zunmlq = A->nb * ib
     * ztslqt = A->nb * (ib+1)
     * ztsmlq = A->nb * ib
     */
    ws_worker = A->nb * (ib+1);

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

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

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );

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

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

129 130
        for (n = k+1; n < A->nt; n++) {
            tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
131 132 133 134

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

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

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

Mathieu Faverge's avatar
Mathieu Faverge committed
149
                INSERT_TASK_ztpmlqt(
150
                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
151
                    ChamRight, ChamConjTrans,
152
                    tempmm, tempnn, A->mb, 0, ib, T->nb,
153
                    A(k, n), ldak,
154 155 156
                    T(k, n), T->mb,
                    A(m, k), ldam,
                    A(m, n), ldam);
157
            }
Mathieu Faverge's avatar
Mathieu Faverge committed
158 159
            RUNTIME_data_flush( sequence, A(k, n) );
            RUNTIME_data_flush( sequence, T(k, n) );
160
        }
161

162 163 164 165 166 167
        /* 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
168
        RUNTIME_iteration_pop(chamctxt);
169
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
170

171
    RUNTIME_options_ws_free(&options);
Mathieu Faverge's avatar
Mathieu Faverge committed
172
    RUNTIME_options_finalize(&options, chamctxt);
Mathieu Faverge's avatar
Mathieu Faverge committed
173
    (void)D;
174
}