pzlange.c 15.5 KB
Newer Older
1
/**
2 3
 *
 * @file pzlange.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 zlange 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.6.0 for CHAMELEON 1.0.0
17 18 19 20 21 22
 * @author Emmanuel Agullo
 * @author Mathieu Faverge
 * @author Florent Pruvost
 * @date 2014-07-21
 * @precisions normal z -> s d c
 *
23
 */
24 25 26
//ALLOC_WS :  A->mb
//ALLOC_WS :  A->nb
//WS_ADD :  A->mb + A->nb
27
#include "control/common.h"
28

29 30
#define A( m, n )        A,     (m), (n)
#define W( desc, m, n ) (desc), (m), (n)
Mathieu Faverge's avatar
Mathieu Faverge committed
31 32 33 34

static inline void
chameleon_pzlange_one( cham_uplo_t uplo, cham_diag_t diag, CHAM_desc_t *A,
                       CHAM_desc_t *Wcol, CHAM_desc_t *Welt,
Mathieu Faverge's avatar
Mathieu Faverge committed
35
                       RUNTIME_option_t *options )
36
{
37
    int m, n;
Mathieu Faverge's avatar
Mathieu Faverge committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
    int minMNT = chameleon_min( A->mt, A->nt );
    int minMN  = chameleon_min( A->m,  A->n  );
    int MT = (uplo == ChamUpper) ? minMNT : A->mt;
    int NT = (uplo == ChamLower) ? minMNT : A->nt;
    int M  = (uplo == ChamUpper) ? minMN  : A->m;
    int N  = (uplo == ChamLower) ? minMN  : A->n;
    int P  = Welt->p;
    int Q  = Welt->q;

    /**
     * Step 1:
     *  For j in [1,P], W(i, n) = reduce( A(i+k*P, n) )
     */
    for(n = 0; n < NT; n++) {
        int mmin = ( uplo == ChamLower ) ? n                      : 0;
        int mmax = ( uplo == ChamUpper ) ? chameleon_min(n+1, MT) : MT;

        int tempnn = ( n == (NT-1) ) ? N - n * A->nb : A->nb;

        for(m = mmin; m < mmax; m++) {
            int tempmm = ( m == (MT-1) ) ? M - m * A->mb : A->mb;
            int ldam = BLKLDD( A, m );

Mathieu Faverge's avatar
Mathieu Faverge committed
61
            if ( (n == m) && (uplo != ChamUpperLower) ) {
Mathieu Faverge's avatar
Mathieu Faverge committed
62 63 64
                INSERT_TASK_ztrasm(
                    options,
                    ChamColumnwise, uplo, diag, tempmm, tempnn,
65
                    A(m, n), ldam, W( Wcol, m, n ) );
Mathieu Faverge's avatar
Mathieu Faverge committed
66 67 68 69 70
            }
            else {
                INSERT_TASK_dzasum(
                    options,
                    ChamColumnwise, ChamUpperLower, tempmm, tempnn,
71
                    A(m, n), ldam, W( Wcol, m, n ) );
Mathieu Faverge's avatar
Mathieu Faverge committed
72
            }
73

Mathieu Faverge's avatar
Mathieu Faverge committed
74 75 76
            if ( m >= P ) {
                INSERT_TASK_dgeadd(
                    options,
77 78 79
                    ChamNoTrans, 1, tempnn, A->nb,
                    1.0, W( Wcol, m,   n ), 1,
                    1.0, W( Wcol, m%P, n ), 1 );
Mathieu Faverge's avatar
Mathieu Faverge committed
80 81
            }
        }
82

Mathieu Faverge's avatar
Mathieu Faverge committed
83 84 85
        /**
         * Step 2:
         *  For each i, W(i, n) = reduce( W(0..P-1, n) )
86
         */
87
        for(m = 1; m < P; m++) {
Mathieu Faverge's avatar
Mathieu Faverge committed
88 89
            INSERT_TASK_dgeadd(
                options,
90 91 92
                ChamNoTrans, 1, tempnn, A->nb,
                1.0, W( Wcol, m, n ), 1,
                1.0, W( Wcol, 0, n ), 1 );
Mathieu Faverge's avatar
Mathieu Faverge committed
93
        }
94

Mathieu Faverge's avatar
Mathieu Faverge committed
95 96
        INSERT_TASK_dlange(
            options,
97
            ChamMaxNorm, 1, tempnn, A->nb,
Mathieu Faverge's avatar
Mathieu Faverge committed
98 99
            W( Wcol, 0, n ), 1,
            W( Welt, 0, n ) );
Mathieu Faverge's avatar
Mathieu Faverge committed
100
    }
101

Mathieu Faverge's avatar
Mathieu Faverge committed
102 103 104 105 106 107 108
    /**
     * Step 3:
     *  For n in 0..Q-1, W(m, n) = max( W(m, n..nt[Q] ) )
     */
    for(n = Q; n < NT; n++) {
        INSERT_TASK_dlange_max(
            options,
Mathieu Faverge's avatar
Mathieu Faverge committed
109 110
            W( Welt, 0, n   ),
            W( Welt, 0, n%Q ) );
Mathieu Faverge's avatar
Mathieu Faverge committed
111
    }
112

Mathieu Faverge's avatar
Mathieu Faverge committed
113 114 115 116 117 118 119
    /**
     * Step 4:
     *  For each i, Welt(i, n) = max( Welt(0..P-1, n) )
     */
    for(n = 1; n < Q; n++) {
        INSERT_TASK_dlange_max(
            options,
Mathieu Faverge's avatar
Mathieu Faverge committed
120 121
            W( Welt, 0, n ),
            W( Welt, 0, 0 ) );
Mathieu Faverge's avatar
Mathieu Faverge committed
122 123
    }
}
124

