Attention une mise à jour du serveur va être effectuée le vendredi 16 avril entre 12h et 12h30. Cette mise à jour va générer une interruption du service de quelques minutes.

pztpqrt.c 3.6 KB
Newer Older
1 2 3 4 5 6 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
/**
 *
 * @copyright (c) 2009-2016 The University of Tennessee and The University
 *                          of Tennessee Research Foundation.
 *                          All rights reserved.
 * @copyright (c) 2012-2016 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 *                          Univ. Bordeaux. All rights reserved.
 *
 **/

/**
 *
 * @file pztpqrt.c
 *
 *  MORSE computational routines
 *  MORSE is a software package provided by Univ. of Tennessee,
 *  Univ. of California Berkeley and Univ. of Colorado Denver
 *
 * @version 0.9.0
 * @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

/***************************************************************************//**
 *  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 */
    int maxm  = B->m - L;
    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
59 60
     * ztsqrt  = A->nb * (ib+1)
     * ztpmqrt = A->nb * ib
61 62 63 64 65 66 67
     */
    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
68
     * ztpmqrt = 2 * A->nb * ib
69
     */
70
    ws_worker = chameleon_max( ws_worker, ib * A->nb * 2 );
71 72 73 74 75
#endif

#if defined(CHAMELEON_USE_MAGMA)
    /* Worker space
     *
Mathieu Faverge's avatar
Mathieu Faverge committed
76
     * ztpqrt = max( A->nb * (ib+1), ib * (ib + A->nb) )
77
     */
78
    ws_worker = chameleon_max( ws_worker, ib * (ib + A->nb) );
79 80 81

    /* Host space
     *
Mathieu Faverge's avatar
Mathieu Faverge committed
82
     * ztpqrt = 2 * ib * (A->nb+ib) + A->nb
83
     */
84 85
    ws_host = chameleon_max( ws_host, ib * (A->mb + 3 * ib) + A->mb );
    ws_host = chameleon_max( ws_host,  2 * ib * (A->nb + ib) + A->nb );
86 87 88 89 90 91 92 93
#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++) {
THIBAULT Samuel's avatar
THIBAULT Samuel committed
94
        RUNTIME_set_iteration(morse, k);
95

96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
        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);
            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 );
            }
        }

124
        maxmt = chameleon_min( B->mt, maxmt+1 );
125 126 127 128 129
    }
    RUNTIME_options_ws_free(&options);
    RUNTIME_options_finalize(&options, morse);
    MORSE_TASK_dataflush_all();
}