HiCMA
Hierarchical Computations on Manycore Architectures
testing_ztrsmd.c
Go to the documentation of this file.
1 
22 /*
23  *
24  * file testing_zposv.c
25  *
26  * MORSE testing routines
27  * MORSE is a software package provided by Univ. of Tennessee,
28  * Univ. of California Berkeley and Univ. of Colorado Denver
29  *
30  * version 2.5.0
31  * comment This file has been automatically generated
32  * from Plasma 2.5.0 for MORSE 1.0.0
33  * author Bilel Hadri, Hatem Ltaief
34  * author Mathieu Faverge
35  * author Emmanuel Agullo
36  * author Cedric Castagnede
37  * date 2010-11-15
38  * precisions normal z -> c d s
39  *
40  */
41 
42 
43 
44 #include "timing.h"
45 #include "hicma_constants.h"
46 #include "hicma_struct.h"
47 #include "hicma_z.h"
48 #include "hicma.h"
49 #include "hicma_common.h"
50 
51 #include <assert.h>
52 #include "auxcompute_z.h"
53 #include "auxdescutil.h"
54 
55 // zgytlr uses starsh in MPI mode.
56 STARSH_blrf *mpiF;
57 
58 int print_progress = 1; // Print progress about the execution
59 char datebuf[128];
60 time_t timer;
61 struct tm* tm_info;
62 
64 int global_check = 0;
69 int run_potrf = 1;
70 int diag_nrows = 0;
72 int print_index = 0;
75 int print_mat = 0;
76 int use_scratch = 1; // Use scratch memory provided by starpu
78 
79 
80 #include <stdlib.h>
81 #include <stdio.h>
82 #include <string.h>
83 #include <math.h>
84 
85 #include <morse.h>
86 #include "testing_zauxiliary.h"
87 
90  blas_colmajor = 102 };
91 
93  blas_base = 151,
94  blas_t = 152,
95  blas_rnd = 153,
96  blas_ieee = 154,
97  blas_emin = 155,
98  blas_emax = 156,
99  blas_eps = 157,
100  blas_prec = 158,
103  blas_sfmin = 161};
104 
114 
115 static void
116 BLAS_error(char *rname, int err, int val, int x) {
117  fprintf( stderr, "%s %d %d %d\n", rname, err, val, x );
118  abort();
119 }
120 
121 static
122 void
123 BLAS_dge_norm(enum blas_order_type order, enum blas_norm_type norm,
124  int m, int n, const double *a, int lda, double *res) {
125  int i, j; float anorm, v;
126  char rname[] = "BLAS_dge_norm";
127 
128  if (order != blas_colmajor) BLAS_error( rname, -1, order, 0 );
129 
130  if (norm == blas_frobenius_norm) {
131  anorm = 0.0f;
132  for (j = n; j; --j) {
133  for (i = m; i; --i) {
134  v = a[0];
135  anorm += v * v;
136  a++;
137  }
138  a += lda - m;
139  }
140  anorm = sqrt( anorm );
141  } else if (norm == blas_inf_norm) {
142  anorm = 0.0f;
143  for (i = 0; i < m; ++i) {
144  v = 0.0f;
145  for (j = 0; j < n; ++j) {
146  v += cabs( a[i + j * lda] );
147  }
148  if (v > anorm)
149  anorm = v;
150  }
151  } else {
152  BLAS_error( rname, -2, norm, 0 );
153  return;
154  }
155 
156  if (res) *res = anorm;
157 }
158 
159 static
160 double
161 BLAS_dpow_di(double x, int n) {
162  double rv = 1.0;
163 
164  if (n < 0) {
165  n = -n;
166  x = 1.0 / x;
167  }
168 
169  for (; n; n >>= 1, x *= x) {
170  if (n & 1)
171  rv *= x;
172  }
173 
174  return rv;
175 }
176 
177 static
178 double
179 BLAS_dfpinfo(enum blas_cmach_type cmach) {
180  double eps = 1.0, r = 1.0, o = 1.0, b = 2.0;
181  int t = 53, l = 1024, m = -1021;
182  char rname[] = "BLAS_dfpinfo";
183 
184  if ((sizeof eps) == sizeof(float)) {
185  t = 24;
186  l = 128;
187  m = -125;
188  } else {
189  t = 53;
190  l = 1024;
191  m = -1021;
192  }
193 
194  /* for (i = 0; i < t; ++i) eps *= half; */
195  eps = BLAS_dpow_di( b, -t );
196  /* for (i = 0; i >= m; --i) r *= half; */
197  r = BLAS_dpow_di( b, m-1 );
198 
199  o -= eps;
200  /* for (i = 0; i < l; ++i) o *= b; */
201  o = (o * BLAS_dpow_di( b, l-1 )) * b;
202 
203  switch (cmach) {
204  case blas_eps: return eps;
205  case blas_sfmin: return r;
206  default:
207  BLAS_error( rname, -1, cmach, 0 );
208  break;
209  }
210  return 0.0;
211 }
212 
213 int testing_dposv(int argc, char** argv){}//FIXME Use CMakeLists from Chameleon
214 
215 static int check_factorization(int, double*, double*, int, int , double);
216 static int check_solution(int, int, double*, int, double*, double*, int, double);
227 int testing_dtrsmd(int argc, char **argv)
228 {
229  HICMA_init();
230  /*HICMA_set_print_index();*/
231  /*HICMA_set_print_mat();*/
232  //HICMA_set_print_index_end();
233  //HICMA_unset_print_index_end();
234  /*HICMA_set_use_fast_hcore_zgemm();*/
235 
236  int hres = 0;
237 
238  /* Check for number of arguments*/
239  if (argc != 7){
240  USAGE("TRSMD", "N LDA NRHS LDB",
241  " - N : the size of the matrix\n"
242  " - LDA : leading dimension of the matrix A\n"
243  " - NRHS : number of RHS\n"
244  " - LDB : leading dimension of the RHS B\n"
245  " - NB : Block size\n"
246  " - acc : Fixed accuracy threshold\n"
247  " - rk : Fixed rank threshold\n"
248  );
249  return -1;
250  }
251 
252  int N = atoi(argv[0]);
253  int LDA = atoi(argv[1]);
254  int NRHS = atoi(argv[2]);
255  int LDB = atoi(argv[3]);
256  int NB = atoi(argv[4]);
257  double fixedacc = atof(argv[5]);
258  int fixedrank = atoi(argv[6]);
259  double eps;
260  int uplo;
261  int info_solution, info_factorization;
262  int trans1, trans2;
263  printf("A: %d-by-%d LD:%d\n", N, N, LDA);
264  printf("B: %d-by-%d LD:%d\n", N, NRHS, LDB);
265  printf("NB: %d fixedrank: %d fixedacc:%.1e\n", NB ,fixedrank, fixedacc);
266 
267  double *A1 = (double *)malloc(LDA*N*sizeof(double));
268  double *A2 = (double *)malloc(LDA*N*sizeof(double));
269  double *B1 = (double *)malloc(LDB*NRHS*sizeof(double));
270  double *B2 = (double *)malloc(LDB*NRHS*sizeof(double));
271 
272  /* Check if unable to allocate memory */
273  if ((!A1)||(!A2)||(!B1)||(!B2)){
274  printf("Out of Memory \n ");
275  return -2;
276  }
277 
278  eps = BLAS_dfpinfo( blas_eps );
279 
280  uplo = MorseUpper;
281  uplo = MorseLower; //to comply with current HICMA_dpotrf
282  trans1 = uplo == MorseUpper ? MorseTrans : MorseNoTrans;
283  trans2 = uplo == MorseUpper ? MorseNoTrans : MorseTrans;
284  /*-------------------------------------------------------------
285  * TESTING ZPOTRF + ZPTRSM + ZTRSM
286  */
287 
288  /* Initialize A1 and A2 for Symmetric Positif Matrix */
289  /*MORSE_dplgsy( N, MorseUpperLower, N, A1, LDA, 51 );*/
290  /*MORSE_dlacpy( MorseUpperLower, N, N, A1, LDA, A2, LDA );*/
291 
292  /* Initialize B1 and B2 */
293  /*MORSE_dplrnt( N, NRHS, B1, LDB, 371 );*/
294  /*MORSE_dlacpy( MorseUpperLower, N, NRHS, B1, LDB, B2, LDB );*/
295 
296  /*MORSE_dpotrf(uplo, N, A2, LDA);*/
297  /*MORSE_dtrsm(MorseLeft, uplo, trans1, MorseNonUnit,*/
298  /*N, NRHS, 1.0, A2, LDA, B2, LDB);*/
299  /*MORSE_dtrsm(MorseLeft, uplo, trans2, MorseNonUnit,*/
300  /*N, NRHS, 1.0, A2, LDA, B2, LDB);*/
301 
302  // DO NOT enforce compression of diagonal tiles, required for HICMA_zgytlr()
303  int compress_diag = 0;
304  global_check = 1;
305  // this paramater enables storing only diagonal tiles in a tall and skinny matrix
307  int P = 1;
308  int Q = 1;
309  int maxrank = NB/2;
310  int comp_maxrank = NB;
311  //eps = fixedacc/10;
312  int NBxMaxrank = NB * maxrank;
313  int NT = 0;
314  if (N % NB == 0)
315  NT = N / NB;
316  else
317  NT = N / NB + 1;
318  int NTxMaxrank = NT * maxrank;
319  int NBxNB = NB * NB;
320  int NBxNRHS = NB * NRHS;
321  int NTxNB = NT * NB;
322  int status;
323  HICMA_problem_t hicma_problem;
324  int probtype;
325  char sym;
326  double ddecay;
327  /*BEGIN AAAAAAAAAAAAAAAAAAAAAAAA */
329  MORSE_desc_t *descAUV = NULL;
330  status = MORSE_Desc_Create(&descAUV, NULL, MorseRealDouble, NB, maxrank*2, NBxMaxrank*2, NTxNB, NTxMaxrank*2, 0, 0, NTxNB, NTxMaxrank*2, P, Q);
331  printf("AUV: m:%d n:%d mb:%d nb:%d mt:%d nt:%d\n",
332  descAUV->m,
333  descAUV->n,
334  descAUV->mb,
335  descAUV->nb,
336  descAUV->mt,
337  descAUV->nt
338  );
339  if(status != MORSE_SUCCESS){ return status; }
340  MORSE_desc_t *descAD = NULL;
341  status = MORSE_Desc_Create(&descAD, NULL, MorseRealDouble, NB, NB, NBxNB, LDA, NB, 0, 0, N, NB, P, Q);
342  if(status != MORSE_SUCCESS){ return status; }
343 
344  MORSE_desc_t *descArk = NULL;
345  status = MORSE_Desc_Create(&descArk, NULL, MorseRealDouble, 1, 1, 1, NT, NT, 0, 0, NT, NT, P, Q);
346  if(status != MORSE_SUCCESS){ return status; }
348  MORSE_dlaset_Tile(MorseLower, 0.0, NB, descArk);
349 
350  MORSE_desc_t *descAdense = NULL;
351  status = MORSE_Desc_Create(&descAdense, NULL, MorseRealDouble, NB, NB, NBxNB, LDA, N, 0, 0, N, N, P, Q);
352  if(status != MORSE_SUCCESS){ return status; }
353  // For checking against chameleon
354  MORSE_desc_t *descAdense2 = NULL;
355  status = MORSE_Desc_Create(&descAdense2, NULL, MorseRealDouble, NB, NB, NBxNB, LDA, N, 0, 0, N, N, P, Q);
356  if(status != MORSE_SUCCESS){ return status; }
357  probtype = HICMA_STARSH_PROB_SS;
358  sym = 'S';
359  hicma_problem.ndim = 2;
360  // Correlation length
361  hicma_problem.beta = 0.1;
362  // Smoothing parameter for Matern kernel
363  hicma_problem.nu = 0.5;
364  // Shift added to diagonal elements
365  hicma_problem.noise = 1.e-4; //not enough for matrices larger than 600K
366  hicma_problem.noise = 5.e-4; //works for 640K but does not work for 10M
367  hicma_problem.noise = 1.e-2; //
368 
369  HICMA_zgenerate_problem(probtype, sym, ddecay, N, NB, NT, NT, &hicma_problem);
370 
371  printf("Generate dense A\n");
373  HICMA_zhagdm_Tile(MorseLower, descAdense);
374  printf("Generate diagonals of A\n");
376  HICMA_zhagdmdiag_Tile(MorseUpperLower, descAD);
377  printf("Generate low rank off-diagonals of A\n");
379  status = HICMA_zhagcm_Tile(MorseLower, descAUV, descArk, N, N, NB, NB, maxrank, fixedacc);
380  if(status != MORSE_SUCCESS){ return status; } //FIXME implement the function
382 
383  if(calc_rank_stat){ // print initial ranks of A
384  PASTE_TILE_TO_LAPACK( descArk, Ark_initial, 1, double, NT, NT );
385  HICMA_stat_t hicma_statrk_initial;
386  zget_stat(MorseLower, Ark_initial, NT, NT, NT, &hicma_statrk_initial);
387  if(MORSE_My_Mpi_Rank()==0){
388  printf("------------------------------A initial_ranks:");
389  zprint_stat(hicma_statrk_initial);
390  }
391  fflush(stderr);
392  fflush(stdout);
393  }
394  PASTE_TILE_TO_LAPACK( descAdense, Aorg, 1, double, LDA, N );
395  { // fill upper part of Aorg so the rest of code taken from Chameleon works correctly.
396  int i, j;
397  for(j = 0; j < N; j++){
398  for(i = 0; i < j; i++){
399  //Aorg[j*LDA+i] = 0.0;
400  Aorg[j*LDA+i] = Aorg[i*LDA+j];
401  // Acham[j*LDA+i] = 0.0;
402  }
403  }
404  }
405  /*END AAAAAAAAAAAAAAAAAAAAAAAA */
406  /*BEGIN BBBBBBBBBBBBBBBBBBBBBBBB */
408  int NTB = ceil(NRHS*1.0/NB);
409  MORSE_desc_t *descBdense = NULL;
410  status = MORSE_Desc_Create(&descBdense, NULL, MorseRealDouble, NB, NB, NBxNB, LDA, NRHS, 0, 0, N, NRHS, P, Q);
411  if(status != MORSE_SUCCESS){ return status; }
412 
413  // For checking against chameleon
414  MORSE_desc_t *descBdense2 = NULL;
415  status = MORSE_Desc_Create(&descBdense2, NULL, MorseRealDouble, NB, NB, NBxNB, LDA, NRHS, 0, 0, N, NRHS, P, Q);
416  if(status != MORSE_SUCCESS){ return status; }
417  /*if randtlr*/
418  probtype = HICMA_STARSH_PROB_RND;
419  sym = 'N';
420  hicma_problem.noise = 0.0; //value added to diagonal
421 
422  ddecay = 1e-2;
423  //double fixedacc_B = 1e-3;
424  double fixedacc_B = fixedacc;
425  //printf("Generate problem for B\n");
426  //HICMA_zgenerate_problem(probtype, sym, ddecay, N, NB, NT, NT, &hicma_problem);
427  //mpiF = hicma_problem.starsh_format; // This is assignment will be hidden from user in release
428 
429  printf("Generate dense B\n");
430  MORSE_dplrnt_Tile(descBdense, 371 );
431  MORSE_dlacpy_Tile( MorseUpperLower, descBdense, descBdense2 );
432  //MORSE_dplrnt_Tile(descBdense2, 371 );
434  //HICMA_zhagdm_Tile(MorseUpperLower, descBdense);
435  PASTE_TILE_TO_LAPACK( descBdense, Borg, 1, double, LDA, NRHS );
436  /*END BBBBBBBBBBBBBBBBBBBBBBBB */
437  // Save A
438  MORSE_dlacpy( MorseUpperLower, N, N, Aorg, LDA, A1, LDA );
439  MORSE_dlacpy( MorseUpperLower, N, N, Aorg, LDA, A2, LDA );
440  if(main_print_mat ){printf("Aorg\n");printmat_format(Aorg,N,N,LDA,1000, 1000, 0);}
441  // Save B
442  MORSE_dlacpy( MorseUpperLower, N, NRHS, Borg, LDA, B1, LDA );
443  MORSE_dlacpy( MorseUpperLower, N, NRHS, Borg, LDA, B2, LDA );
444  if(main_print_mat ){printf("Borg\n");printmat_format(Borg,N,NRHS,LDB,1000, 1000, 0);}
445 
446 
447  MORSE_dpotrf(uplo, N, A2, LDA);
448  MORSE_dtrsm(MorseLeft, uplo, trans1, MorseNonUnit,
449  N, NRHS, 1.0, A2, LDA, B2, LDB);
450  if(0)cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, N, NRHS, N, 1.0, A1, LDA, B2, LDB, 0.0, B1, LDB);
451  MORSE_dtrsm(MorseLeft, uplo, trans2, MorseNonUnit,
452  N, NRHS, 1.0, A2, LDA, B2, LDB);
453 
454  printf("Potrf on A\n");
456  HICMA_zpotrf_Tile(MorseLower, descAUV, descAD, descArk, fixedrank, comp_maxrank, fixedacc );
458  HICMA_zuncompress(MorseLower, descAUV, descAdense, descArk);
460  HICMA_zdiag_vec2mat(descAD, descAdense);
461  PASTE_TILE_TO_LAPACK( descAdense, Ahicma, 1, double, LDA, N );
462  if(calc_rank_stat){ // print final ranks of L
463  PASTE_TILE_TO_LAPACK( descArk, Ark_initial, 1, double, NT, NT );
464  HICMA_stat_t hicma_statrk_initial;
465  zget_stat(MorseLower, Ark_initial, NT, NT, NT, &hicma_statrk_initial);
466  if(MORSE_My_Mpi_Rank()==0){
467  printf("------------------------------A final_ranks after HICMA_potrf():");
468  zprint_stat(hicma_statrk_initial);
469  }
470  fflush(stderr);
471  fflush(stdout);
472  }
473 
474  //Check Chameleon. A1 is original matrix, A2 is L coming from MORSE_dpotrf
475  //info_factorization = check_factorization( N, A1, A2, LDA, uplo, eps);
476  //Check Hicma. Aorg is original matrix, Ahicma is L coming from HICMA_dpotrf
477  info_factorization = check_factorization( N, Aorg, Ahicma, LDA, uplo, fixedacc);
478  //return info_factorization;
479 
480  //check if uncompress works well for B
481  /*HICMA_zuncompress(MorseUpperLower, descBUV, descBdense2, descBrk); */
482  /*PASTE_TILE_TO_LAPACK( descBdense2, Bhicma2, 1, double, LDA, N );*/
483  /*MORSE_dtrsm(MorseLeft, uplo, trans1, MorseNonUnit,*/
484  /*N, NRHS, 1.0, A2, LDA, Bhicma2, LDB);*/
485  /*MORSE_dtrsm(MorseLeft, uplo, trans2, MorseNonUnit,*/
486  /*N, NRHS, 1.0, A2, LDA, Bhicma2, LDB);*/
487  /*info_solution = check_solution(N, NRHS, Aorg, LDA, Borg, Bhicma2, LDB, eps);*/
488  /*return 0;*/
489 
490  printf("\n");
491  printf("------ TESTS FOR CHAMELEON ZPOTRF + ZTRSM + ZTRSM ROUTINE ------- \n");
492  printf(" Size of the Matrix %d by %d\n", N, N);
493  printf("\n");
494  printf(" The matrix A is randomly generated for each test.\n");
495  printf("============\n");
496  printf(" The relative machine precision (eps) is to be %e \n", eps);
497  printf(" Computational tests pass if scaled residuals are less than 60.\n");
498 
499  PASTE_TILE_TO_LAPACK( descBdense, arrayB_1, 1, double, LDA, NRHS );
500  PASTE_TILE_TO_LAPACK( descBdense2, arrayB2_1, 1, double, LDA, NRHS );
501  check_same_array(arrayB_1, arrayB2_1, N, __LINE__, __FILE__);
502 
503  printf("First trsm\n");
504  if(1)MORSE_dtrsm_Tile(MorseLeft, uplo, trans1, MorseNonUnit, 1.0,
505  descAdense, descBdense2);
506  if(1)HICMA_ztrsmd_Tile(MorseLeft, uplo, trans1, MorseNonUnit, 1.0,
507  descAUV,
508  descAD,
509  descArk,
510  descBdense, comp_maxrank);
511  PASTE_TILE_TO_LAPACK( descBdense, arrayB_2, 1, double, LDA, NRHS );
512  PASTE_TILE_TO_LAPACK( descBdense2, arrayB2_2, 1, double, LDA, NRHS );
513  check_same_array(arrayB_2, arrayB2_2, N, __LINE__, __FILE__);
514 
515  printf("Second trsm\n");
516  if(1)MORSE_dtrsm_Tile(MorseLeft, uplo, trans2, MorseNonUnit, 1.0,
517  descAdense, descBdense2);
518  if(1)HICMA_ztrsmd_Tile(MorseLeft, uplo, trans2, MorseNonUnit, 1.0,
519  descAUV,
520  descAD,
521  descArk,
522  descBdense, comp_maxrank);
523  PASTE_TILE_TO_LAPACK( descBdense, arrayB_3, 1, double, LDA, NRHS );
524  PASTE_TILE_TO_LAPACK( descBdense2, arrayB2_3, 1, double, LDA, NRHS );
525  check_same_array(arrayB_3, arrayB2_3, N, __LINE__, __FILE__);
526 
527  //printf("%s %d %s EXITING %e\n", __FILE__, __LINE__, __func__, fixedacc);exit(0);
528  PASTE_TILE_TO_LAPACK( descBdense, Bhicma, 1, double, LDA, NRHS );
529  int info_solution_hicma = check_solution(N, NRHS, Aorg, LDA, Borg, Bhicma, LDB, fixedacc);
530  //info_solution = check_solution(N, NRHS, Aorg, LDA, Borg, Bhicma, LDB, eps);
531  /* Check the factorization and the solution */
532  //info_factorization = check_factorization( N, A1, A2, LDA, uplo, eps);
533  info_solution = check_solution(N, NRHS, A1, LDA, B1, B2, LDB, eps);
534 
535  if ((info_solution_hicma == 0)&(info_solution == 0)&(info_factorization == 0)){
536  printf("***************************************************\n");
537  printf(" ---- TESTING ZPOTRF + ZTRSM + ZTRSM ..... PASSED !\n");
538  printf("***************************************************\n");
539  }
540  else{
541  printf("***************************************************\n");
542  printf(" - TESTING ZPOTRF + ZTRSM + ZTRSM ... FAILED !\n");
543  printf("***************************************************\n");
544  }
545 
546  free(A1); free(A2); free(B1); free(B2);
547  PASTE_CODE_FREE_MATRIX( descAdense );
548  PASTE_CODE_FREE_MATRIX( descBdense );
549  PASTE_CODE_FREE_MATRIX( descAdense2 );
550  PASTE_CODE_FREE_MATRIX( descBdense2 );
551  PASTE_CODE_FREE_MATRIX( descAD );
552  PASTE_CODE_FREE_MATRIX( descAUV );
553  PASTE_CODE_FREE_MATRIX( descArk );
554 
555  return hres;
556 }
557 
558 
559 /*------------------------------------------------------------------------
560  * Check the factorization of the matrix A2
561  */
562 static int check_factorization(int N, double *A1, double *A2, int LDA, int uplo, double eps)
563 {
564  double Anorm, Rnorm;
565  double alpha;
566  int info_factorization;
567  int i,j;
568 
569  double *Residual = (double *)malloc(N*N*sizeof(double));
570  double *L1 = (double *)malloc(N*N*sizeof(double));
571  double *L2 = (double *)malloc(N*N*sizeof(double));
572  double *work = (double *)malloc(N*sizeof(double));
573 
574  memset((void*)L1, 0, N*N*sizeof(double));
575  memset((void*)L2, 0, N*N*sizeof(double));
576 
577  alpha= 1.0;
578 
579  LAPACKE_dlacpy_work(LAPACK_COL_MAJOR,' ', N, N, A1, LDA, Residual, N);
580 
581  /* Dealing with L'L or U'U */
582  if (uplo == MorseUpper){
583  LAPACKE_dlacpy_work(LAPACK_COL_MAJOR,'u', N, N, A2, LDA, L1, N);
584  LAPACKE_dlacpy_work(LAPACK_COL_MAJOR,'u', N, N, A2, LDA, L2, N);
585  cblas_dtrmm(CblasColMajor, CblasLeft, CblasUpper, CblasTrans, CblasNonUnit, N, N, (alpha), L1, N, L2, N);
586  }
587  else{
588  LAPACKE_dlacpy_work(LAPACK_COL_MAJOR,'l', N, N, A2, LDA, L1, N);
589  LAPACKE_dlacpy_work(LAPACK_COL_MAJOR,'l', N, N, A2, LDA, L2, N);
590  cblas_dtrmm(CblasColMajor, CblasRight, CblasLower, CblasTrans, CblasNonUnit, N, N, (alpha), L1, N, L2, N);
591  }
592 
593  /* Compute the Residual || A -L'L|| */
594  for (i = 0; i < N; i++)
595  for (j = 0; j < N; j++)
596  Residual[j*N+i] = L2[j*N+i] - Residual[j*N+i];
597 
598  BLAS_dge_norm( blas_colmajor, blas_inf_norm, N, N, Residual, N, &Rnorm );
599  BLAS_dge_norm( blas_colmajor, blas_inf_norm, N, N, A1, LDA, &Anorm );
600 
601  printf("============\n");
602  printf("Checking the Cholesky Factorization \n");
603  printf("-- ||L'L-A||_oo/(||A||_oo.N.eps) = %e eps:%.1e\n",Rnorm/(Anorm*N*eps), eps);
604 
605  if ( isnan(Rnorm/(Anorm*N*eps)) || isinf(Rnorm/(Anorm*N*eps)) || (Rnorm/(Anorm*N*eps) > 60.0) ){
606  printf("-- Factorization is suspicious ! \n");
607  info_factorization = 1;
608  }
609  else{
610  printf("-- Factorization is CORRECT ! \n");
611  info_factorization = 0;
612  }
613 
614  free(Residual); free(L1); free(L2); free(work);
615 
616  return info_factorization;
617 }
618 
619 
620 /*------------------------------------------------------------------------
621  * Check the accuracy of the solution of the linear system
622  */
623 
624 static int check_solution(int N, int NRHS, double *A1, int LDA, double *B1, double *B2, int LDB, double eps )
625 {
626  int info_solution;
627  double Rnorm, Anorm, Xnorm, Bnorm, result;
628  double alpha, beta;
629  double *work = (double *)malloc(N*sizeof(double));
630 
631  alpha = 1.0;
632  beta = -1.0;
633 
634  BLAS_dge_norm( blas_colmajor, blas_inf_norm, N, NRHS, B2, LDB, &Xnorm );
635  BLAS_dge_norm( blas_colmajor, blas_inf_norm, N, N, A1, LDA, &Anorm );
636  BLAS_dge_norm( blas_colmajor, blas_inf_norm, N, NRHS, B1, LDB, &Bnorm );
637 
638  cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, N, NRHS, N, (alpha), A1, LDA, B2, LDB, (beta), B1, LDB);
639  BLAS_dge_norm( blas_colmajor, blas_inf_norm, N, NRHS, B1, LDB, &Rnorm );
640 
641  if (getenv("MORSE_TESTING_VERBOSE")) {
642  printf( "||A||_oo=%f\n||X||_oo=%f\n||B||_oo=%f\n||A X - B||_oo=%e eps:%.2e\n", Anorm, Xnorm, Bnorm, Rnorm, eps );
643  }
644  result = Rnorm / ( (Anorm*Xnorm+Bnorm)*N*eps ) ;
645  printf("============\n");
646  printf("Checking the Residual of the solution \n");
647  printf("-- ||Ax-B||_oo/((||A||_oo||x||_oo+||B||_oo).N.eps) = %e \n", result);
648 
649  if ( isnan(Xnorm) || isinf(Xnorm) || isnan(result) || isinf(result) || (result > 60.0) ) {
650  printf("-- The solution is suspicious ! \n");
651  info_solution = 1;
652  }
653  else{
654  printf("-- The solution is CORRECT ! \n");
655  info_solution = 0;
656  }
657 
658  free(work);
659 
660  return info_solution;
661 }
char datebuf[128]
blas_order_type
Definition: testing_zposv.c:90
int global_fixed_rank
int diag_nrows
blas_norm_type
#define USAGE(name, args, details)
int norm[4]
time_t timer
#define PASTE_TILE_TO_LAPACK(_desc_, _name_, _cond_, _type_, _lda_, _n_)
Definition: timing.h:168
int main_print_mat
#define PASTE_CODE_FREE_MATRIX(_desc_)
Definition: timing.h:165
struct tm * tm_info
int use_scratch
int main_print_index
int run_potrf
int global_check
#define HICMA_STARSH_PROB_RND
int global_always_fixed_rank
int testing_dposv(int argc, char **argv)
int print_progress
int HICMA_init()
Definition: hicma_init.c:2
int store_only_diagonal_tiles
int print_index
#define HICMA_STARSH_PROB_SS
int HICMA_zhagdm_Tile(MORSE_enum uplo, MORSE_desc_t *Dense)
Definition: zhagdm.c:57
int HICMA_zhagdmdiag_Tile(MORSE_enum uplo, MORSE_desc_t *Dense)
Definition: zhagdm.c:162
int print_index_end
int HICMA_ztrsmd_Tile(MORSE_enum side, MORSE_enum uplo, MORSE_enum transA, MORSE_enum diag, double alpha, MORSE_desc_t *AUV, MORSE_desc_t *AD, MORSE_desc_t *Ark, MORSE_desc_t *Bdense, int maxrk)
Definition: ztrsm.c:303
int num_mpi_ranks
int testing_dtrsmd(int argc, char **argv)
int HICMA_zpotrf_Tile(MORSE_enum uplo, MORSE_desc_t *AUV, MORSE_desc_t *AD, MORSE_desc_t *Ark, int rk, int maxrk, double acc)
Definition: zpotrf.c:79
int uplo[2]
int calc_rank_stat
int global_omit_computation
blas_cmach_type
Definition: testing_zposv.c:94
int HICMA_zhagcm_Tile(MORSE_enum uplo, MORSE_desc_t *AUV, MORSE_desc_t *Ark, int numrows_matrix, int numcols_matrix, int numrows_block, int numcols_block, int maxrank, double tol)
Definition: zhagcm.c:92
STARSH_blrf * mpiF
int print_mat