pzgelqf.c 4.89 KB
Newer Older
1
2
/**
 *
3
4
 * @copyright (c) 2009-2014 The University of Tennessee and The University
 *                          of Tennessee Research Foundation.
5
 *                          All rights reserved.
6
 * @copyright (c) 2012-2016 Inria. All rights reserved.
7
 * @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 *
 **/

/**
 *
 * @file pzgelqf.c
 *
 *  MORSE auxiliary routines
 *  MORSE is a software package provided by Univ. of Tennessee,
 *  Univ. of California Berkeley and Univ. of Colorado Denver
 *
 * @version 2.5.0
 * @comment This file has been automatically generated
 *          from Plasma 2.5.0 for MORSE 1.0.0
 * @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
 *
 **/
31
#include "control/common.h"
32
33
34

#define A(m,n) A,  m,  n
#define T(m,n) T,  m,  n
35
#if defined(CHAMELEON_COPY_DIAG)
36
#define D(k)   D, k, 0
37
#else
38
#define D(k)   D, k, k
39
#endif
40

Mathieu Faverge's avatar
Mathieu Faverge committed
41
/*******************************************************************************
42
43
 *  Parallel tile LQ factorization - dynamic scheduling
 **/
44
void morse_pzgelqf(MORSE_desc_t *A, MORSE_desc_t *T, MORSE_desc_t *D,
45
46
47
48
49
50
51
52
53
54
                   MORSE_sequence_t *sequence, MORSE_request_t *request)
{
    MORSE_context_t *morse;
    MORSE_option_t options;
    size_t ws_worker = 0;
    size_t ws_host = 0;

    int k, m, n;
    int ldak, ldam;
    int tempkm, tempkn, tempmm, tempnn;
55
    int ib, minMNT;
56
57
58
59
60
61
62
63

    morse = morse_context_self();
    if (sequence->status != MORSE_SUCCESS)
        return;
    RUNTIME_options_init(&options, morse, sequence, request);

    ib = MORSE_IB;

64
    if (A->m > A->n) {
65
        minMNT = A->nt;
66
    } else {
67
        minMNT = A->mt;
68
69
    }

70
71
72
73
    if ( D == NULL ) {
        D = A;
    }

74
75
76
77
78
79
80
81
82
    /*
     * 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
83
84
85
86
87
88
#if defined(CHAMELEON_USE_CUDA)
    /* Worker space
     *
     * zunmqr = A->nb * ib
     * ztsmqr = 2 * A->nb * ib
     */
89
    ws_worker = chameleon_max( ws_worker, ib * A->nb * 2 );
Mathieu Faverge's avatar
Mathieu Faverge committed
90
91
#endif

92
93
94
95
96
    ws_worker *= sizeof(MORSE_Complex64_t);
    ws_host   *= sizeof(MORSE_Complex64_t);

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );

97
    for (k = 0; k < minMNT; k++) {
98
        RUNTIME_iteration_push(morse, k);
99

100
101
102
103
104
105
106
107
108
        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);
        MORSE_TASK_zgelqt(
            &options,
            tempkm, tempkn, ib, T->nb,
            A(k, k), ldak,
            T(k, k), T->mb);
        if ( k < (A->mt-1) ) {
109
#if defined(CHAMELEON_COPY_DIAG)
110
111
112
113
            MORSE_TASK_zlacpy(
                &options,
                MorseUpper, A->mb, A->nb, A->nb,
                A(k, k), ldak,
114
                D(k), ldak );
Mathieu Faverge's avatar
Mathieu Faverge committed
115
#if defined(CHAMELEON_USE_CUDA)
116
117
118
119
            MORSE_TASK_zlaset(
                &options,
                MorseLower, A->mb, A->nb,
                0., 1.,
120
                D(k), ldak );
121
#endif
122
#endif
123
        }
124
125
126
127
128
129
130
        for (m = k+1; m < A->mt; m++) {
            tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
            ldam = BLKLDD(A, m);
            MORSE_TASK_zunmlq(
                &options,
                MorseRight, MorseConjTrans,
                tempmm, tempkn, tempkn, ib, T->nb,
131
                D(k), ldak,
132
133
134
135
136
                T(k, k), T->mb,
                A(m, k), ldam);
        }
        for (n = k+1; n < A->nt; n++) {
            tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
137
138
139
140

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

141
            /* TS kernel */
142
            MORSE_TASK_ztplqt(
143
                &options,
144
                tempkm, tempnn, 0, ib, T->nb,
145
146
147
148
149
150
                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);
151
152
153
154
155

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

                MORSE_TASK_ztpmlqt(
156
157
                    &options,
                    MorseRight, MorseConjTrans,
158
                    tempmm, tempnn, A->mb, 0, ib, T->nb,
159
                    A(k, n), ldak,
160
161
162
                    T(k, n), T->mb,
                    A(m, k), ldam,
                    A(m, n), ldam);
163
164
            }
        }
165

166
167
168
169
170
171
        /* 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 ) );
        }

172
        RUNTIME_iteration_pop(morse);
173
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
174

175
176
    RUNTIME_options_ws_free(&options);
    RUNTIME_options_finalize(&options, morse);
Mathieu Faverge's avatar
Mathieu Faverge committed
177
    (void)D;
178
}