MAGMA  1.2.0
MatrixAlgebraonGPUandMulticoreArchitectures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
time_zpotrf.c
Go to the documentation of this file.
1 
6 #define _TYPE PLASMA_Complex64_t
7 #define _PREC double
8 #define _LAMCH LAPACKE_dlamch_work
9 
10 #define _NAME "PLASMA_zpotrf"
11 /* See Lawn 41 page 120 */
12 #define _FMULS (n * (1.0 / 6.0 * n + 0.5) * n)
13 #define _FADDS (n * (1.0 / 6.0 * n ) * n)
14 
15 #include "./timing.c"
16 
17 static int
18 RunTest(int *iparam, double *dparam, real_Double_t *t_)
19 {
20  PLASMA_Complex64_t *A, *Acpy, *b, *x;
21  real_Double_t t;
22  int n = iparam[TIMING_N];
23  int nrhs = iparam[TIMING_NRHS];
24  int check = iparam[TIMING_CHECK];
25  int lda = n;
26  int ldb = n;
27  int uplo = PlasmaLower;
28 
29  /* Allocate Data */
30  A = (PLASMA_Complex64_t *)malloc(lda*n* sizeof(PLASMA_Complex64_t));
31 
32  /* Check if unable to allocate memory */
33  if ( !A ) {
34  printf("Out of Memory \n ");
35  exit(0);
36  }
37 
38  /* Initialiaze Data */
39  MAGMA_zplghe( (double)n, n, A, lda, 51 );
40 
41  /* Save A and b */
42  if (check) {
43  Acpy = (PLASMA_Complex64_t *)malloc(lda*n*sizeof(PLASMA_Complex64_t));
44  LAPACKE_zlacpy_work(LAPACK_COL_MAJOR,' ', n, n, A, lda, Acpy, lda);
45  }
46 
47  /* PLASMA ZPOSV */
48  /* if (iparam[TIMING_BOUND]) */
49  /* starpu_bound_start(iparam[TIMING_BOUNDDEPS],iparam[TIMING_BOUNDDEPSPRIO]); */
50  t = -cWtime();
51  MAGMA_zpotrf(uplo, n, A, lda);
52  t += cWtime();
53  /* if (iparam[TIMING_BOUND]) */
54  /* starpu_bound_stop(); */
55  *t_ = t;
56 
57  /* Check the solution */
58  if (check)
59  {
60  b = (PLASMA_Complex64_t *)malloc(ldb*nrhs*sizeof(PLASMA_Complex64_t));
61  x = (PLASMA_Complex64_t *)malloc(ldb*nrhs*sizeof(PLASMA_Complex64_t));
62  LAPACKE_zlarnv_work(1, ISEED, n*nrhs, x);
63  LAPACKE_zlacpy_work(LAPACK_COL_MAJOR, 'A', n, nrhs, x, ldb, b, ldb);
64 
65  MAGMA_zpotrs(uplo, n, nrhs, A, lda, x, ldb);
66 
67  dparam[TIMING_RES] = zcheck_solution(n, n, nrhs, Acpy, lda, b, x, ldb,
68  &(dparam[TIMING_ANORM]),
69  &(dparam[TIMING_BNORM]),
70  &(dparam[TIMING_XNORM]));
71 
72  free(Acpy); free(b); free(x);
73  }
74 
75  free(A);
76 
77  return 0;
78 }