pzlascal.c 2.95 KB
Newer Older
1
/**
2 3
 *
 * @file pzlascal.c
4 5 6 7 8 9 10
 *
 * @copyright 2009-2014 The University of Tennessee and The University of
 *                      Tennessee Research Foundation. All rights reserved.
 * @copyright 2012-2018 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
 *                      Univ. Bordeaux. All rights reserved.
 *
 ***
11
 *
12
 * @brief Chameleon zlascal parallel algorithm
13
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
14
 * @version 1.0.0
15 16 17 18
 * @author Dalal Sukkari
 * @date 2010-11-15
 * @precisions normal z -> s d c
 *
19
 */
20 21 22 23 24
#include "control/common.h"

#define A(m, n) A,  m,  n
/**
 *  Parallel scale of a matrix A
25
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
26
void chameleon_pzlascal(cham_uplo_t uplo, CHAMELEON_Complex64_t alpha, CHAM_desc_t *A,
27
                    RUNTIME_sequence_t *sequence, RUNTIME_request_t *request)
28
{
Mathieu Faverge's avatar
Mathieu Faverge committed
29
    CHAM_context_t *chamctxt;
30
    RUNTIME_option_t options;
31 32 33 34

    int tempmm, tempnn, tempmn, tempnm;
    int m, n;
    int ldam, ldan;
35
    int minmnt = chameleon_min(A->mt, A->nt);
36

Mathieu Faverge's avatar
Mathieu Faverge committed
37
    chamctxt = chameleon_context_self();
Mathieu Faverge's avatar
Mathieu Faverge committed
38
    if (sequence->status != CHAMELEON_SUCCESS) {
39
        return;
Mathieu Faverge's avatar
Mathieu Faverge committed
40
    }
41

Mathieu Faverge's avatar
Mathieu Faverge committed
42
    RUNTIME_options_init(&options, chamctxt, sequence, request);
43 44

    switch(uplo) {
45
    case ChamLower:
46 47 48 49 50
        for (n = 0; n < minmnt; n++) {
            tempnm = n == A->mt-1 ? A->m-n*A->mb : A->mb;
            tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;
            ldan = BLKLDD(A, n);

51
            INSERT_TASK_zlascal(
52
                &options,
53
                ChamLower, tempnm, tempnn, A->mb,
54 55 56 57 58 59
                alpha, A(n, n), ldan);

            for (m = n+1; m < A->mt; m++) {
                tempmm = m == A->mt-1 ? A->m-A->mb*m : A->nb;
                ldam = BLKLDD(A, m);

60
                INSERT_TASK_zlascal(
61
                    &options,
62
                    ChamUpperLower, tempmm, tempnn, A->mb,
63 64 65 66 67
                    alpha, A(m, n), ldam);
            }
        }
        break;

68
    case ChamUpper:
69 70 71 72 73
        for (m = 0; m < minmnt; m++) {
            tempmm = m == A->mt-1 ? A->m-A->mb*m : A->nb;
            tempmn = m == A->nt-1 ? A->n-m*A->nb : A->nb;
            ldam = BLKLDD(A, m);

74
            INSERT_TASK_zlascal(
75
                &options,
76
                ChamUpper, tempmm, tempmn, A->mb,
77 78 79 80 81
                alpha, A(m, m), ldam);

            for (n = m+1; n < A->nt; n++) {
                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;

82
                INSERT_TASK_zlascal(
83
                    &options,
84
                    ChamUpperLower, tempmm, tempnn, A->mb,
85 86 87 88 89
                    alpha, A(m, n), ldam);
            }
        }
        break;

90
    case ChamUpperLower:
91 92 93 94 95 96 97 98
    default:
        for (m = 0; m < A->mt; m++) {
            tempmm = m == A->mt-1 ? A->m-A->mb*m : A->nb;
            ldam = BLKLDD(A, m);

            for (n = 0; n < A->nt; n++) {
                tempnn = n == A->nt-1 ? A->n-n*A->nb : A->nb;

99
                INSERT_TASK_zlascal(
100
                    &options,
101
                    ChamUpperLower, tempmm, tempnn, A->mb,
102 103 104 105
                    alpha, A(m, n), ldam);
            }
        }
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
106
    RUNTIME_options_finalize(&options, chamctxt);
107
}