pzsytrf.c 5 KB
Newer Older
1
/**
2 3
 *
 * @file pzsytrf.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-2014 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 zsytrf parallel algorithm
13 14 15 16 17 18 19 20 21 22 23 24
 *
 * @version 1.0.0
 * @author Jakub Kurzak
 * @author Hatem Ltaief
 * @author Mathieu Faverge
 * @author Emmanuel Agullo
 * @author Cedric Castagnede
 * @author Florent Pruvost
 * @author Marc Sergent
 * @date 2014-10-09
 * @precisions normal z -> c
 *
25
 */
26
#include "control/common.h"
27 28

#define A(m,n) A,  m,  n
29
/**
30
 *  Parallel tile Cholesky factorization - dynamic scheduling
31
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
32
void chameleon_pzsytrf(cham_uplo_t uplo, CHAM_desc_t *A,
Mathieu Faverge's avatar
Mathieu Faverge committed
33
                   RUNTIME_sequence_t *sequence, RUNTIME_request_t *request)
34
{
Mathieu Faverge's avatar
Mathieu Faverge committed
35
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
36
    RUNTIME_option_t options;
37 38 39 40 41 42

    int k, m, n;
    int ldak, ldam, ldan;
    int tempkm, tempmm, tempnn;
    size_t ws_host   = 0;

Mathieu Faverge's avatar
Mathieu Faverge committed
43 44
    CHAMELEON_Complex64_t zone  = (CHAMELEON_Complex64_t) 1.0;
    CHAMELEON_Complex64_t mzone = (CHAMELEON_Complex64_t)-1.0;
45

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

    RUNTIME_options_ws_alloc( &options, 0, ws_host );

    /*
Mathieu Faverge's avatar
Mathieu Faverge committed
54
     *  ChamLower
55
     */
Mathieu Faverge's avatar
Mathieu Faverge committed
56
    if (uplo == ChamLower) {
57
        for (k = 0; k < A->mt; k++) {
Mathieu Faverge's avatar
Mathieu Faverge committed
58
            RUNTIME_iteration_push(chamctxt, k);
59

60 61 62
            tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
            ldak = BLKLDD(A, k);

Mathieu Faverge's avatar
Mathieu Faverge committed
63
            INSERT_TASK_zsytrf_nopiv(
64
                &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
65
                ChamLower, tempkm, A->mb,
66 67 68 69 70
                A(k, k), ldak, A->nb*k);

            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
71
                INSERT_TASK_ztrsm(
72
                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
73
                    ChamRight, ChamLower, ChamTrans, ChamNonUnit,
74 75 76 77
                    tempmm, A->mb, A->mb,
                    zone, A(k, k), ldak,
                          A(m, k), ldam);
            }
78
            RUNTIME_data_flush( sequence, A(k, k) );
79 80 81 82

            for (n = k+1; n < A->nt; n++) {
                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
                ldan = BLKLDD(A, n);
Mathieu Faverge's avatar
Mathieu Faverge committed
83
                INSERT_TASK_zsyrk(
84
                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
85
                    ChamLower, ChamNoTrans,
86 87 88 89 90 91 92
                    tempnn, A->nb, A->mb,
                    -1.0, A(n, k), ldan,
                     1.0, A(n, n), ldan);

                for (m = n+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
93
                    INSERT_TASK_zgemm(
94
                        &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
95
                        ChamNoTrans, ChamTrans,
96 97 98 99 100
                        tempmm, tempnn, A->mb, A->mb,
                        mzone, A(m, k), ldam,
                               A(n, k), ldan,
                        zone,  A(m, n), ldam);
                }
101
                RUNTIME_data_flush( sequence, A(n, k) );
102
            }
103

Mathieu Faverge's avatar
Mathieu Faverge committed
104
            RUNTIME_iteration_pop(chamctxt);
105 106 107
        }
    }
    /*
Mathieu Faverge's avatar
Mathieu Faverge committed
108
     *  ChamUpper
109 110 111
     */
    else {
        for (k = 0; k < A->nt; k++) {
Mathieu Faverge's avatar
Mathieu Faverge committed
112
            RUNTIME_iteration_push(chamctxt, k);
113

114 115
            tempkm = k == A->nt-1 ? A->n-k*A->nb : A->nb;
            ldak = BLKLDD(A, k);
Mathieu Faverge's avatar
Mathieu Faverge committed
116
            INSERT_TASK_zsytrf_nopiv(
117
                &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
118
                ChamUpper,
119 120 121 122 123
                tempkm, A->mb,
                A(k, k), ldak, A->nb*k);

            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
124
                INSERT_TASK_ztrsm(
125
                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
126
                    ChamLeft, ChamUpper, ChamTrans, ChamNonUnit,
127 128 129 130
                    A->mb, tempnn, A->mb,
                    zone, A(k, k), ldak,
                          A(k, n), ldak);
            }
131
            RUNTIME_data_flush( sequence, A(k, k) );
132 133 134 135 136

            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
137
                INSERT_TASK_zsyrk(
138
                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
139
                    ChamUpper, ChamTrans,
140 141 142 143 144 145 146
                    tempmm, A->mb, A->mb,
                    -1.0, A(k, m), ldak,
                     1.0, A(m, m), ldam);

                for (n = m+1; n < A->nt; n++) {
                    tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;

Mathieu Faverge's avatar
Mathieu Faverge committed
147
                    INSERT_TASK_zgemm(
148
                        &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
149
                        ChamTrans, ChamNoTrans,
150 151 152 153 154
                        tempmm, tempnn, A->mb, A->mb,
                        mzone, A(k, m), ldak,
                               A(k, n), ldak,
                        zone,  A(m, n), ldam);
                }
155
                RUNTIME_data_flush( sequence, A(k, m) );
156
            }
157

Mathieu Faverge's avatar
Mathieu Faverge committed
158
            RUNTIME_iteration_pop(chamctxt);
159 160 161 162
        }
    }

    RUNTIME_options_ws_free(&options);
Mathieu Faverge's avatar
Mathieu Faverge committed
163
    RUNTIME_options_finalize(&options, chamctxt);
164
}