Mathieu Faverge's avatar
Mathieu Faverge committed
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
static inline void
chameleon_pzlange_inf( cham_uplo_t uplo, cham_diag_t diag, CHAM_desc_t *A,
                       CHAM_desc_t *Wcol, CHAM_desc_t *Welt,
                       RUNTIME_option_t *options)
{
    int m, n;
    int minMNT = chameleon_min( A->mt, A->nt );
    int minMN  = chameleon_min( A->m,  A->n  );
    int MT = (uplo == ChamUpper) ? minMNT : A->mt;
    int NT = (uplo == ChamLower) ? minMNT : A->nt;
    int M  = (uplo == ChamUpper) ? minMN  : A->m;
    int N  = (uplo == ChamLower) ? minMN  : A->n;
    int P  = Welt->p;
    int Q  = Welt->q;

    /**
     * Step 1:
     *  For j in [1,Q], Wcol(m, j) = reduce( A(m, j+k*Q) )
     */
    for(m = 0; m < MT; m++) {
        int nmin = ( uplo == ChamUpper ) ? m                      : 0;
        int nmax = ( uplo == ChamLower ) ? chameleon_min(m+1, NT) : NT;

        int tempmm = ( m == (MT-1) ) ? M - m * A->mb : A->mb;
        int ldam = BLKLDD( A, m );

        for(n = nmin; n < nmax; n++) {
            int tempnn = ( n == (NT-1) ) ? N - n * A->nb : A->nb;

            if ( (n == m)  && (uplo != ChamUpperLower) ) {
                INSERT_TASK_ztrasm(
                    options,
                    ChamRowwise, uplo, diag, tempmm, tempnn,
158
                    A(m, n), ldam, W( Wcol, m, n) );
159
            }
Mathieu Faverge's avatar
Mathieu Faverge committed
160
            else {
161
                INSERT_TASK_dzasum(
Mathieu Faverge's avatar
Mathieu Faverge committed
162 163
                    options,
                    ChamRowwise, ChamUpperLower, tempmm, tempnn,
164
                    A(m, n), ldam, W( Wcol, m, n) );
165 166
            }

Mathieu Faverge's avatar
Mathieu Faverge committed
167
            if ( n >= Q ) {
168
                INSERT_TASK_dgeadd(
Mathieu Faverge's avatar
Mathieu Faverge committed
169 170
                    options,
                    ChamNoTrans, tempmm, 1, A->mb,
171 172
                    1.0, W( Wcol, m, n  ), tempmm,
                    1.0, W( Wcol, m, n%Q), tempmm );
173
            }
Mathieu Faverge's avatar
Mathieu Faverge committed
174
        }
175

Mathieu Faverge's avatar
Mathieu Faverge committed
176 177 178 179 180 181 182 183
        /**
         * Step 2:
         *  For each j, W(m, j) = reduce( Wcol(m, 0..Q-1) )
         */
        for(n = 1; n < Q; n++) {
            INSERT_TASK_dgeadd(
                options,
                ChamNoTrans, tempmm, 1, A->mb,
184 185
                1.0, W( Wcol, m, n), tempmm,
                1.0, W( Wcol, m, 0), tempmm );
186 187
        }

Mathieu Faverge's avatar
Mathieu Faverge committed
188 189 190
        INSERT_TASK_dlange(
            options,
            ChamMaxNorm, tempmm, 1, A->nb,
191
            W( Wcol, m, 0), 1, W( Welt, m, 0));
Mathieu Faverge's avatar
Mathieu Faverge committed
192 193 194 195 196 197 198 199 200
    }

    /**
     * Step 3:
     *  For m in 0..P-1, Welt(m, n) = max( Wcol(m..mt[P], n ) )
     */
    for(m = P; m < MT; m++) {
        INSERT_TASK_dlange_max(
            options,
201
            W( Welt, m, 0), W( Welt, m%P, 0) );
Mathieu Faverge's avatar
Mathieu Faverge committed
202 203 204 205 206 207 208 209 210
    }

    /**
     * Step 4:
     *  For each i, Welt(i, n) = max( Welt(0..P-1, n) )
     */
    for(m = 1; m < P; m++) {
        INSERT_TASK_dlange_max(
            options,
211
            W( Welt, m, 0), W( Welt, 0, 0) );
Mathieu Faverge's avatar
Mathieu Faverge committed
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
    }
}

