pztpqrt.c 3.26 KB
Newer Older
1
/**
2 3
 *
 * @file pztpqrt.c
4
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
5 6
 * @copyright 2009-2016 The University of Tennessee and The University of
 *                      Tennessee Research Foundation. All rights reserved.
7 8 9
 * @copyright 2012-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 *                      Univ. Bordeaux. All rights reserved.
 * @copyright 2016-2018 KAUST. All rights reserved.
10
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
11
 ***
12 13 14 15 16 17
 *
 *
 *  MORSE computational routines
 *  MORSE is a software package provided by Univ. of Tennessee,
 *  Univ. of California Berkeley and Univ. of Colorado Denver
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
18
 * @version 1.0.0
19 20 21 22 23 24 25 26 27 28 29
 * @author Mathieu Faverge
 * @date 2016-12-15
 * @precisions normal z -> s d c
 *
 **/
#include "control/common.h"

#define A(m,n) A,  m,  n
#define B(m,n) B,  m,  n
#define T(m,n) T,  m,  n

Mathieu Faverge's avatar
Mathieu Faverge committed
30
/*******************************************************************************
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
 *  Parallel tile QR factorization - dynamic scheduling
 **/
void morse_pztpqrt( int L, MORSE_desc_t *A, MORSE_desc_t *B, MORSE_desc_t *T,
                    MORSE_sequence_t *sequence, MORSE_request_t *request )
{
    MORSE_context_t *morse;
    MORSE_option_t options;
    size_t ws_worker = 0;
    size_t ws_host = 0;

    int k, m, n;
    int ldak, ldbm;
    int tempkm, tempkn, tempnn, tempmm, templm;
    int ib;

    /* Dimension of the first column */
47
    int maxm  = chameleon_max( B->m - L, 1 );
48 49 50 51 52 53 54 55 56 57
    int maxmt = (maxm % B->mb == 0) ? (maxm / B->mb) : (maxm / B->mb + 1);

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

    ib = MORSE_IB;

    /*
Mathieu Faverge's avatar
Mathieu Faverge committed
58 59
     * ztsqrt  = A->nb * (ib+1)
     * ztpmqrt = A->nb * ib
60 61 62 63 64 65 66
     */
    ws_worker = A->nb * (ib+1);

    /* Allocation of temporary (scratch) working space */
#if defined(CHAMELEON_USE_CUDA)
    /* Worker space
     *
Mathieu Faverge's avatar
Mathieu Faverge committed
67
     * ztpmqrt = 2 * A->nb * ib
68
     */
69
    ws_worker = chameleon_max( ws_worker, ib * A->nb * 2 );
70 71 72 73 74 75 76 77
#endif

    ws_worker *= sizeof(MORSE_Complex64_t);
    ws_host   *= sizeof(MORSE_Complex64_t);

    RUNTIME_options_ws_alloc( &options, ws_worker, ws_host );

    for (k = 0; k < A->nt; k++) {
78
        RUNTIME_iteration_push(morse, k);
79

80 81 82 83 84 85 86 87
        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);

        for (m = 0; m < maxmt; m++) {
            tempmm = m == B->mt-1 ? B->m-m*B->mb : B->mb;
            templm = m == maxmt-1 ? tempmm       : 0;
            ldbm = BLKLDD(B, m);
88
            /* TT kernel */
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
            MORSE_TASK_ztpqrt(
                &options,
                tempmm, tempkn, templm, ib, T->nb,
                A(k, k), ldak,
                B(m, k), ldbm,
                T(m, k), T->mb );

            for (n = k+1; n < B->nt; n++) {
                tempnn = n == B->nt-1 ? B->n-n*B->nb : B->nb;
                MORSE_TASK_ztpmqrt(
                    &options,
                    MorseLeft, MorseConjTrans,
                    tempmm, tempnn, tempkm, templm, ib, T->nb,
                    B(m, k), ldbm,
                    T(m, k), T->mb,
                    A(k, n), ldak,
                    B(m, n), ldbm );
            }
        }

109
        maxmt = chameleon_min( B->mt, maxmt+1 );
110 111

        RUNTIME_iteration_pop(morse);
112
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
113

114 115 116
    RUNTIME_options_ws_free(&options);
    RUNTIME_options_finalize(&options, morse);
}