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

#define A(m,n) A,  m,  n
#define B(m,n) B,  m,  n
#define C(m,n) C,  m,  n
29
/**
30
 *  Parallel tile symmetric matrix-matrix multiplication - dynamic scheduling
31
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
32
void chameleon_pzsymm(cham_side_t side, cham_uplo_t uplo,
Mathieu Faverge's avatar
Mathieu Faverge committed
33 34 35
                          CHAMELEON_Complex64_t alpha, CHAM_desc_t *A, CHAM_desc_t *B,
                          CHAMELEON_Complex64_t beta, CHAM_desc_t *C,
                          RUNTIME_sequence_t *sequence, RUNTIME_request_t *request)
36
{
Mathieu Faverge's avatar
Mathieu Faverge committed
37
    CHAM_context_t *chamctxt;
Mathieu Faverge's avatar
Mathieu Faverge committed
38
    RUNTIME_option_t options;
39 40

    int k, m, n;
41
    int ldak, ldam, ldan, ldbk, ldbm, ldcm;
42 43
    int tempmm, tempnn, tempkn, tempkm;

Mathieu Faverge's avatar
Mathieu Faverge committed
44 45
    CHAMELEON_Complex64_t zbeta;
    CHAMELEON_Complex64_t zone = (CHAMELEON_Complex64_t)1.0;
46

Mathieu Faverge's avatar
Mathieu Faverge committed
47
    chamctxt = chameleon_context_self();
Mathieu Faverge's avatar
Mathieu Faverge committed
48
    if (sequence->status != CHAMELEON_SUCCESS)
49
        return;
Mathieu Faverge's avatar
Mathieu Faverge committed
50
    RUNTIME_options_init(&options, chamctxt, sequence, request);
51

52
    /*
Mathieu Faverge's avatar
Mathieu Faverge committed
53
     *  ChamLeft
54
     */
Mathieu Faverge's avatar
Mathieu Faverge committed
55
    if (side == ChamLeft) {
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
        for (k = 0; k < C->mt; k++) {
            tempkm = k == C->mt-1 ? C->m-k*C->mb : C->mb;
            ldak = BLKLDD(A, k);
            ldbk = BLKLDD(B, k);
            zbeta = k == 0 ? beta : zone;

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

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

                    /*
Mathieu Faverge's avatar
Mathieu Faverge committed
71
                     *  ChamLeft / ChamLower
72
                     */
Mathieu Faverge's avatar
Mathieu Faverge committed
73
                    if (uplo == ChamLower) {
74
                        if (k < m) {
Mathieu Faverge's avatar
Mathieu Faverge committed
75
                            INSERT_TASK_zgemm(
76
                                &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
77
                                ChamNoTrans, ChamNoTrans,
78
                                tempmm, tempnn, tempkm, A->mb,
79 80 81
                                alpha, A(m, k), ldam,
                                       B(k, n), ldbk,
                                zbeta, C(m, n), ldcm);
82 83 84
                        }
                        else {
                            if (k == m) {
Mathieu Faverge's avatar
Mathieu Faverge committed
85
                                INSERT_TASK_zsymm(
86 87 88
                                    &options,
                                    side, uplo,
                                    tempmm, tempnn, A->mb,
89 90 91
                                    alpha, A(k, k), ldak,
                                           B(k, n), ldbk,
                                    zbeta, C(m, n), ldcm);
92 93
                            }
                            else {
Mathieu Faverge's avatar
Mathieu Faverge committed
94
                                INSERT_TASK_zgemm(
95
                                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
96
                                    ChamTrans, ChamNoTrans,
97
                                    tempmm, tempnn, tempkm, A->mb,
98 99 100
                                    alpha, A(k, m), ldak,
                                           B(k, n), ldbk,
                                    zbeta, C(m, n), ldcm);
101 102 103
                            }
                        }
                    }
104
                    /*
Mathieu Faverge's avatar
Mathieu Faverge committed
105
                     *  ChamLeft / ChamUpper
106 107
                     */
                    else {
108
                        if (k < m) {
Mathieu Faverge's avatar
Mathieu Faverge committed
109
                            INSERT_TASK_zgemm(
110
                                &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
111
                                ChamTrans, ChamNoTrans,
112
                                tempmm, tempnn, tempkm, A->mb,
113 114 115
                                alpha, A(k, m), ldak,
                                       B(k, n), ldbk,
                                zbeta, C(m, n), ldcm);
116 117 118
                        }
                        else {
                            if (k == m) {
Mathieu Faverge's avatar
Mathieu Faverge committed
119
                                INSERT_TASK_zsymm(
120 121 122
                                    &options,
                                    side, uplo,
                                    tempmm, tempnn, A->mb,
123 124 125
                                    alpha, A(k, k), ldak,
                                           B(k, n), ldbk,
                                    zbeta, C(m, n), ldcm);
126 127
                            }
                            else {
Mathieu Faverge's avatar
Mathieu Faverge committed
128
                                INSERT_TASK_zgemm(
129
                                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
130
                                    ChamNoTrans, ChamNoTrans,
131
                                    tempmm, tempnn, tempkm, A->mb,
132 133 134
                                    alpha, A(m, k), ldam,
                                           B(k, n), ldbk,
                                    zbeta, C(m, n), ldcm);
135 136 137 138
                            }
                        }
                    }
                }
139
                RUNTIME_data_flush( sequence, B(k, n) );
140
            }
