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

/**
 *
 * @file pzgetrf_incpiv.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
 *
 **/
//ALLOC_WS :  ib*L->nb
//WS_ADD :  ib*L->nb
32
#include "control/common.h"
Mathieu Faverge's avatar
Mathieu Faverge committed
33
#include <stdlib.h>
34 35

#define A(_m_,_n_) A, _m_, _n_
36
#if defined(CHAMELEON_COPY_DIAG)
37
#define D(k)   D, k, 0
38
#else
39
#define D(k)   A, k, k
40
#endif
41 42 43
#define L(_m_,_n_) L,  _m_,  _n_
#define IPIV(_m_,_n_) &(IPIV[(int64_t)A->mb*((int64_t)(_m_)+(int64_t)A->mt*(int64_t)(_n_))])

Mathieu Faverge's avatar
Mathieu Faverge committed
44
/*******************************************************************************
45 46
 *  Parallel tile LU factorization - dynamic scheduling
 **/
47 48
void morse_pzgetrf_incpiv( MORSE_desc_t *A, MORSE_desc_t *L, MORSE_desc_t *D, int *IPIV,
                           MORSE_sequence_t *sequence, MORSE_request_t *request )
49 50 51
{
    MORSE_context_t *morse;
    MORSE_option_t options;
52 53
    size_t ws_worker = 0;
    size_t ws_host = 0;
54 55 56 57 58

    int k, m, n;
    int ldak, ldam;
    int tempkm, tempkn, tempmm, tempnn;
    int ib;
59
    int minMNT = chameleon_min(A->mt, A->nt);
60 61 62 63 64 65 66

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

    ib = MORSE_IB;
67

68 69 70 71 72 73 74
    /*
     * zgetrf_incpiv = 0
     * zgessm        = 0
     * ztstrf        = A->mb * ib
     * zssssm        = 0
     */
    ws_worker = A->mb * ib;
75

76 77 78 79
    ws_worker *= sizeof(MORSE_Complex64_t);
    ws_host   *= sizeof(MORSE_Complex64_t);

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );
80

81
    for (k = 0; k < minMNT; k++) {
82
        RUNTIME_iteration_push(morse, k);
83

84 85 86 87 88 89 90 91 92 93 94 95
        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_zgetrf_incpiv(
            &options,
            tempkm, tempkn, ib, L->nb,
            A(k, k), ldak,
            L(k, k), L->mb,
            IPIV(k, k),
            k == A->mt-1, A->nb*k);

        if ( k < (minMNT-1) ) {
96
#if defined(CHAMELEON_COPY_DIAG)
97 98 99 100
            MORSE_TASK_zlacpy(
                &options,
                MorseUpperLower, tempkm, tempkn, A->nb,
                A(k, k), ldak,
101
                D(k), ldak);
102
#endif
103 104 105 106 107 108 109 110 111
        }

        for (n = k+1; n < A->nt; n++) {
            tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
            MORSE_TASK_zgessm(
                &options,
                tempkm, tempnn, tempkm, ib, L->nb,
                IPIV(k, k),
                L(k, k), L->mb,
112
                D(k), ldak,
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
                A(k, n), ldak);
        }
        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_ztstrf(
                &options,
                tempmm, tempkn, ib, L->nb,
                A(k, k), ldak,
                A(m, k), ldam,
                L(m, k), L->mb,
                IPIV(m, k),
                m == A->mt-1, A->nb*k);

            for (n = k+1; n < A->nt; n++) {
                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
                MORSE_TASK_zssssm(
                    &options,
                    A->nb, tempnn, tempmm, tempnn, A->nb, ib, L->nb,
                    A(k, n), ldak,
                    A(m, n), ldam,
                    L(m, k), L->mb,
                    A(m, k), ldam,
                    IPIV(m, k));
            }
        }
139 140

        RUNTIME_iteration_pop(morse);
141
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
142

143 144
    RUNTIME_options_ws_free(&options);
    RUNTIME_options_finalize(&options, morse);
145
    (void)D;
146
}