time_zgetrs_incpiv_tile.c 2.75 KB
Newer Older
1
/**
2 3
 *
 * @file time_zgetrs_incpiv_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.
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
 *
Mathieu Faverge's avatar
Mathieu Faverge committed
12
 * @version 1.0.0
13 14
 * @precisions normal z -> c d s
 *
15
 */
16
#define _TYPE  CHAMELEON_Complex64_t
17 18 19
#define _PREC  double
#define _LAMCH LAPACKE_dlamch_work

20
#define _NAME  "CHAMELEON_zgetrs_incpiv_Tile"
21 22 23 24 25 26 27
/* See Lawn 41 page 120 */
#define _FMULS (FMULS_GETRS( N, NRHS ))
#define _FADDS (FADDS_GETRS( N, NRHS ))

#include "./timing.c"

static int
Mathieu Faverge's avatar
Mathieu Faverge committed
28
RunTest(int *iparam, double *dparam, chameleon_time_t *t_)
29
{
30
    CHAM_desc_t *descL;
31 32 33 34 35 36 37 38 39 40
    int *piv;
    PASTE_CODE_IPARAM_LOCALS( iparam );
    check = 1;

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

    /* Allocate Data */
41 42 43 44
    PASTE_CODE_ALLOCATE_MATRIX_TILE( descA, 1, CHAMELEON_Complex64_t, ChamComplexDouble, LDA, M, N );
    PASTE_CODE_ALLOCATE_MATRIX_TILE( descX,  check, CHAMELEON_Complex64_t, ChamComplexDouble, LDB, M, NRHS );
    PASTE_CODE_ALLOCATE_MATRIX_TILE( descAC, check, CHAMELEON_Complex64_t, ChamComplexDouble, LDA, M, N    );
    PASTE_CODE_ALLOCATE_MATRIX_TILE( descB,  check, CHAMELEON_Complex64_t, ChamComplexDouble, LDB, M, NRHS );
45

46
    CHAMELEON_zplrnt_Tile(descA, 3456);
47 48

    /* Allocate Workspace */
49
    CHAMELEON_Alloc_Workspace_zgesv_incpiv_Tile(chameleon_min(M,N), &descL, &piv, P, Q);
50 51 52

    /* Save A for check */
    if (check == 1){
53
        CHAMELEON_zlacpy_Tile(ChamUpperLower, descA, descAC);
54 55
    }

56 57
    /* CHAMELEON ZGETRF_NOPIV */
    CHAMELEON_zgetrf_incpiv_Tile( descA, descL, piv );
58 59 60 61 62

    /* Check the solution */
    if ( check )
    {
        /* Initialize and save B */
63 64
        CHAMELEON_zplrnt_Tile( descX, 7732 );
        CHAMELEON_zlacpy_Tile(ChamUpperLower, descX, descB);
65 66 67

        /* Compute the solution */
        START_TIMING();
68
        CHAMELEON_zgetrs_incpiv_Tile( descA, descL, piv, descX );
69 70 71
        STOP_TIMING();

        /* Check solution */
72 73 74 75 76
        dparam[IPARAM_ANORM] = CHAMELEON_zlange_Tile(ChamInfNorm, descAC);
        dparam[IPARAM_BNORM] = CHAMELEON_zlange_Tile(ChamInfNorm, descB);
        dparam[IPARAM_XNORM] = CHAMELEON_zlange_Tile(ChamInfNorm, descX);
        CHAMELEON_zgemm_Tile( ChamNoTrans, ChamNoTrans, 1.0, descAC, descX, -1.0, descB );
        dparam[IPARAM_RES] = CHAMELEON_zlange_Tile(ChamInfNorm, descB);
77 78 79 80 81 82
        PASTE_CODE_FREE_MATRIX( descX  );
        PASTE_CODE_FREE_MATRIX( descAC );
        PASTE_CODE_FREE_MATRIX( descB  );
    }

    /* Deallocate Workspace */
83
    CHAMELEON_Dealloc_Workspace(&descL);
84 85 86 87 88 89

    PASTE_CODE_FREE_MATRIX( descA );
    free( piv );

    return 0;
}