Mathieu Faverge's avatar
Mathieu Faverge committed
141
            if (uplo == ChamLower) {
142
                for (n = 0; n <= k; n++) {
143
                    RUNTIME_data_flush( sequence, A(k, n) );
144
                }
145 146
            }
            else {
147
                for (m = 0; m <= k; m++) {
148
                    RUNTIME_data_flush( sequence, A(m, k) );
149 150 151 152 153
                }
            }
        }
    }
    /*
Mathieu Faverge's avatar
Mathieu Faverge committed
154
     *  ChamRight
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
     */
    else {
        for (k = 0; k < C->nt; k++) {
            tempkn = k == C->nt-1 ? C->n-k*C->nb : C->nb;
            ldak = BLKLDD(A, k);
            zbeta = k == 0 ? beta : zone;

            for (m = 0; m < C->mt; m++) {
                tempmm = m == C->mt-1 ? C->m-m*C->mb : C->mb;
                ldbm = BLKLDD(B, m);
                ldcm = BLKLDD(C, m);

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

                    /*
Mathieu Faverge's avatar
Mathieu Faverge committed
172
                     *  ChamRight / ChamLower
173
                     */
Mathieu Faverge's avatar
Mathieu Faverge committed
174
                    if (uplo == ChamLower) {
175
                        if (k < n) {
Mathieu Faverge's avatar
Mathieu Faverge committed
176
                           INSERT_TASK_zgemm(
177
                               &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
178
                               ChamNoTrans, ChamTrans,
179 180 181 182
                               tempmm, tempnn, tempkn, A->mb,
                               alpha, B(m, k), ldbm,
                                      A(n, k), ldan,
                               zbeta, C(m, n), ldcm);
183 184 185
                        }
                        else {
                            if (k == n) {
Mathieu Faverge's avatar
Mathieu Faverge committed
186
                               INSERT_TASK_zsymm(
187
                                   &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
188
                                   ChamRight, uplo,
189 190 191 192
                                   tempmm, tempnn, A->mb,
                                   alpha, A(k, k), ldak,
                                          B(m, k), ldbm,
                                   zbeta, C(m, n), ldcm);
193 194
                            }
                            else {
Mathieu Faverge's avatar
Mathieu Faverge committed
195
                                INSERT_TASK_zgemm(
196
                                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
197
                                    ChamNoTrans, ChamNoTrans,
198
                                    tempmm, tempnn, tempkn, A->mb,
199 200 201
                                    alpha, B(m, k), ldbm,
                                           A(k, n), ldak,
                                    zbeta, C(m, n), ldcm);
202 203 204
                            }
                        }
                    }
205
                    /*
Mathieu Faverge's avatar
Mathieu Faverge committed
206
                     *  ChamRight / ChamUpper
207 208
                     */
                    else {
209
                        if (k < n) {
Mathieu Faverge's avatar
Mathieu Faverge committed
210
                            INSERT_TASK_zgemm(
211
                                &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
212
                                ChamNoTrans, ChamNoTrans,
213
                                tempmm, tempnn, tempkn, A->mb,
214 215 216
                                alpha, B(m, k), ldbm,
                                       A(k, n), ldak,
                                zbeta, C(m, n), ldcm);
217 218 219
                        }
                        else {
                            if (k == n) {
Mathieu Faverge's avatar
Mathieu Faverge committed
220
                                INSERT_TASK_zsymm(
221
                                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
222
                                    ChamRight, uplo,
223
                                    tempmm, tempnn, A->mb,
224 225 226
                                    alpha, A(k, k), ldak,
                                           B(m, k), ldbm,
                                    zbeta, C(m, n), ldcm);
227 228
                            }
                            else {
Mathieu Faverge's avatar
Mathieu Faverge committed
229
                                INSERT_TASK_zgemm(
230
                                    &options,
Mathieu Faverge's avatar
Mathieu Faverge committed
231
                                    ChamNoTrans, ChamTrans,
232
                                    tempmm, tempnn, tempkn, A->mb,
233 234 235
                                    alpha, B(m, k), ldbm,
                                           A(n, k), ldan,
                                    zbeta, C(m, n), ldcm);
236 237 238 239
                            }
                        }
                    }
                }
240
                RUNTIME_data_flush( sequence, B(m, k) );
241
            }
Mathieu Faverge's avatar
Mathieu Faverge committed
242
            if (uplo == ChamLower) {
243
                for (n = 0; n <= k; n++) {
244
                    RUNTIME_data_flush( sequence, A(k, n) );
245 246 247 248
                }
            }
            else {
                for (m = 0; m <= k; m++) {
249
                    RUNTIME_data_flush( sequence, A(m, k) );
250
                }
251 252 253
            }
        }
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
254
    RUNTIME_options_finalize(&options, chamctxt);
255
}