static inline void
chameleon_pzlange_max( cham_uplo_t uplo, cham_diag_t diag, CHAM_desc_t *A, CHAM_desc_t *Welt,
                       RUNTIME_option_t *options)
{
    int m, n;
    int minMNT = chameleon_min( A->mt, A->nt );
    int minMN  = chameleon_min( A->m,  A->n  );
    int MT = (uplo == ChamUpper) ? minMNT : A->mt;
    int NT = (uplo == ChamLower) ? minMNT : A->nt;
    int M  = (uplo == ChamUpper) ? minMN  : A->m;
    int N  = (uplo == ChamLower) ? minMN  : A->n;
    int P  = Welt->p;
    int Q  = Welt->q;

    /**
     * Step 1:
     *  For j in [1,Q], Welt(m, j) = reduce( A(m, j+k*Q) )
     */
    for(m = 0; m < MT; m++) {
        int nmin = ( uplo == ChamUpper ) ? m                      : 0;
        int nmax = ( uplo == ChamLower ) ? chameleon_min(m+1, NT) : NT;

        int tempmm = ( m == (MT-1) ) ? M - m * A->mb : A->mb;
        int ldam = BLKLDD( A, m );

        for(n = nmin; n < nmax; n++) {
            int tempnn = ( n == (NT-1) ) ? N - n * A->nb : A->nb;

            if ( (n == m)  && (uplo != ChamUpperLower) ) {
                INSERT_TASK_zlantr(
                    options,
                    ChamMaxNorm, uplo, diag, tempmm, tempnn, A->nb,
247
                    A(m, n), ldam, W( Welt, m, n));
Mathieu Faverge's avatar
Mathieu Faverge committed
248 249 250 251 252
            }
            else {
                INSERT_TASK_zlange(
                    options,
                    ChamMaxNorm, tempmm, tempnn, A->nb,
Mathieu Faverge's avatar
Mathieu Faverge committed
253
                    A(m, n), ldam, W( Welt, m, n ));
Mathieu Faverge's avatar
Mathieu Faverge committed
254
            }
255

Mathieu Faverge's avatar
Mathieu Faverge committed
256
            if ( n >= Q ) {
257
                INSERT_TASK_dlange_max(
Mathieu Faverge's avatar
Mathieu Faverge committed
258
                    options,
Mathieu Faverge's avatar
Mathieu Faverge committed
259 260
                    W( Welt, m, n   ),
                    W( Welt, m, n%Q ) );
261 262 263
            }
        }

Mathieu Faverge's avatar
Mathieu Faverge committed
264 265 266 267 268 269 270
        /**
         * Step 2:
         *  For each j, W(m, j) = reduce( Welt(m, 0..Q-1) )
         */
        for(n = 1; n < Q; n++) {
            INSERT_TASK_dlange_max(
                options,
Mathieu Faverge's avatar
Mathieu Faverge committed
271 272
                W( Welt, m, n ),
                W( Welt, m, 0 ) );
Mathieu Faverge's avatar
Mathieu Faverge committed
273 274 275 276 277 278 279 280 281 282
        }
    }

    /**
     * Step 3:
     *  For m in 0..P-1, Welt(m, n) = max( Welt(m..mt[P], n ) )
     */
    for(m = P; m < MT; m++) {
        INSERT_TASK_dlange_max(
            options,
Mathieu Faverge's avatar
Mathieu Faverge committed
283 284
            W( Welt, m,   0 ),
            W( Welt, m%P, 0 ) );
Mathieu Faverge's avatar
Mathieu Faverge committed
285 286 287 288 289 290 291 292 293
    }

    /**
     * Step 4:
     *  For each i, Welt(i, n) = max( Welt(0..P-1, n) )
     */
    for(m = 1; m < P; m++) {
        INSERT_TASK_dlange_max(
            options,
Mathieu Faverge's avatar
Mathieu Faverge committed
294 295
            W( Welt, m, 0 ),
            W( Welt, 0, 0 ) );
Mathieu Faverge's avatar
Mathieu Faverge committed
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
    }
}

