pzunglq.c 4.45 KB
Newer Older
1
/**
2 3
 *
 * @file pzunglq.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 zunglq 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
 * @author Hatem Ltaief
 * @author Jakub Kurzak
 * @author Mathieu Faverge
 * @author Emmanuel Agullo
 * @author Cedric Castagnede
22
 * @date 2018-11-09
23 24
 * @precisions normal z -> s d c
 *
25
 */
26
#include "control/common.h"
27 28 29 30

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

33
/**
34
 *  Parallel construction of Q using tile V (application to identity) - dynamic scheduling
35
 */
36 37
void chameleon_pzunglq( int genD, CHAM_desc_t *A, CHAM_desc_t *Q, CHAM_desc_t *T, CHAM_desc_t *D,
                        RUNTIME_sequence_t *sequence, RUNTIME_request_t *request )
38
{
Mathieu Faverge's avatar
Mathieu Faverge committed
39
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
40
    RUNTIME_option_t options;
41 42 43 44
    size_t ws_worker = 0;
    size_t ws_host = 0;

    int k, m, n;
Mathieu Faverge's avatar
Mathieu Faverge committed
45
    int ldak, ldqm, lddk;
46 47 48 49
    int tempnn, tempmm, tempkmin, tempkn;
    int tempAkm, tempAkn;
    int ib, minMT;

Mathieu Faverge's avatar
Mathieu Faverge committed
50
    chamctxt = chameleon_context_self();
Mathieu Faverge's avatar
Mathieu Faverge committed
51
    if (sequence->status != CHAMELEON_SUCCESS) {
52
        return;
Mathieu Faverge's avatar
Mathieu Faverge committed
53
    }
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 (A->m > A->n) {
        minMT = A->nt;
    } else {
        minMT = A->mt;
    }

64 65 66
    if ( D == NULL ) {
        D    = A;
        genD = 0;
67 68
    }

69
    /*
70 71
     * zunmlq  = A->nb * ib
     * ztpmlqt = A->nb * ib
72 73 74 75
     */
    ws_worker = A->nb * ib;

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

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

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );

90
    for (k = minMT-1; k >= 0; k--) {
Mathieu Faverge's avatar
Mathieu Faverge committed
91
        RUNTIME_iteration_push(chamctxt, k);
92

93 94
        tempAkm  = k == A->mt-1 ? A->m-k*A->mb : A->mb;
        tempAkn  = k == A->nt-1 ? A->n-k*A->nb : A->nb;
95
        tempkmin = chameleon_min( tempAkn, tempAkm );
96 97
        tempkn   = k == Q->nt-1 ? Q->n-k*Q->nb : Q->nb;
        ldak = BLKLDD(A, k);
Mathieu Faverge's avatar
Mathieu Faverge committed
98 99
        lddk = BLKLDD(D, k);

100 101 102 103 104
        for (n = Q->nt-1; n > k; n--) {
            tempnn = n == Q->nt-1 ? Q->n-n*Q->nb : Q->nb;
            for (m = 0; m < Q->mt; m++) {
                tempmm = m == Q->mt-1 ? Q->m-m*Q->mb : Q->mb;
                ldqm = BLKLDD(Q, m);
105 106 107 108

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

109
                /* TS kernel */
Mathieu Faverge's avatar
Mathieu Faverge committed
110
                INSERT_TASK_ztpmlqt(
111
                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
112
                    ChamRight, ChamNoTrans,
113
                    tempmm, tempnn, tempAkm, 0, ib, T->nb,
114
                    A(k, n), ldak,
115 116 117
                    T(k, n), T->mb,
                    Q(m, k), ldqm,
                    Q(m, n), ldqm);
118
            }
Mathieu Faverge's avatar
Mathieu Faverge committed
119 120
            RUNTIME_data_flush( sequence, A(k, n) );
            RUNTIME_data_flush( sequence, T(k, n) );
121
        }
122 123 124 125 126 127

        if ( genD ) {
            INSERT_TASK_zlacpy(
                &options,
                ChamUpper, tempkmin, tempkn, A->nb,
                A(k, k), ldak,
Mathieu Faverge's avatar
Mathieu Faverge committed
128
                D(k),    lddk );
Mathieu Faverge's avatar
Mathieu Faverge committed
129
#if defined(CHAMELEON_USE_CUDA)
130 131 132 133
            INSERT_TASK_zlaset(
                &options,
                ChamLower, tempkmin, tempkn,
                0., 1.,
Mathieu Faverge's avatar
Mathieu Faverge committed
134
                D(k), lddk );
135
#endif
136
        }
137
        for (m = k; m < Q->mt; m++) {
138 139
            tempmm = m == Q->mt-1 ? Q->m-m*Q->mb : Q->mb;
            ldqm = BLKLDD(Q, m);
140 141 142 143

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

Mathieu Faverge's avatar
Mathieu Faverge committed
144
            INSERT_TASK_zunmlq(
145
                &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
146
                ChamRight, ChamNoTrans,
147
                tempmm, tempkn, tempkmin, ib, T->nb,
Mathieu Faverge's avatar
Mathieu Faverge committed
148
                D(k),    lddk,
149 150 151
                T(k, k), T->mb,
                Q(m, k), ldqm);
        }
Mathieu Faverge's avatar
Mathieu Faverge committed
152 153
        RUNTIME_data_flush( sequence, D(k)    );
        RUNTIME_data_flush( sequence, T(k, k) );
154

Mathieu Faverge's avatar
Mathieu Faverge committed
155
        RUNTIME_iteration_pop(chamctxt);
156
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
157

158
    RUNTIME_options_ws_free(&options);
Mathieu Faverge's avatar
Mathieu Faverge committed
159
    RUNTIME_options_finalize(&options, chamctxt);
160
}