time_zgeqrf_hqr.c 2.89 KB
Newer Older
1
/**
2 3
 *
 * @file time_zgeqrf_hqr.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
 *
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-05-29
16 17
 * @precisions normal z -> c d s
 *
18
 */
19
#define _TYPE  CHAMELEON_Complex64_t
20 21 22
#define _PREC  double
#define _LAMCH LAPACKE_dlamch_work

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
{
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 */
47
    PASTE_CODE_ALLOCATE_MATRIX( A, 1, CHAMELEON_Complex64_t, LDA, N );
BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
48

49
    /* Initialize Data */
50
    CHAMELEON_zplrnt(M, N, A, LDA, 3456);
51 52

    /* Allocate Workspace */
53 54
    CHAMELEON_Alloc_Workspace_zgels(M, N, &TS, P, Q);
    CHAMELEON_Alloc_Workspace_zgels(M, N, &TT, P, Q);
55

56
    /* Save AT in lapack layout for check */
57
    PASTE_CODE_ALLOCATE_COPY( Acpy, check, CHAMELEON_Complex64_t, A, LDA, N );
58

BOUCHERIE Raphael's avatar
BOUCHERIE Raphael committed
59 60 61 62 63 64 65
    /* 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
66 67 68 69
    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
70 71

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

75
    START_TIMING();
76
    CHAMELEON_zgeqrf_param(&qrtree, M, N, A, LDA, TS, TT );
77 78 79 80 81
    STOP_TIMING();

    /* Check the solution */
    if ( check )
    {
82 83 84
        PASTE_CODE_ALLOCATE_MATRIX( X, 1, CHAMELEON_Complex64_t, LDB, NRHS );
        CHAMELEON_zplrnt( N, NRHS, X, LDB, 5673 );
        PASTE_CODE_ALLOCATE_COPY( B, 1, CHAMELEON_Complex64_t, X, LDB, NRHS );
85

86
        CHAMELEON_zgeqrs_param(&qrtree, M, N, NRHS, A, LDA, TS, TT, X, LDB);
87 88 89 90 91 92 93 94 95

        dparam[IPARAM_RES] = z_check_solution(M, N, NRHS, Acpy, LDA, B, X, LDB,
                                              &(dparam[IPARAM_ANORM]),
                                              &(dparam[IPARAM_BNORM]),
                                              &(dparam[IPARAM_XNORM]));

        free( Acpy );
        free( B );
        free( X );
Mathieu Faverge's avatar
Mathieu Faverge committed
96
    }
97 98

    /* Free Workspace */
Mathieu Faverge's avatar
Mathieu Faverge committed
99
    libhqr_finalize( &qrtree );
100 101
    CHAMELEON_Dealloc_Workspace( &TS );
    CHAMELEON_Dealloc_Workspace( &TT );
102
    free( A );
103 104 105

    return 0;
}