pztrtri.c 5.06 KB
Newer Older
1
/**
2 3
 *
 * @file pztrtri.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
 *
10
 ***
11
 *
12
 * @brief Chameleon ztrtri parallel algorithm
13
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
14
 * @version 1.0.0
15
 * @comment This file has been automatically generated
16
 *          from Plasma 2.5.0 for CHAMELEON 1.0.0
17 18 19 20 21 22 23 24
 * @author Julien Langou
 * @author Henricus Bouwmeester
 * @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

#define A(m,n) A,  m,  n
29
/**
30
 *  Parallel tile triangular matrix inverse - dynamic scheduling
31
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
32
void chameleon_pztrtri(cham_uplo_t uplo, cham_diag_t diag, CHAM_desc_t *A,
33
                          RUNTIME_sequence_t *sequence, RUNTIME_request_t *request)
34
{
Mathieu Faverge's avatar
Mathieu Faverge committed
35
    CHAM_context_t *chamctxt;
36
    RUNTIME_option_t options;
37 38

    int k, m, n;
39 40
    int ldam, ldak;
    int tempkn, tempkm, tempmm, tempnn;
41

42 43
    CHAMELEON_Complex64_t zone  = (CHAMELEON_Complex64_t) 1.0;
    CHAMELEON_Complex64_t mzone = (CHAMELEON_Complex64_t)-1.0;
44

Mathieu Faverge's avatar
Mathieu Faverge committed
45
    chamctxt = chameleon_context_self();
Mathieu Faverge's avatar
Mathieu Faverge committed
46
    if (sequence->status != CHAMELEON_SUCCESS) {
47
        return;
Mathieu Faverge's avatar
Mathieu Faverge committed
48
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
49
    RUNTIME_options_init(&options, chamctxt, sequence, request);
50
    /*
51
     *  ChamLower
52
     */
53
    if (uplo == ChamLower) {
54
        for (k = 0; k < A->nt; k++) {
Mathieu Faverge's avatar
Mathieu Faverge committed
55
            RUNTIME_iteration_push(chamctxt, k);
56

57 58 59
            tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
            ldak = BLKLDD(A, k);
            for (m = k+1; m < A->mt; m++) {
60 61
                tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
                ldam = BLKLDD(A, m);
62
                INSERT_TASK_ztrsm(
63
                    &options,
64
                    ChamRight, uplo, ChamNoTrans, diag,
65 66 67
                    tempmm, tempkn, A->mb,
                    mzone, A(k, k), ldak,
                           A(m, k), ldam);
68
            }
69
            for (m = k+1; m < A->mt; m++) {
70 71
                tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
                ldam = BLKLDD(A, m);
72
                for (n = 0; n < k; n++) {
73
                    INSERT_TASK_zgemm(
74
                        &options,
75
                        ChamNoTrans, ChamNoTrans,
76 77 78 79
                        tempmm, A->nb, tempkn, A->mb,
                        zone, A(m, k), ldam,
                              A(k, n), ldak,
                        zone, A(m, n), ldam);
80
                }
81
                RUNTIME_data_flush( sequence, A(m, k) );
82
            }
83
            for (n = 0; n < k; n++) {
84
                RUNTIME_data_flush( sequence, A(k, n) );
85
                INSERT_TASK_ztrsm(
86
                    &options,
87
                    ChamLeft, uplo, ChamNoTrans, diag,
88 89 90
                    tempkn, A->nb, A->mb,
                    zone, A(k, k), ldak,
                          A(k, n), ldak);
91
            }
92
            RUNTIME_data_flush( sequence, A(k, k) );
93
            INSERT_TASK_ztrtri(
94 95
                &options,
                uplo, diag,
96 97
                tempkn, A->mb,
                A(k, k), ldak, A->nb*k);
98

Mathieu Faverge's avatar
Mathieu Faverge committed
99
            RUNTIME_iteration_pop(chamctxt);
100 101 102
        }
    }
    /*
103
     *  ChamUpper
104 105
     */
    else {
106
        for (k = 0; k < A->mt; k++) {
Mathieu Faverge's avatar
Mathieu Faverge committed
107
            RUNTIME_iteration_push(chamctxt, k);
108

109 110 111
            tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
            ldak = BLKLDD(A, k);
            for (n = k+1; n < A->nt; n++) {
112
                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
113
                INSERT_TASK_ztrsm(
114
                    &options,
115
                    ChamLeft, uplo, ChamNoTrans, diag,
116 117 118
                    tempkm, tempnn, A->mb,
                    mzone, A(k, k), ldak,
                           A(k, n), ldak);
119
            }
120
            for (n = k+1; n < A->nt; n++) {
121
                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
122 123
                for (m = 0; m < k; m++) {
                    ldam = BLKLDD(A, m);
124
                    INSERT_TASK_zgemm(
125
                        &options,
126
                        ChamNoTrans, ChamNoTrans,
127 128 129 130
                        A->mb, tempnn, tempkm, A->mb,
                        zone, A(m, k), ldam,
                              A(k, n), ldak,
                        zone, A(m, n), ldam);
131
                }
132
                RUNTIME_data_flush( sequence, A(k, n) );
133 134 135
            }
            for (m = 0; m < k; m++) {
                ldam = BLKLDD(A, m);
136
                RUNTIME_data_flush( sequence, A(m, k) );
137
                INSERT_TASK_ztrsm(
138
                    &options,
139
                    ChamRight, uplo, ChamNoTrans, diag,
140 141 142
                    A->mb, tempkm, A->mb,
                    zone, A(k, k), ldak,
                          A(m, k), ldam);
143
            }
144
            RUNTIME_data_flush( sequence, A(k, k) );
145
            INSERT_TASK_ztrtri(
146 147
                &options,
                uplo, diag,
148 149
                tempkm, A->mb,
                A(k, k), ldak, A->mb*k);
150

Mathieu Faverge's avatar
Mathieu Faverge committed
151
            RUNTIME_iteration_pop(chamctxt);
152 153
        }
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
154
    RUNTIME_options_finalize(&options, chamctxt);
155
}