time_zgemm.c 2.18 KB
Newer Older
1
/**
2 3
 *
 * @file time_zgemm.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_zgemm"
21 22 23 24 25
/* See Lawn 41 page 120 */
#define _FMULS FMULS_GEMM(M, N, K)
#define _FADDS FADDS_GEMM(M, N, K)

#include "./timing.c"
26
#include "timing_zauxiliary.h"
27 28

static int
Mathieu Faverge's avatar
Mathieu Faverge committed
29
RunTest(int *iparam, double *dparam, chameleon_time_t *t_)
30
{
31
    CHAMELEON_Complex64_t alpha, beta;
32
    PASTE_CODE_IPARAM_LOCALS( iparam );
33

34 35
    LDB = chameleon_max(K, iparam[IPARAM_LDB]);
    LDC = chameleon_max(M, iparam[IPARAM_LDC]);
36 37

    /* Allocate Data */
38 39 40 41
    PASTE_CODE_ALLOCATE_MATRIX( A,      1, CHAMELEON_Complex64_t, LDA, K   );
    PASTE_CODE_ALLOCATE_MATRIX( B,      1, CHAMELEON_Complex64_t, LDB, N   );
    PASTE_CODE_ALLOCATE_MATRIX( C,      1, CHAMELEON_Complex64_t, LDC, N   );
    PASTE_CODE_ALLOCATE_MATRIX( C2, check, CHAMELEON_Complex64_t, LDC, N   );
42

43 44 45
    CHAMELEON_zplrnt( M, K, A, LDA,  453 );
    CHAMELEON_zplrnt( K, N, B, LDB, 5673 );
    CHAMELEON_zplrnt( M, N, C, LDC,  740 );
46 47 48 49 50 51

    LAPACKE_zlarnv_work(1, ISEED, 1, &alpha);
    LAPACKE_zlarnv_work(1, ISEED, 1, &beta );

    if (check)
    {
52
        memcpy(C2, C, LDC*N*sizeof(CHAMELEON_Complex64_t));
53 54 55
    }

    START_TIMING();
56
    CHAMELEON_zgemm( ChamNoTrans, ChamNoTrans, M, N, K, alpha, A, LDA, B, LDB, beta, C, LDC );
57
    STOP_TIMING();
58

59 60 61
    /* Check the solution */
    if (check)
    {
62
        dparam[IPARAM_RES] = 0.0;
63
        dparam[IPARAM_RES] = z_check_gemm( ChamNoTrans, ChamNoTrans, M, N, K,
64 65 66 67
                                           alpha, A, LDA, B, LDB, beta, C, C2, LDC,
                                           &(dparam[IPARAM_ANORM]),
                                           &(dparam[IPARAM_BNORM]),
                                           &(dparam[IPARAM_XNORM]));
68

69 70 71 72 73 74 75 76 77
        free(C2);
    }

    free( A );
    free( B );
    free( C );

    return 0;
}