time_zgeqrf_hqr_tile.c 3.42 KB
Newer Older
1
/**
2 3
 *
 * @file time_zgeqrf_hqr_tile.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.
PRUVOST Florent's avatar
PRUVOST Florent committed
7
 * @copyright 2012-2019 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8
 *                      Univ. Bordeaux. All rights reserved.
9
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
10
 ***
11
 *
PRUVOST Florent's avatar
PRUVOST Florent committed
12
 * @version 0.9.2
13 14
 * @author Mathieu Faverge
 * @author Raphael Boucherie
PRUVOST Florent's avatar
PRUVOST Florent committed
15
 * @date 2017-06-13
16 17
 * @precisions normal z -> c d s
 *
18
 */
Mathieu Faverge's avatar
Mathieu Faverge committed
19
#define _TYPE  CHAMELEON_Complex64_t
20 21 22
#define _PREC  double
#define _LAMCH LAPACKE_dlamch_work

Mathieu Faverge's avatar
Mathieu Faverge committed
23
#define _NAME  "CHAMELEON_zgeqrf_param"
24 25 26 27 28 29 30 31
/* See Lawn 41 page 120 */
#define _FMULS FMULS_GEQRF(M, N)
#define _FADDS FADDS_GEQRF(M, N)

#include "./timing.c"
#include "timing_zauxiliary.h"

static int
Mathieu Faverge's avatar
Mathieu Faverge committed
32
RunTest(int *iparam, double *dparam, chameleon_time_t *t_)
33
{
Mathieu Faverge's avatar
Mathieu Faverge committed
34 35
    CHAM_desc_t *TS;
    CHAM_desc_t *TT;
Mathieu Faverge's avatar
Mathieu Faverge committed
36 37
    libhqr_tree_t   qrtree;
    libhqr_matrix_t matrix;
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
38
    int hlvl, llvl, qr_a, domino;
39 40 41 42 43 44 45 46
    PASTE_CODE_IPARAM_LOCALS( iparam );

    if ( M != N && check ) {
        fprintf(stderr, "Check cannot be perfomed with M != N\n");
        check = 0;
    }

    /* Allocate Data */
Mathieu Faverge's avatar
Mathieu Faverge committed
47 48 49 50
    PASTE_CODE_ALLOCATE_MATRIX_TILE( descA, 1, CHAMELEON_Complex64_t,  ChamComplexDouble, LDA, M, N );
    PASTE_CODE_ALLOCATE_MATRIX_TILE( descX,  ( check && M == N ), CHAMELEON_Complex64_t, ChamComplexDouble, LDB, M, NRHS );
    PASTE_CODE_ALLOCATE_MATRIX_TILE( descA0, ( check && M == N ), CHAMELEON_Complex64_t, ChamComplexDouble, LDA, M, N    );
    PASTE_CODE_ALLOCATE_MATRIX_TILE( descB,  ( check && M == N ), CHAMELEON_Complex64_t, ChamComplexDouble, LDB, M, NRHS );
51

Mathieu Faverge's avatar
Mathieu Faverge committed
52
    CHAMELEON_zplrnt_Tile( descA, 5373 );
53 54 55

    /* Save A for check */
    if (check == 1 && M == N){
Mathieu Faverge's avatar
Mathieu Faverge committed
56
        CHAMELEON_zlacpy_Tile(ChamUpperLower, descA, descA0);
57 58 59
    }

    /* Allocate Workspace */
Mathieu Faverge's avatar
Mathieu Faverge committed
60 61
    CHAMELEON_Alloc_Workspace_zgels(M, N, &TS, P, Q);
    CHAMELEON_Alloc_Workspace_zgels(M, N, &TT, P, Q);
62 63 64 65 66 67 68 69

    /* Initialize matrix */
    matrix.mt = TS->mt;
    matrix.nt = TS->nt;
    matrix.nodes = 1;
    matrix.p = 1;

    /* Initialize qrtree  */
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
70 71 72 73
    hlvl = iparam[IPARAM_HIGHLVL_TREE];
    llvl = iparam[IPARAM_LOWLVL_TREE];
    qr_a = iparam[IPARAM_RHBLK];
    domino =  iparam[IPARAM_QR_DOMINO];
Mathieu Faverge's avatar
Mathieu Faverge committed
74 75

    libhqr_init_hqr( &qrtree,
76
                     ( M >= N ) ? LIBHQR_QR : LIBHQR_LQ,
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
77
                     &matrix, llvl, hlvl, qr_a, P, domino, 0);
78 79

    START_TIMING();
Mathieu Faverge's avatar
Mathieu Faverge committed
80
    CHAMELEON_zgeqrf_param_Tile(&qrtree, descA, TS, TT );
81 82 83 84 85 86
    STOP_TIMING();

    /* Check the solution */
    if ( check && M == N)
    {
         /* Initialize and save B */
Mathieu Faverge's avatar
Mathieu Faverge committed
87 88
        CHAMELEON_zplrnt_Tile( descX, 2264 );
        CHAMELEON_zlacpy_Tile(ChamUpperLower, descX, descB);
89 90

        /* Compute the solution */
Mathieu Faverge's avatar
Mathieu Faverge committed
91
        CHAMELEON_zgeqrs_param_Tile(&qrtree, descA, TS, TT, descX );
92 93

        /* Check solution */
Mathieu Faverge's avatar
Mathieu Faverge committed
94 95 96 97 98
        dparam[IPARAM_ANORM] = CHAMELEON_zlange_Tile(ChamInfNorm, descA0);
        dparam[IPARAM_BNORM] = CHAMELEON_zlange_Tile(ChamInfNorm, descB);
        dparam[IPARAM_XNORM] = CHAMELEON_zlange_Tile(ChamInfNorm, descX);
        CHAMELEON_zgemm_Tile( ChamNoTrans, ChamNoTrans, 1.0, descA0, descX, -1.0, descB );
        dparam[IPARAM_RES] = CHAMELEON_zlange_Tile(ChamInfNorm, descB);
99 100 101 102 103 104
        PASTE_CODE_FREE_MATRIX( descX  )
        PASTE_CODE_FREE_MATRIX( descA0 )
        PASTE_CODE_FREE_MATRIX( descB  )
      }

    /* Free Workspace */
Mathieu Faverge's avatar
Mathieu Faverge committed
105
    libhqr_finalize( &qrtree );
Mathieu Faverge's avatar
Mathieu Faverge committed
106 107
    CHAMELEON_Dealloc_Workspace( &TS );
    CHAMELEON_Dealloc_Workspace( &TT );
108 109 110 111
    free( descA );

    return 0;
}