pztile2band.c 3.34 KB
Newer Older
1
/**
2 3
 *
 * @file pztile2band.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
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
12
 * @brief Chameleon ztile2band parallel algorithm
13
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
14
 * @version 1.0.0
15 16 17 18 19 20
 * @author Azzam Haidar
 * @author Gregoire Pichon
 * @author Mathieu Faverge
 * @date 2010-11-15
 * @precisions normal z -> s d c
 *
21
 */
22 23 24 25 26
#include "control/common.h"

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

27
/**
28
 *  Parallel copy of a band matrix from full NxN tile storage to band storage (LDABxN).
29
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
30
void chameleon_pztile2band(cham_uplo_t uplo, CHAM_desc_t *A, CHAM_desc_t *B,
Mathieu Faverge's avatar
Mathieu Faverge committed
31
                       RUNTIME_sequence_t *sequence, RUNTIME_request_t *request)
32
{
Mathieu Faverge's avatar
Mathieu Faverge committed
33
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
34
    RUNTIME_option_t options;
35 36 37 38

    int j;
    int ldaj, ldx;
    int tempjm, tempjn;
39
    int minmnt = chameleon_min(A->mt, A->nt);
40

Mathieu Faverge's avatar
Mathieu Faverge committed
41
    chamctxt = chameleon_context_self();
Mathieu Faverge's avatar
Mathieu Faverge committed
42
    if (sequence->status != CHAMELEON_SUCCESS) {
43
        return;
Mathieu Faverge's avatar
Mathieu Faverge committed
44
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
45
    RUNTIME_options_init(&options, chamctxt, sequence, request);
46 47 48 49

    ldx = B->mb-1;

    /*
Mathieu Faverge's avatar
Mathieu Faverge committed
50
     *  ChamLower => Lower Band
51
     */
Mathieu Faverge's avatar
Mathieu Faverge committed
52
    if ( uplo == ChamLower ) {
53
       for (j = 0; j < minmnt; j++){
54
           /* Compute dimension on N with B since it is dimensioned with chameleon_min(A->m, A->n) */
55 56 57 58 59 60 61
           assert( A->m == B->n );
           assert( A->n >= B->n );

           tempjm = j == A->mt-1 ? A->m - j * A->mb : A->mb;
           tempjn = j == B->nt-1 ? B->n - j * B->nb : B->nb;
           ldaj = BLKLDD(A, j);

Mathieu Faverge's avatar
Mathieu Faverge committed
62
           INSERT_TASK_zlaset(
63
               &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
64
               ChamUpperLower, B->mb, tempjn,
65 66 67
               0., 0.,
               B(0, j), B->mb );

Mathieu Faverge's avatar
Mathieu Faverge committed
68
           INSERT_TASK_zlacpy(
69
               &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
70
               ChamLower, tempjm, tempjn, A->nb,
71 72 73 74 75 76
               A(j, j), ldaj,
               B(0, j), ldx );

           if( j<minmnt-1 ){
               tempjm = (j+1) == A->mt-1 ? A->m-(j+1)*A->mb : A->mb;
               ldaj = BLKLDD(A, j+1);
Mathieu Faverge's avatar
Mathieu Faverge committed
77
               INSERT_TASK_zlacpyx(
78
                   &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
79
                   ChamUpper, tempjm, tempjn, A->nb,
80 81 82 83 84
                   0,     A(j+1, j), ldaj,
                   A->nb, B(0,   j), ldx);
           }
       }
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
85
    else if ( uplo == ChamUpper ) {
86
       for (j = 0; j < minmnt; j++){
87
           /* Compute dimension on M with B since it is dimensioned with chameleon_min(A->m, A->n) */
88 89 90 91 92
           assert( A->n == B->n );
           assert( A->m >= B->n );
           tempjn = j == A->nt-1 ? A->n - j * A->nb : A->nb;
           ldaj = BLKLDD(A, j);

Mathieu Faverge's avatar
Mathieu Faverge committed
93
           INSERT_TASK_zlaset(
94
               &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
95
               ChamUpperLower, B->mb, tempjn,
96 97 98 99
               0., 0.,
               B(0, j), B->mb );

           if(j > 0){
Mathieu Faverge's avatar
Mathieu Faverge committed
100
               INSERT_TASK_zlacpy(
101
                   &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
102
                   ChamLower, A->mb, tempjn, A->nb,
103 104 105 106 107
                   A(j-1, j), BLKLDD(A, j-1),
                   B(0,   j), ldx);
           }

           tempjm = j == B->nt-1 ? B->n - j * B->nb : B->nb;
Mathieu Faverge's avatar
Mathieu Faverge committed
108
           INSERT_TASK_zlacpyx(
109
               &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
110
               ChamUpper, tempjm, tempjn, A->nb,
111 112 113 114
               0,     A(j, j), ldaj,
               A->nb, B(0, j), ldx);
       }
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
115
    RUNTIME_options_finalize(&options, chamctxt);
116 117 118
}
#undef B
#undef A