pztrtri.c 5.2 KB
Newer Older
1 2
/**
 *
3 4
 * @copyright (c) 2009-2014 The University of Tennessee and The University
 *                          of Tennessee Research Foundation.
5 6
 *                          All rights reserved.
 * @copyright (c) 2012-2014 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 pztrtri.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 Julien Langou
 * @author Henricus Bouwmeester
 * @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 35 36 37 38 39 40 41 42 43

#define A(m,n) A,  m,  n
/***************************************************************************//**
 *  Parallel tile triangular matrix inverse - dynamic scheduling
 **/
void morse_pztrtri(MORSE_enum uplo, MORSE_enum diag, MORSE_desc_t *A,
                          MORSE_sequence_t *sequence, MORSE_request_t *request)
{
    MORSE_context_t *morse;
    MORSE_option_t options;

    int k, m, n;
44 45
    int ldam, ldak;
    int tempkn, tempkm, tempmm, tempnn;
46 47 48 49 50 51 52 53 54 55 56 57

    MORSE_Complex64_t zone  = (MORSE_Complex64_t) 1.0;
    MORSE_Complex64_t mzone = (MORSE_Complex64_t)-1.0;

    morse = morse_context_self();
    if (sequence->status != MORSE_SUCCESS)
        return;
    RUNTIME_options_init(&options, morse, sequence, request);
    /*
     *  MorseLower
     */
    if (uplo == MorseLower) {
58
        for (k = 0; k < A->nt; k++) {
59 60
            RUNTIME_set_iteration(k);

61 62 63
            tempkn = k == A->nt-1 ? A->n-k*A->nb : A->nb;
            ldak = BLKLDD(A, k);
            for (m = k+1; m < A->mt; m++) {
64 65 66 67 68
                tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
                ldam = BLKLDD(A, m);
                MORSE_TASK_ztrsm(
                    &options,
                    MorseRight, uplo, MorseNoTrans, diag,
69 70 71
                    tempmm, tempkn, A->mb,
                    mzone, A(k, k), ldak,
                           A(m, k), ldam);
72
            }
73
            for (m = k+1; m < A->mt; m++) {
74 75
                tempmm = m == A->mt-1 ? A->m-m*A->mb : A->mb;
                ldam = BLKLDD(A, m);
76
                for (n = 0; n < k; n++) {
77 78 79
                    MORSE_TASK_zgemm(
                        &options,
                        MorseNoTrans, MorseNoTrans,
80 81 82 83
                        tempmm, A->nb, tempkn, A->mb,
                        zone, A(m, k), ldam,
                              A(k, n), ldak,
                        zone, A(m, n), ldam);
84
                }
85
                MORSE_TASK_dataflush( &options, A(m, k) );
86
            }
87 88
            for (n = 0; n < k; n++) {
                MORSE_TASK_dataflush( &options, A(k, n) );
89 90 91
                MORSE_TASK_ztrsm(
                    &options,
                    MorseLeft, uplo, MorseNoTrans, diag,
92 93 94
                    tempkn, A->nb, A->mb,
                    zone, A(k, k), ldak,
                          A(k, n), ldak);
95
            }
96
            MORSE_TASK_dataflush( &options, A(k, k) );
97 98 99
            MORSE_TASK_ztrtri(
                &options,
                uplo, diag,
100 101
                tempkn, A->mb,
                A(k, k), ldak, A->nb*k);
102 103 104 105 106 107
        }
    }
    /*
     *  MorseUpper
     */
    else {
108
        for (k = 0; k < A->mt; k++) {
109 110
            RUNTIME_set_iteration(k);

111 112 113
            tempkm = k == A->mt-1 ? A->m-k*A->mb : A->mb;
            ldak = BLKLDD(A, k);
            for (n = k+1; n < A->nt; n++) {
114 115 116 117
                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
                MORSE_TASK_ztrsm(
                    &options,
                    MorseLeft, uplo, MorseNoTrans, diag,
118 119 120
                    tempkm, tempnn, A->mb,
                    mzone, A(k, k), ldak,
                           A(k, n), ldak);
121
            }
122
            for (n = k+1; n < A->nt; n++) {
123
                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
124 125
                for (m = 0; m < k; m++) {
                    ldam = BLKLDD(A, m);
126 127 128
                    MORSE_TASK_zgemm(
                        &options,
                        MorseNoTrans, MorseNoTrans,
129 130 131 132
                        A->mb, tempnn, tempkm, A->mb,
                        zone, A(m, k), ldam,
                              A(k, n), ldak,
                        zone, A(m, n), ldam);
133
                }
134 135 136 137 138
                MORSE_TASK_dataflush( &options, A(k, n) );
            }
            for (m = 0; m < k; m++) {
                ldam = BLKLDD(A, m);
                MORSE_TASK_dataflush( &options, A(m, k) );
139 140 141
                MORSE_TASK_ztrsm(
                    &options,
                    MorseRight, uplo, MorseNoTrans, diag,
142 143 144
                    A->mb, tempkm, A->mb,
                    zone, A(k, k), ldak,
                          A(m, k), ldam);
145
            }
146
            MORSE_TASK_dataflush( &options, A(k, k) );
147 148 149
            MORSE_TASK_ztrtri(
                &options,
                uplo, diag,
150 151
                tempkm, A->mb,
                A(k, k), ldak, A->mb*k);
152 153 154 155 156
        }
    }
    RUNTIME_options_finalize(&options, morse);
    MORSE_TASK_dataflush_all();
}