static inline void
chameleon_pzlange_frb( cham_uplo_t uplo, cham_diag_t diag, CHAM_desc_t *A, CHAM_desc_t *Welt,
                       RUNTIME_option_t *options)
{
    int m, n;
    int minMNT = chameleon_min( A->mt, A->nt );
    int minMN  = chameleon_min( A->m,  A->n  );
    int MT = (uplo == ChamUpper) ? minMNT : A->mt;
    int NT = (uplo == ChamLower) ? minMNT : A->nt;
    int M  = (uplo == ChamUpper) ? minMN  : A->m;
    int N  = (uplo == ChamLower) ? minMN  : A->n;
    int P  = Welt->p;
    int Q  = Welt->q;

    /**
     * Step 1:
     *  For j in [1,Q], Welt(m, j) = reduce( A(m, j+k*Q) )
     */
    for(m = 0; m < MT; m++) {
        int nmin = ( uplo == ChamUpper ) ? m                      : 0;
        int nmax = ( uplo == ChamLower ) ? chameleon_min(m+1, NT) : NT;

        int tempmm = ( m == (MT-1) ) ? M - m * A->mb : A->mb;
        int ldam = BLKLDD( A, m );

        for(n = nmin; n < nmax; n++) {
            int tempnn = ( n == (NT-1) ) ? N - n * A->nb : A->nb;

            if ( (n == m) && (uplo != ChamUpperLower) ) {
                INSERT_TASK_ztrssq(
                    options,
                    uplo, diag, tempmm, tempnn,
331
                    A(m, n), ldam, W( Welt, m, n) );
Mathieu Faverge's avatar
Mathieu Faverge committed
332 333 334 335 336
            }
            else {
                INSERT_TASK_zgessq(
                    options,
                    tempmm, tempnn,
337
                    A(m, n), ldam, W( Welt, m, n) );
Mathieu Faverge's avatar
Mathieu Faverge committed
338 339 340 341
            }

            if ( n >= Q ) {
                INSERT_TASK_dplssq(
342
                    options, W( Welt, m, n), W( Welt, m, n%Q) );
343 344 345
            }
        }

Mathieu Faverge's avatar
Mathieu Faverge committed
346 347 348
        /**
         * Step 2:
         *  For each j, W(m, j) = reduce( Welt(m, 0..Q-1) )
349
         */
Mathieu Faverge's avatar
Mathieu Faverge committed
350 351
        for(n = 1; n < Q; n++) {
            INSERT_TASK_dplssq(
352
                options, W( Welt, m, n), W( Welt, m, 0) );
Mathieu Faverge's avatar
Mathieu Faverge committed
353 354
        }
    }
355

Mathieu Faverge's avatar
Mathieu Faverge committed
356 357 358 359 360 361
    /**
     * Step 3:
     *  For m in 0..P-1, Welt(m, n) = max( Welt(m..mt[P], n ) )
     */
    for(m = P; m < MT; m++) {
        INSERT_TASK_dplssq(
362
            options, W( Welt, m, 0), W( Welt, m%P, 0) );
Mathieu Faverge's avatar
Mathieu Faverge committed
363
    }
364

Mathieu Faverge's avatar
Mathieu Faverge committed
365 366 367 368 369 370
    /**
     * Step 4:
     *  For each i, Welt(i, n) = max( Welt(0..P-1, n) )
     */
    for(m = 1; m < P; m++) {
        INSERT_TASK_dplssq(
371
            options, W( Welt, m, 0), W( Welt, 0, 0) );
Mathieu Faverge's avatar
Mathieu Faverge committed
372
    }
373

Mathieu Faverge's avatar
Mathieu Faverge committed
374
    INSERT_TASK_dplssq2(
375
        options, W( Welt, 0, 0) );
Mathieu Faverge's avatar
Mathieu Faverge committed
376
}
377

