pzlaset.c 3.08 KB
Newer Older
1
/**
2 3
 *
 * @file pzlaset.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
 *
12
 * @brief Chameleon zlaset parallel algorithm
13
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
14
 * @version 1.0.0
15
 * @comment This file has been automatically generated
16
 *          from Plasma 2.5.0 for CHAMELEON 1.0.0
17 18 19 20 21 22 23
 * @author Hatem Ltaief
 * @author Mathieu Faverge
 * @author Emmanuel Agullo
 * @author Cedric Castagnede
 * @date 2010-11-15
 * @precisions normal z -> s d c
 *
24
 */
25
#include "control/common.h"
26 27

#define A(m,n) A,  m,  n
28
/**
29 30
 *  Parallel initialization a 2-D array A to BETA on the diagonal and
 *  ALPHA on the offdiagonals.
31
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
32
void chameleon_pzlaset(cham_uplo_t uplo,
33 34 35
                          CHAMELEON_Complex64_t alpha, CHAMELEON_Complex64_t beta,
                          CHAM_desc_t *A,
                          RUNTIME_sequence_t *sequence, RUNTIME_request_t *request)
36
{
Mathieu Faverge's avatar
Mathieu Faverge committed
37
    CHAM_context_t *chamctxt;
38
    RUNTIME_option_t options;
39 40 41 42 43

    int i, j;
    int ldai, ldaj;
    int tempim;
    int tempjm, tempjn;
44
    int minmn = chameleon_min(A->mt, A->nt);
45

Mathieu Faverge's avatar
Mathieu Faverge committed
46
    chamctxt = chameleon_context_self();
Mathieu Faverge's avatar
Mathieu Faverge committed
47
    if (sequence->status != CHAMELEON_SUCCESS) {
48
        return;
Mathieu Faverge's avatar
Mathieu Faverge committed
49
    }
50

Mathieu Faverge's avatar
Mathieu Faverge committed
51
    RUNTIME_options_init(&options, chamctxt, sequence, request);
52

53
    if (uplo == ChamLower) {
54 55 56 57
       for (j = 0; j < minmn; j++){
           tempjm = j == A->mt-1 ? A->m-j*A->mb : A->mb;
           tempjn = j == A->nt-1 ? A->n-j*A->nb : A->nb;
           ldaj = BLKLDD(A, j);
58
           INSERT_TASK_zlaset(
59
               &options,
60
               ChamLower, tempjm, tempjn, alpha, beta,
61 62 63 64 65
               A(j, j), ldaj);

           for (i = j+1; i < A->mt; i++){
               tempim = i == A->mt-1 ? A->m-i*A->mb : A->mb;
               ldai = BLKLDD(A, i);
66
               INSERT_TASK_zlaset(
67
                   &options,
68
                   ChamUpperLower, tempim, tempjn, alpha, alpha,
69 70 71 72
                   A(i, j), ldai);
           }
       }
    }
73
    else if (uplo == ChamUpper) {
Mathieu Faverge's avatar
Mathieu Faverge committed
74
       for (j = 0; j < A->nt; j++){
75
           tempjn = j == A->nt-1 ? A->n-j*A->nb : A->nb;
Mathieu Faverge's avatar
Mathieu Faverge committed
76
           for (i = 0; i < chameleon_min(j+1, A->mt); i++){
77 78
               tempim = i == A->mt-1 ? A->m-i*A->mb : A->mb;
               ldai = BLKLDD(A, i);
79
               INSERT_TASK_zlaset(
80
                   &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
81 82
                   ChamUpperLower, tempim, tempjn,
                   alpha,  (i == j) ? beta : alpha,
83 84 85 86 87 88 89 90 91 92
                   A(i, j), ldai);
           }
       }
    }
    else {
       for (i = 0; i < A->mt; i++){
           tempim = i == A->mt-1 ? A->m-i*A->mb : A->mb;
           ldai = BLKLDD(A, i);
           for (j = 0; j < A->nt; j++){
               tempjn = j == A->nt-1 ? A->n-j*A->nb : A->nb;
93
               INSERT_TASK_zlaset(
94
                   &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
95 96
                   ChamUpperLower, tempim, tempjn,
                   alpha, (i == j) ? beta : alpha,
97 98 99 100
                   A(i, j), ldai);
           }
       }
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
101
    RUNTIME_options_finalize(&options, chamctxt);
102
}