Mathieu Faverge's avatar
Mathieu Faverge committed
378 379 380 381 382 383 384 385 386
/**
 *
 */
void chameleon_pzlange_generic( cham_normtype_t norm, cham_uplo_t uplo, cham_diag_t diag,
                                CHAM_desc_t *A, double *result,
                                RUNTIME_sequence_t *sequence, RUNTIME_request_t *request )
{
    CHAM_context_t *chamctxt;
    RUNTIME_option_t options;
387 388
    CHAM_desc_t Wcol;
    CHAM_desc_t Welt;
Mathieu Faverge's avatar
Mathieu Faverge committed
389 390
    double alpha = 0.0;
    double beta  = 0.0;
391

Mathieu Faverge's avatar
Mathieu Faverge committed
392
    int workmt, worknt;
393
    int m, n, wcol_init = 0;
394

Mathieu Faverge's avatar
Mathieu Faverge committed
395
    chamctxt = chameleon_context_self();
Mathieu Faverge's avatar
Mathieu Faverge committed
396
    if ( sequence->status != CHAMELEON_SUCCESS ) {
Mathieu Faverge's avatar
Mathieu Faverge committed
397
        return;
Mathieu Faverge's avatar
Mathieu Faverge committed
398
    }
Mathieu Faverge's avatar
Mathieu Faverge committed
399
    RUNTIME_options_init(&options, chamctxt, sequence, request);
400

Mathieu Faverge's avatar
Mathieu Faverge committed
401
    *result = 0.0;
402

Mathieu Faverge's avatar
Mathieu Faverge committed
403 404
    workmt = chameleon_max( A->mt, A->p );
    worknt = chameleon_max( A->nt, A->q );
405

Mathieu Faverge's avatar
Mathieu Faverge committed
406 407 408
    switch ( norm ) {
    case ChamOneNorm:
        RUNTIME_options_ws_alloc( &options, 1, 0 );
409

410 411 412 413
        chameleon_desc_init( &Wcol, CHAMELEON_MAT_ALLOC_GLOBAL, ChamRealDouble, 1, A->nb, A->nb,
                             workmt, worknt * A->nb, 0, 0, workmt, worknt * A->nb, A->p, A->q,
                             NULL, NULL, NULL );
        wcol_init = 1;
414

415 416 417
        chameleon_desc_init( &Welt, CHAMELEON_MAT_ALLOC_GLOBAL, ChamRealDouble, 1, 1, 1,
                             A->p, worknt, 0, 0, A->p, worknt, A->p, A->q,
                             NULL, NULL, NULL );
418

Mathieu Faverge's avatar
Mathieu Faverge committed
419
        break;
420

Mathieu Faverge's avatar
Mathieu Faverge committed
421 422 423 424 425
        /*
         *  ChamInfNorm
         */
    case ChamInfNorm:
        RUNTIME_options_ws_alloc( &options, A->mb, 0 );
426

427 428 429 430
        chameleon_desc_init( &Wcol, CHAMELEON_MAT_ALLOC_GLOBAL, ChamRealDouble, A->mb, 1, A->mb,
                             workmt * A->mb, worknt, 0, 0, workmt * A->mb, worknt, A->p, A->q,
                             NULL, NULL, NULL );
        wcol_init = 1;
Mathieu Faverge's avatar
Mathieu Faverge committed
431

432 433 434
        chameleon_desc_init( &Welt, CHAMELEON_MAT_ALLOC_GLOBAL, ChamRealDouble, 1, 1, 1,
                             workmt, A->q, 0, 0, workmt, A->q, A->p, A->q,
                             NULL, NULL, NULL );
435 436 437
        break;

        /*
438
         *  ChamFrobeniusNorm
439
         */
440
    case ChamFrobeniusNorm:
Mathieu Faverge's avatar
Mathieu Faverge committed
441
        RUNTIME_options_ws_alloc( &options, 1, 0 );
442

Mathieu Faverge's avatar
Mathieu Faverge committed
443
        alpha = 1.;
444
        chameleon_desc_init( &Welt, CHAMELEON_MAT_ALLOC_GLOBAL, ChamRealDouble, 2, 1, 2,
445
                             workmt*2, worknt, 0, 0, workmt*2, worknt, A->p, A->q,
446
                             NULL, NULL, NULL );
447 448 449
        break;

        /*
450
         *  ChamMaxNorm
451
         */
452
    case ChamMaxNorm:
453 454 455
    default:
        RUNTIME_options_ws_alloc( &options, 1, 0 );

456
        chameleon_desc_init( &Welt, CHAMELEON_MAT_ALLOC_GLOBAL, ChamRealDouble, 1, 1, 1,
457
                             workmt, worknt, 0, 0, workmt, worknt, A->p, A->q,
458
                             NULL, NULL, NULL );
Mathieu Faverge's avatar
Mathieu Faverge committed
459
    }
460

Mathieu Faverge's avatar
Mathieu Faverge committed
461 462 463 464 465
    /* Initialize workspaces */
    if ( (norm == ChamInfNorm) ||
         (norm == ChamOneNorm) )
    {
        /* Initialize Wcol tile */
466 467
        for(m = 0; m < Wcol.mt; m++) {
            for(n = 0; n < Wcol.nt; n++) {
Mathieu Faverge's avatar
Mathieu Faverge committed
468
                INSERT_TASK_dlaset(
469
                    &options,
470
                    ChamUpperLower, Wcol.mb, Wcol.nb,
Mathieu Faverge's avatar
Mathieu Faverge committed
471
                    alpha, beta,
472
                    W( &Wcol, m, n ), Wcol.mb );
473 474
            }
        }
Mathieu Faverge's avatar
Mathieu Faverge committed
475
    }
476 477
    for(m = 0; m < Welt.mt; m++) {
        for(n = 0; n < Welt.nt; n++) {
Mathieu Faverge's avatar
Mathieu Faverge committed
478 479
            INSERT_TASK_dlaset(
                &options,
480
                ChamUpperLower, Welt.mb, Welt.nb,
Mathieu Faverge's avatar
Mathieu Faverge committed
481
                alpha, beta,
482
                W( &Welt, m, n ), Welt.mb );
Mathieu Faverge's avatar
Mathieu Faverge committed
483 484
        }
    }
485

Mathieu Faverge's avatar
Mathieu Faverge committed
486 487
    switch ( norm ) {
    case ChamOneNorm:
488 489
        chameleon_pzlange_one( uplo, diag, A, &Wcol, &Welt, &options );
        CHAMELEON_Desc_Flush( &Wcol, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
490
        break;
491

Mathieu Faverge's avatar
Mathieu Faverge committed
492
    case ChamInfNorm:
493 494
        chameleon_pzlange_inf( uplo, diag, A, &Wcol, &Welt, &options );
        CHAMELEON_Desc_Flush( &Wcol, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
495
        break;
496

Mathieu Faverge's avatar
Mathieu Faverge committed
497
    case ChamFrobeniusNorm:
498
        chameleon_pzlange_frb( uplo, diag, A, &Welt, &options );
Mathieu Faverge's avatar
Mathieu Faverge committed
499 500 501 502
        break;

    case ChamMaxNorm:
    default:
503
        chameleon_pzlange_max( uplo, diag, A, &Welt, &options );
Mathieu Faverge's avatar
Mathieu Faverge committed
504 505 506 507 508 509 510
    }

    /**
     * Broadcast the result
     */
    for(m = 0; m < A->p; m++) {
        for(n = 0; n < A->q; n++) {
Mathieu Faverge's avatar
Mathieu Faverge committed
511
            if ( (m != 0) || (n != 0) ) {
512
                INSERT_TASK_dlacpy(
513
                    &options,
514
                    ChamUpperLower, 1, 1, 1,
515
                    W( &Welt, 0, 0 ), 1, W( &Welt, m, n ), 1);
516 517 518
            }
        }
    }
519

Mathieu Faverge's avatar
Mathieu Faverge committed
520 521 522
    if ( wcol_init ) {
        CHAMELEON_Desc_Flush( &Wcol, sequence );
    }
523
    CHAMELEON_Desc_Flush( &Welt, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
524
    CHAMELEON_Desc_Flush( A, sequence );
Mathieu Faverge's avatar
Mathieu Faverge committed
525 526
    RUNTIME_sequence_wait(chamctxt, sequence);

Mathieu Faverge's avatar
Mathieu Faverge committed
527
    *result = *((double *)Welt.get_blkaddr( &Welt, A->myrank / A->q, A->myrank % A->q ));
Mathieu Faverge's avatar
Mathieu Faverge committed
528

529 530
    if ( wcol_init ) {
        chameleon_desc_destroy( &Wcol );
Mathieu Faverge's avatar
Mathieu Faverge committed
531
    }
532
    chameleon_desc_destroy( &Welt );
533

534
    RUNTIME_options_ws_free(&options);
Mathieu Faverge's avatar
Mathieu Faverge committed
535
    RUNTIME_options_finalize(&options, chamctxt);
536
}